예제 #1
0
 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
0
 function scopeForUser($query, $id)
 {
     if (!$id) {
         $id = Auth::id();
     }
     $query->whereHas('user_id', function ($query) use($id) {
         $query->where('id', $id);
     });
 }
예제 #3
0
파일: Schedule.php 프로젝트: eldaronco/p4
 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
0
 public function scopeOwner($q)
 {
     return $q->whereUserId(Auth::id());
 }
예제 #5
0
 /**
  * Take all users with roles
  *
  * @return array
  */
 public static function allUsersWithRoles()
 {
     $users = \DB::table('users')->join('role_user', 'users.id', '=', 'role_user.user_id')->join('roles', 'roles.id', '=', 'role_user.role_id')->where('users.id', '<>', \Auth::id())->whereNull('users.deleted_at')->select('users.*', 'roles.name as role', 'roles.slug', 'roles.level');
     return $users->orderBy('first_name', 'asc')->get();
 }
예제 #6
0
파일: Online.php 프로젝트: Crisfole/LAZ
 /**
  * [scopeUserIdle description]
  * @return [type] [description]
  */
 public function scopeUpdateIdleUser(Builder $query)
 {
     return $query->where('id', Session::getId())->update(['user_id' => \Auth::id()]);
 }
예제 #7
0
파일: Notice.php 프로젝트: rolka/antVel
 public function scopeAuth($query, $input = false)
 {
     return $query->where('user_id', \Auth::id())->whereIn('action_type_id', $this->actionsType);
     //trans('notices.actions')
 }
예제 #8
0
 public function notReadCount()
 {
     return $this->messages()->selectRaw('conversation_id, count(*) as aggregate')->where('user_id', '!=', \Auth::id())->where('read', '=', 0)->groupBy('conversation_id');
 }
예제 #9
0
파일: User.php 프로젝트: ant-vel/Web
 public static function cantUpdate($id)
 {
     return \Auth::check() && (\Auth::id() == $id || \Auth::user() && in_array(\Auth::user()->role, ['admin', 'root']));
 }
예제 #10
0
 /**
  * Checkout this model to the logged in user
  * @method checkoutToMe
  * @return [type]       [description]
  */
 public function checkoutToMe()
 {
     return $this->checkoutToId(\Auth::id());
 }
예제 #11
0
 public function isSameUser()
 {
     return (bool) ($this->user_id === \Auth::id());
 }
예제 #12
0
파일: Book.php 프로젝트: MedElans/library
 public function scopeForLoggedInUser($query)
 {
     return $query->where('user_id', Auth::id());
 }
예제 #13
0
 /**
  * @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;
     });
 }