Questions tagged [route-model-binding]
24 questions
0
votes
2 answers
Laravel 9: Implicit model binding not working on nested one-to-many relationship
I have a problem using Laravel's implicit model binding using a nested route and a custom key (not ID). I have these example models:
Categories (migration):
public function up()
{
Schema::create('categories', function (Blueprint…

NKnuelle
- 234
- 2
- 19
0
votes
1 answer
Laravel Slugable Route Model Binding weird behaviour
I have a section in my project with the latest news articles. For this I have a:
Post model
Post resource controller and a
Resource Post Route.
Post Model
class Post extends Model
{
use HasFactory, Sluggable;
protected $fillable =…

Maik Lowrey
- 15,957
- 6
- 40
- 79
0
votes
1 answer
Route model binding with multiple wildcards
How to explicitly say to route model binding to fetch only related categories? I have my web.php file as follows:
Route::get('/catalog/{category}', [CategoryController::class,…

Coverdale101
- 7
- 1
- 2
0
votes
1 answer
Laravel Route Model Binding - Laravel 5.7
I'm trying to use Laravel's route model binding. I've setup a binding in the RoutesServiceProvider to perform some custom resolution logic. This works fine for the attributable parameter which requires both a string name and an id to…

DazedAndConfused
- 115
- 6
0
votes
1 answer
Laravel - How to implement a shared controller with working model route binding
Before everything, I'm using Laravel 6 and PHP 7.2.
Alright. I have various models on which I can do the same action. For the of being DRY, I thought of the following idea:
On each model I'll implement an interface, and I'll put the actual…

TheSETJ
- 518
- 9
- 25
0
votes
2 answers
How to find the parameter name expected in laravel model route binding
I have a route like this
Route::get('/vcs-integrations/{vcs-provider}/authenticate','VcsIntegrationsController@authenticate');
and the method to handle the route I am using the model route binding to happen is as follows

Shobi
- 10,374
- 6
- 46
- 82
0
votes
1 answer
How much model name matter in injecting into a function in controller[Base on a problem]?
days before i was working on my homework which a problem cause me many days to fix and it was weird for me but somehow I've got that problem again which i'm pretty sure it's about how i name my model when I'm injecting it into function. Here's the…

Atlas-Pio
- 1,063
- 11
- 26
0
votes
2 answers
Route uses Slug, but id needed for function
I'm using slugs to navigate in my site, but I need the id connected to the slug for a function.
Function:
public function categories(Request $request, $slug)
{
$categories = Category::where('slug', $slug)->get();
$announcements =…

SpookyCode
- 39
- 1
- 7
-2
votes
1 answer
How to pass encrypted ID as route parameter in Laravel Route Model Binding
I want to pass encrypted ID as route parameter. Currently, I'm using Route model binding and it returns a 404

Arun Raj KV
- 21
- 6