If do you want to get logged in user information in laravel, Laravel auth function provide login user information you need to call Auth::User() function which returns all the details of users and also want to check user login or not then use laravel Auth::check function which return true or false.
1 2 3 4 5 6 |
if(Auth::check()){ $loggedIn_user=Auth::User(); dd($loggedIn_user); } |
How to create a record in Laravel using eloquent ?
To create a new record in the database using Laravel Eloquent, simply create a new model instance, set attributes on the model, then call the save method: example code give below.
1 2 3 4 5 6 7 |
public function saveProduct(Request $request ) $product = new product; $product->name = $request->name; $product->description = $request->name; $product->save(); |
Using save function you can simple insert data in database with all details which passed in request parameters.