Back

Auth::user()


Kubanacx posted 1 week ago

When I use Auth::user() in a controller I get null as a result. The reason I need the ID of the current authenticated user is to insert it into another table.

class GetterController extends Controller {
  public function test(){
            $sqlObject = new Order;
            $sqlObject->obrok_id = some_integer;
            $sqlObject->user_id = Auth::user()->id;
            $sqlObject->prilozi = "text";

            $sqlObject->save();
  }

}
Dries Vints replied 1 week ago

What does it say when you do a dd(Auth::check())?


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us