Friday, 1 February 2019

Laravel controller

https://laravel.com/docs/5.7/controllers
You may generate an invokable controller by using the --invokable option of the make:controller Artisan command:
php artisan make:controller ShowProfile

<?php

namespace App\Http\Controllers;

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

class ShowProfile extends Controller
{
    /**
     * Show the profile for the given user.
     *
     * @param  int  $id
     * @return View
     */
    public function __invoke($id)
    {
        return view('user.profile', ['user' => User::findOrFail($id)]);
    }
}

No comments:

Post a comment