Facundo Quintana Facundo Quintana - 2 months ago 19
PHP Question

get current user id laravel

i am trying to get the id of the current user on my controller this way

$post->user_id=Auth::user()->id;


I'm importing these classes

use Illuminate\Http\Request;
use conocermusica\Post;
use Illuminate\Support\Fecades\Redirect;
use conocermusica\Http\Requests\PostFormRequest;
use DB;


when i add:

use Auth;


I get the error

(1/1) FatalThrowableError
Class 'Illuminate\Support\Fecades\Redirect' not found

how can i do it?

Answer Source

Your import is wrong:

the path is 'Illuminate\Support\Facades\Redirect'