本文整理汇总了PHP中app\Auth::User方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::User方法的具体用法?PHP Auth::User怎么用?PHP Auth::User使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Auth
的用法示例。
在下文中一共展示了Auth::User方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UserProfilePicture
/**
* Saving and Database Recording Users Default Picture
* @param UploadedFile $file Library for Uploading Files Locally or Cloud
* @param User $user Users Model
*/
public function UserProfilePicture(UploadedFile $file, User $user)
{
$Image = $file->getClientOriginalName();
$Imagename = 'DP_' . $Image;
$file->move(\Auth::User()->username . '/profile_images/', $Imagename);
$user->userData()->update(['profile_picture' => '/' . \Auth::User()->username . '/profile_images/' . $Imagename, 'picture_name' => $Imagename]);
}
示例2: numberUnreadMessages
public function numberUnreadMessages()
{
$count = 0;
foreach (\App\Message::all() as $message) {
if ($message->to == \Auth::User()->id && $message->read == 0) {
$count++;
}
}
return $count;
}
示例3: followingCheck
public function followingCheck()
{
return $this->hasOne('App\\Follow', 'followee_id', 'id')->selectRaw('followee_id')->where('follower_id', '=', \Auth::User()->id);
}
示例4: HasPermissions
public function HasPermissions($Permissions)
{
// I cannot believe laravel does not support db sets hence this shitty function.
$objUser = \Auth::User();
if (!$objUser) {
return false;
}
$tPermissions = explode('/', $Permissions);
foreach ($tPermissions as $Permission) {
switch ($Permission) {
case 'Admin Panel':
if ($objUser->role == static::ROLE_CLIENT) {
return false;
}
break;
default:
return false;
break;
}
}
return true;
}