本文整理汇总了PHP中app\Auth::id方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::id方法的具体用法?PHP Auth::id怎么用?PHP Auth::id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Auth
的用法示例。
在下文中一共展示了Auth::id方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: scopeForUser
function scopeForUser($query, $id)
{
if (!$id) {
$id = Auth::id();
}
$query->whereHas('user_id', function ($query) use($id) {
$query->where('id', $id);
});
}
示例3: getSchedulesForDropdown
public function getSchedulesForDropdown()
{
# Only let the user see their schedules
$schedules = $this->where('user_id', '=', \Auth::id())->orderby('name', 'ASC')->get();
$schedules_for_dropdown = [];
foreach ($schedules as $schedule) {
$schedules_for_dropdown[$schedule->id] = $schedule->name;
}
return $schedules_for_dropdown;
}
示例4: scopeOwner
public function scopeOwner($q)
{
return $q->whereUserId(Auth::id());
}
示例5: scopeUpdateIdleUser
/**
* [scopeUserIdle description]
* @return [type] [description]
*/
public function scopeUpdateIdleUser(Builder $query)
{
return $query->where('id', Session::getId())->update(['user_id' => \Auth::id()]);
}
示例6: scopeAuth
public function scopeAuth($query, $input = false)
{
return $query->where('user_id', \Auth::id())->whereIn('action_type_id', $this->actionsType);
//trans('notices.actions')
}
示例7: notReadCount
public function notReadCount()
{
return $this->messages()->selectRaw('conversation_id, count(*) as aggregate')->where('user_id', '!=', \Auth::id())->where('read', '=', 0)->groupBy('conversation_id');
}
示例8: cantUpdate
public static function cantUpdate($id)
{
return \Auth::check() && (\Auth::id() == $id || \Auth::user() && in_array(\Auth::user()->role, ['admin', 'root']));
}
示例9: checkoutToMe
/**
* Checkout this model to the logged in user
* @method checkoutToMe
* @return [type] [description]
*/
public function checkoutToMe()
{
return $this->checkoutToId(\Auth::id());
}
示例10: isSameUser
public function isSameUser()
{
return (bool) ($this->user_id === \Auth::id());
}
示例11: scopeForLoggedInUser
public function scopeForLoggedInUser($query)
{
return $query->where('user_id', Auth::id());
}
示例12: 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;
});
}