I have a doubt, I would like to recover the data that is logged in without having to go through the view, and use them in any view, so I decided to do in controller __construct
plus laravel does not let me take user data .
<?php
namespace App\Http\Controllers;
use App\User;
use app\Http\Requests\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Auth\Events\Authenticated;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
public function __construct()
{
$this->middleware(function ($request, $next) {
$this->projects = Auth::user()->id;
return $next($request);
});
$projects = $request->user();
}
}