1<?php
2
3namespace App\Http\Controllers;
4
5use App\User;
6use Illuminate\Support\Facades\Auth;
7use App\Http\Controllers\Controller;
8
9class ProjectController extends Controller
10{
11 /**
12 * All of the current user's projects.
13 */
14 protected $projects;
15
16 /**
17 * Create a new controller instance.
18 *
19 * @return void
20 */
21 public function __construct()
22 {
23 $this->middleware(function ($request, $next) {
24 $this->projects = Auth::user()->projects;
25
26 return $next($request);
27 });
28 }
29}
30
1Laravel's laravel/ui package provides a quick way to scaffold all of the routes and views you need for authentication using a few simple commands:
2
3composer require laravel/ui
4
5php artisan ui vue --auth
1composer require laravel/ui
2
3php artisan ui vue --auth
4
5npm install && npm run dev
1// Only for laravel 6.x and higher
2composer require laravel/ui "^1.0" --dev
3
4php artisan ui vue --auth
1public function __construct()
2{
3 $this->middleware(function ($request, $next) {
4 $this->user = Auth::user();
5 return $next($request);
6 });
7}