Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+ | Column - Listing - Link #2376

Merged
merged 1 commit into from
Jan 9, 2024
Merged

+ | Column - Listing - Link #2376

merged 1 commit into from
Jan 9, 2024

Conversation

agnonym
Copy link
Contributor

@agnonym agnonym commented Nov 29, 2023

Description

Add Link as available Listings Columns, allowing to create a link with:

  • url: callback
  • content: string or callback
  • shouldOpenInNewWindow: to add target="_blank" on the rendered link

Usage examples:

Link to a route, with the URL displayed and opened in a new window.

        $tableColumns->add(
            Link::make()
                ->field('url')
                ->title('URL')
                ->url(function (Model $item) {
                    return route('item.show', ['slug' => $item->slug], true);
                })
                ->shouldOpenInNewWindow()
        );

Link to a twill route, with dynamic content.

        $tableColumns->add(
            Link::make()
                ->field('requests')
                ->title('Requests')
                ->url(function (Model $item) {
                    $filter = [
                        'status' => 'all',
                        'item' => $item->id,
                    ];
                    return route('twill.requests.index', ['filter' => json_encode($filter)]);
                })
                ->content(function (Model $item) {
                    return $item->requests?->count();
                })
        );

@ifox ifox merged commit 50ee137 into area17:3.x Jan 9, 2024
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants