New In Laravel 7 - e06 - Route Model Binding Improvements

preview_player
Показать описание
Route Model Binding is one of the coolest and most used features of Laravel. Laravel 7 comes with some welcomed changes which include the new key customization and automatic scoping in nested routes. Let's take a look at some concrete example of how it works.

Foreign Devs Podcast

Documentation

DigitalOcean Referral

It's that time of the year again when we get new fresh features in Laravel. Let's explore what is coming to the latest version of Laravel.
Рекомендации по теме
Комментарии
Автор

Dynamic view without a controller... Magic 💫😱😍

Stoney_Eagle
Автор

please start a series on any famous ecommerce laravel package

mrnli
Автор

you are one the best explainer. always loved your content. if you can please upload a video about larvel 6 to 7 upgrade guide

jayedkhan
Автор

Good video Bro, you should do one that says 50 tricks with laravel

abelenocrodriguez
Автор

thanks victor!!! this is really awesome feature!

mel-
Автор

Hi Victor! Would you do any tutorial on how to build SPA with Laravel, Vue, and Inertia.js?

kapa
Автор

I was actually thinking how to put a slug in my laravel 6 project and this makes me to finally update my laravel version :D

Adbal
Автор

Oh wow... This is definitely going to be helpful. Thank you!
One question: what if we have /user/1/post/2/comment/3 (all have in the route ":id") ?
It will be "comment" for that "port" for that "user"?
Is there a way to make it another level up like:
Get the "comment" for that "post" for thet "user" AND the "comment" has to be from that "user"

kmtsvetanov
Автор

How does the model binding work for resource controller with nested multiple parameters ?


Example:


( where 'posts' table has 'user_id' foreign key and 'comments' table has 'post_id' foreign key )



Using:
Route::resource('users.posts.comments', 'BlogController');


instead of doing:

turagoda
Автор

Thanks for the video as always.


I'm not sure what we're gaining here, it looks like another way to do something we could already very easily do with getRouteKeyName().
What if we use the Route::resource method? Looks like it wouldn't work and would require to use the getRouteKeyName() method anyway...


Also not sure about the extra protection added to the route model binding; I feel like this authorization logic belongs in a Policy. That could be confusing to debug IMHO.

Virtualmix
Автор

This is going to be really useful for what i'm working on now. Are you planning to release a video on how to do upgrades from v6 to v7?

KristofNachtergaele
Автор

Thanks this is awesome. Who would you handle something like I think this is also real when i can have lets say /category2/subcategory wit the same name as category1. However i cant figure out how to next more subcategories.

someguytu
Автор

Is the protection thing a bug? Or is it because the ID is unique to each post, but slugs aren't necessarily? So for example, "/users/1/posts/a-cool-post" and "/users/2/posts/a-cool-post" are two completely different posts.

ExpDev
Автор

so if I want to pull id with slug, not just id or slug, I must use {post:id}-{post:slug} ?

efai
Автор

What would the protection do if the column in the posts table was `author_id`?

mokhosh
Автор

How to use specify key name in resource route???

shameulzion
Автор

Very strange., its doesn't work for me!
And in dump don`t choose id, I see only dump of instance. Do any one know what a problem?

zMULDERz
Автор

what if my slug is not in the database, iam getting not found since i dont have slug field and im using accessor, solution please?

aqshalzakki
Автор

Why is the default with mandatory id ? I mean, the binding concept is that i don't have to tell to Laravel look at the post id

julienSibille
Автор

So now Laravel 7 is optimized for blog development (I assumed)?

But yeah, hidden product listing details owned by a seller could be useful too.

Knee-Lew