laravel Missing required parameter for [Route: adm.index] [URI: admin/{name}] [Missing parameter: name]

Viewed 28

controller.php

public function index($name)
{
    $academy = Academy::where('won_main',Auth::user()->id)->first();
    return view('auth.dashboard.admin.index',['name'=> $academy]);
}

web.php

Route::controller(AcademyController::class)
    ->prefix('admin')
    ->middleware('auth')
    ->group(function ()
    Route::get('/{name}','index')->name('adm.index');
});

html

<a href="{{ route('adm.index',['name'=> $name ])}}">

model

protected $table = 'academies';
protected $primaryKey = 'id';
protected $fillable = [
    'user_id',
    'acadamy_code',
    'won_name',
    'won_main',
    'role',
];

use HasFactory;

version laravel 9.2

I want domain.test/name

It's been a long time, but it's not working. I ask for your help.

1 Answers

checkout your Html <a href=“”>. You’re passing and array [‘name’ => $name] whereas you’re Route is expecting a string $name.
Try this:
<a href=“{{route(‘adm.index’,$name)}}”>

Related