user model laravel code example

Example 1: laravel update from query

$affected = DB::table('users')
              ->where('id', 1)
              ->update(['votes' => 1]);

Example 2: laravel check auth

use Illuminate\Support\Facades\Auth;

if (Auth::check()) {
    // The user is logged in...
}

Example 3: get user auth in laravel

Auth::user();

Example 4: laravel authentication

composer require laravel/ui

php artisan ui vue --auth

Example 5: laravel auth namespace

use Illuminate\Support\Facades\Auth;

Example 6: laravel query with trashed

$user->roles()->withTrashed()->get();

Tags:

Php Example