Hey there! 👋 Do you want an easy way to deep link your Backpack columns? Well, you're in luck! Backpack has introduced a new column at...
Hey there! 👋
Do you want an easy way to deep link your Backpack columns? Well, you're in luck!
Backpack has introduced a new column attribute called linkTo()
. This simplifies the process of linking columns to specific routes.
So you make UX better, while saving you from writing verbose code.
Previously, linking a column to a route required the manual setup of the wrapper['href']
. For instance:
CRUD::column('category')->wrapper([
'href' => function ($crud, $column, $entry, $related_key) {
return backpack_url('category/'.$related_key.'/show');
},
]);
Isn't that a lot to handle while doing for many columns? Well, worry no more! With the new linkTo() attribute, now you can achieve the same functionality with a single line:
CRUD::column('category')->linkTo('category.show');
Yes, it's that simple! linkTo()
checks if your named route requires a parameter and passes the related entry ID.
And, This works for 1-n relationship columns too:
CRUD::column('tags')->linkTo('tag.show');
But wait, there's more! You can pass additional parameters or use a closure instead of a route name. Take a look at these examples:
//Pass additional parameters to your URLs
CRUD::column('my_column')->linkTo('my.route.name', ['myParameter' => 'value']);
//Use a closure instead of a route name
CRUD::column('category')->linkTo(fn($entry, $related_key) => backpack_url('category/'.$related_key.'/show'));
Now you know it! Go, Deep link your admin panel and bring a huge UX improvement within a few minutes. Trust us, your admins will love you for it!
To know more, visit the docs.
Subscribe to our "Article Digest". We'll send you a list of the new articles, every week, month or quarter - your choice.
What do you think about this?
Wondering what our community has been up to?