Laravel Controllers Basic Controllers



namespace App\Http\Controllers;

use App\User;
use App\Http\Controllers\Controller;

class UserController extends Controller
     * Show the profile for the given user.
     * @param  int  $id
     * @return Response
    public function show($id)
        return view('user.profile', ['user' => User::findOrFail($id)]);

You can define a route to this controller action like so:

Route::get('user/{id}', 'UserController@show');

Now, when a request matches the specified route URI, the show method on the UserController class will be executed. Of course, the route parameters will also be passed to the method.