Questions tagged [route-model-binding]
24 questions
6
votes
4 answers
Laravel BelongsTo Through relationship
How to implement BelongsToThrough Relationship in Laravel?
I have Table:
**projects_table**
id
**categories_table**
id
project_id
**properties_table**
id
category_id
Category BelongsTo Project
public function project(){
return…

Lim Socheat
- 705
- 2
- 12
- 25
3
votes
5 answers
How to change Route Model Binding finding data from id to slug
I have a route like the following.
Route::get('/articles/{articleSlug}' ,
[App\Http\Controllers\ArticleController::class, 'single']);
And the method of single() at ArticleController class goes here:
public function single($slug)
{
$article…

Pouya
- 114
- 1
- 8
- 36
2
votes
2 answers
Laravel Route Model Binding Reusability
I'm creating a like feature for my application where users can like posts, events, products etc.
I have a LikeController and a Trait which handles the like functionality
public function store(Post $post)
{
$post->like();
return…

Danny Younes
- 579
- 1
- 6
- 19
2
votes
1 answer
Laravel won't resolve model
I'm building an application to track expenses, using laravel 5.8 as the back-end.
When I try to access the show method on my controller, I find laravel is giving me a fresh instance of the model instead of fetching the one matching the id…

KeepoN
- 137
- 1
- 11
1
vote
0 answers
Laravel Route model binding throws NotFoundHttpException instead of ModelNotFoundException
I am using route model binding for my API routes.
Route::middleware('client')->group(function(){
Route::get('/documents/{document}', [DocumentController::class, 'get']);
Route::apiResource('documents',…

Vüsal Hüseynli
- 889
- 1
- 4
- 16
1
vote
1 answer
Update and Edit on Resource Controller: Can't Find Query Results for Model
I have a resource controller in my Laravel app, where all resource functions are placed. So far I have the creation and store functions working fine, but it falls on edit() and update(). As far as I can see, the issue is that it's not grabbing the…

Adnan Ali
- 61
- 6
1
vote
1 answer
Laravel 8 route model binding not return ant record?
I am using below code for route model binding but the binding variable does not return any value.
MY ROUTE
Route::resource('offertypes', 'OfferTYpeController');
CONTROLLER CODE
public function edit(OfferType $offerType)
{
…

Gagan Sharma
- 17
- 5
1
vote
2 answers
Route Model Binding Problem Does Not Seem To Be Working
I'm working with Laravel 8 and I have made a table like this at Blade:
Username |
---|