Hao Phung
Hao Phung

Reputation: 99

laravel route by passing parameter got page not found

I just regular do the route with passing parameter

Route::get('cabinet', 'CabinetController@index');
Route::get('cabinet/{$id}', 'CabinetController@show');

and the controller just simple like this

class CabinetController extends Controller
{
    function index()
    {
        $cabinets = Cabinet::all();
        return view('detail', compact('cabinets'));
    }
    function show($id)
    {
        $single = Cabinet::find($id);
        $cabinets = Cabinet::all();
        return view('detail', compact('cabinets', 'single'));
    }
}

public/cabinet/1 How come i got Sorry, the page you are looking for could not be found.

Thank you for solve this for me

Upvotes: 0

Views: 193

Answers (1)

DevK
DevK

Reputation: 9942

Remove the $ from route declaration:

Route::get('cabinet/{id}', 'CabinetController@show');

Upvotes: 1

Related Questions