本文整理汇总了PHP中app\Auth::check方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::check方法的具体用法?PHP Auth::check怎么用?PHP Auth::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Auth
的用法示例。
在下文中一共展示了Auth::check方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: customCreate
public static function customCreate(CreateConversationRequest $request)
{
$conv = new Conversation();
$conv->Title = $request->Title;
// if nothing specified in the request
if (!$request->has('user_id')) {
// if we are not even logged ( happen while seeding base)
if (!\Auth::check()) {
$conv->user_id = User::first()->id;
} else {
$conv->user_id = \Auth::id();
}
}
// if Pending status is specified we take it, if not default value will be applied (false)
if (!$request->has('Pending')) {
$conv->Pending = $request->Pending;
}
$conv->created_at = Carbon::now();
$conv->save();
// When conversation is settled the Thread can be created
$thread = new Thread();
$thread->user_id = $conv->user_id;
$thread->Content = $request->Content;
$thread->conversation_id = $conv->id;
$thread->created_at = Carbon::now();
$thread->Pending = $conv->Pending;
$thread->save();
return true;
}
示例2: userReadDiscussion
public function userReadDiscussion()
{
if (\Auth::check()) {
return $this->hasMany('App\\UserReadDiscussion')->where('user_id', '=', \Auth::user()->id);
} else {
abort(500, 'Need to be logged in to access this userReadDiscussion relation');
}
}
示例3: myWatchlist
public function myWatchlist()
{
if (Auth::check() && Watchlist::where('user_id', Auth::user()->id)->where('art_id', $this->id)->exists()) {
return true;
} else {
return false;
}
}
示例4: tipoUserLogado
public static function tipoUserLogado()
{
if (!\Auth::check()) {
return "*";
}
$user = User::whereRaw('name=?', [\Auth::user()->name]);
if ($user->count() == 1) {
return $user->first()->tipo;
}
return "";
}
示例5: getQotd
/**
* @return string
*/
public static function getQotd()
{
if (Cache::has('qotd')) {
$quote = Cache::get('qotd');
if (is_null($quote->speaker)) {
return "<span class='text-lg'>“</span> {$quote->text} <span class='text-lg'>”</span>";
} else {
return "<span class='text-lg'>“</span> {$quote->text} <span class='text-lg'>”</span><br> - {$quote->speaker}";
}
} else {
if (\Auth::check() && \Auth::user()->isAdmin()) {
return "<span class='text-danger'><i>No Quote set as Quote of the Day and so a random quote will be shown to public.</i></span>";
}
$quote = self::random();
if (is_null($quote->speaker)) {
return "<span class='text-lg'>“</span> {$quote->text} <span class='text-lg'>”</span>";
} else {
return "<span class='text-lg'>“</span> {$quote->text} <span class='text-lg'>”</span><br> - {$quote->speaker}";
}
}
}
示例6: cantUpdate
public static function cantUpdate($id)
{
return \Auth::check() && (\Auth::id() == $id || \Auth::user() && in_array(\Auth::user()->role, ['admin', 'root']));
}
示例7: scopeVisible
/**
* @param Builder|\Illuminate\Database\Eloquent\Builder|Profile $query
* @return mixed
*/
public function scopeVisible($query)
{
return $query->where(function ($query) {
$query = $query->approved();
if (\Auth::check()) {
$query = $query->orWhere('user_id', \Auth::id());
}
return $query;
});
}