-
Notifications
You must be signed in to change notification settings - Fork 907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot access current user in controller #95
Comments
And a shitload of other tickets regarding this issue... |
Apparently this is a know breaking change in Laravel 5.3, just like @axyr said. I've found this solution: <?php
namespace App\Http\Controllers;
use App\User;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
class ProjectController extends Controller
{
public function __construct()
{
$this->middleware(function ($request, $next) {
$this->projects = Auth::user()->projects;
return $next($request);
});
}
} from this article, but... it doesn't look very sexy to me. NOTE YOU NO LONGER HAVE TO DO THIS - YOU SHOULD BE USING THE NEW SYNTAX<?php
namespace App\Http\Controllers;
use App\User;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
class ProjectController extends Controller
{
public function setup()
{
$this->projects = Auth::user()->projects;
}
} |
We've included a simpler solution into So: If you want to use Note: This change is backwards-compatible. You can still define everything inside |
Awesome! test ok! |
Tried it, works like magic! Thanks! |
I've tried the following:
All of them are returning null. I've tried to add some middleware to the route group:
Am I missing something?
The text was updated successfully, but these errors were encountered: