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

Add linkTo cell setting #461

Merged
merged 6 commits into from
Sep 26, 2021
Merged

Add linkTo cell setting #461

merged 6 commits into from
Sep 26, 2021

Conversation

fabio-ivona
Copy link
Contributor

Hi @rappasoft

as usual: you're doing a great work! A lot of livewire datatables packages are showing up, but yours is the one that better balances features and DX!

I'll try to contribute by adding a new ->linkTo(...) method to a column:

with this PR, during the table columns setup you could do:

return [
            //...

            Column::make('Name', 'name')
                ->linkTo(fn($value, $column, $row) => route('pets.edit', $row->id))
                ->searchable(),

            //...
        ];

and this will result in the table cell being rendered with this content:

<a href='http://my.domain/pets/5/edit'>My Pet 5 Name</a>

So the cell would be clickable and be linked to the url generated by the ->linkTo() callback:

Note: a second parameter for the ->linkTo() method allows to hint the link target:

  Column::make('Name', 'name')
                ->linkTo(fn($value, $column, $row) => route('pets.edit', $row->id), '_blank')
                ->searchable(),

What do you think?

@rappasoft
Copy link
Owner

When would this be more useful than this though? https://rappasoft.github.io/laravel-livewire-tables-docs/rows/Clickable-Rows

@fabio-ivona
Copy link
Contributor Author

fabio-ivona commented Sep 21, 2021

This is intended to work on a single cell, a different use case

And, as it would be defined in the Column, a more fluent syntax

@kevyworks
Copy link

Can we merge this? If the library has like Macro I would go with that approach as well.

@rappasoft rappasoft added the Awaiting Next Release Currently merged into development awaiting a release to master label Sep 26, 2021
@rappasoft rappasoft mentioned this pull request Sep 26, 2021
@rappasoft rappasoft merged commit 8d7aff8 into rappasoft:master Sep 26, 2021
@fabio-ivona fabio-ivona deleted the add-linkto-cell-property branch September 26, 2021 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Next Release Currently merged into development awaiting a release to master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants