laravel auth user in constructor
<?php
namespace App\Http\Controllers;
use App\User;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
class ProjectController extends Controller
{
/**
* All of the current user's projects.
*/
protected $projects;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware(function ($request, $next) {
$this->projects = Auth::user()->projects;
return $next($request);
});
}
}
Laravel make:auth
composer require laravel/ui
php artisan ui vue --auth
php artisan migrate
laravel auth
composer require laravel/ui
php artisan ui vue --auth
npm install && npm run dev
Laravel make auth
Laravel'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:
composer require laravel/ui
php artisan ui vue --auth
Laravel setup auth
// Only for laravel 6.x and higher
composer require laravel/ui "^1.0" --dev
php artisan ui vue --auth
Laravel auth user in constructor
public function __construct()
{
$this->middleware(function ($request, $next) {
$this->user = Auth::user();
return $next($request);
});
}
0 comments:
Post a Comment
Thanks