with parameter

There's an instance that we need to pass a parameter to our routes. Just remember that inside the braces {your-desired-name} you can define your desired name for your id's or parameters.This is how we do it in sprnva.

Route::get("/profile/detail/{id}", ['ProfileController@detail', ['auth']]);

Then the controller's method accepts a parameter.

<?php

namespace App\Controllers;

class UsersController
{
    public function detail($id){
        //code here
    }
}

Last updated