User specific items

This commit is contained in:
Kode
2018-10-14 17:27:28 +01:00
parent 46bb073001
commit c3da17befc
15 changed files with 367 additions and 18 deletions

View File

@@ -43,4 +43,17 @@ class User extends Authenticatable
return $this->belongsToMany('App\Setting')->withPivot('value');
}
public static function currentUser()
{
$current_user = session('current_user');
if ($current_user) { // if logged in, set this user
return $current_user;
} else { // not logged in, get first user
$user = User::first();
session(['current_user' => $user]);
return $user;
}
}
}