Laravel Route Model Binding: All You Need To Know

preview_player
Показать описание
Quite often in the Controllers, you don't have to use findOrFail() by ID field from the URL, instead, you may use Route Model Binding. In this video, I will show you how.

- - - - -
Support the channel by checking out our products:
Рекомендации по теме
Комментарии
Автор

Great video. The missing method and changing route key for a specific route was new information for me. Thanks

rahulraveendran
Автор

Perfect content. This is almost assumed knowledge, but it's not something I ever came across when first delving into Laravel. Consequently I learned by osmosis which isn't ideal. I know you'll solve this problem for others with your new learning roadmap. Great stuff.

rossco
Автор

Today I am extremely happy... IT have upgraded our LTS server to the latest SP which includes PHP 7.4, so I can finally start playing around with Laravel 8! Oh, and nice vid Povilas as always!

martinh
Автор

Great content as always, the missing method it's a magic. I'm following your channel quite well from Africa/Dar es salaam. Keep up Good work

tradewithtony
Автор

i finish the LEVEL 1 and I am doing NOW the LEVEL 2 and this improve a lot my level THANK YOU SO MUCH

ChangeYourLifeForever
Автор

I was looking for how to change the route key, and you showed it, although it was the tiny unnecessary thing that either everybody knows well or nobody needs at all. Liked and subscribed at that moment :) Thank You!

sadiriy
Автор

One more thing to add. If you want to bind a resource, nested resource or any route, you can you use scope as well. You can use it when you have multiple route model binding and you don't need to use the getRouteKeyName function

orpheusohms
Автор

Sir awesome knowledge which you are sharing with us. Thanks for this. Sir i have question that what is alternative of id in url. And is it safe to show id in url.

NotBeHaris
Автор

php artisan make:controller CategoryController --resource --model=Category can be shorted for php artisan make:controller CategoryController -r -m Category

rolandosanches
Автор

Is there any solutions for route model binding with hasMany relationships? If a user has many products, works fine, but with route model binding, user can get access to other products. Middleware checking will create an extra load (double DB request).

ZhanOmar
Автор

5:25 Can I get data using more than one database row? For example, id OR slug to bring the same result?

guilhermemoraes
Автор

i need show info, table product and category, union how whit model binding?

ggmm
Автор

is the capital Email and Password affect in attempt method in laravel i add field name in camalcase in database.

if(Auth:: attempt (['Email'=>$request->email, 'Password'=>$request->password]))

this will return always false if i used Email and Password instead of email and password.

can you tell me why this happening??

ravaliyanikunj
Автор

Is it possible to cache the eloquent model?

LippittDesigns
Автор

Does the route model binding check policies or gates?

krunalshrimali
Автор

what if i need to add another condition like created_by = auth()->user()

crispy-channel
Автор

Awesome content, I didn't know most of the details described on this video. I have a question, any help would be appreciated, is there any way to use route model binding with collection instead of single model? I'm trying to implement this feature with livewire in a project but I haven't any success yet😥

alexisarcegomez
Автор

Hi
I have tried route building and see the query in laravel debugger it's making query select * from products where slug = product-1, how can I select specific columns only for example I only want 3 filed to show and want to select that particular fields only. Can we do so?

jagrutivaru
Автор

Well explained, I didn't know about the missing() function yet on routes. Hope you will get the 100k subscribers but I think you will need to extend your content to different languages and frameworks as the PHP market share has been in decline for a couple of years now. To put things in perspective, you already have more subscribers than the Laravel subreddit has so I doubt there is much more growth to gain.

user
Автор

I use this method a lot. However, I encountered an issue ModelNotFoundException error: No query results for the model. I don't know what went wrong yet I implemented the same thing in other parts of the application and it works very well. I get the error on my edit resource. I can't find what went wrong

emmanuels.emokor