/** * @return User|null */ public function fetchUser() { $listUser = $this->hasMany('\\App\\Models\\SearchListUser')->join('users', 'search_list_users.user_id', '=', 'users.id')->whereNull('fetched_at')->where('users.status', '=', User::STATUS_AVAILABLE)->orderBy('order')->first(['search_list_users.*']); if ($listUser instanceof SearchListUser && $listUser->user_id > 0) { $listUser->fetched_at = Carbon::now()->toDateTimeString(); $listUser->save(); $user = User::whereId($listUser->user_id)->first(); $user->status = User::STATUS_PENDENT; $user->save(); return $user; } else { return null; } }
/** * Avvisa l'utente che ha accettato l'abbraccio che l'abbraccio è stato creato e che può entrare. * * @param Hug $hug */ private function alertSoughtUser(Hug $hug) { $soughtUser = User::whereId($hug->user_sought_id)->first(); Notifier::send($soughtUser, 'hug', 'created', ['hug_id' => $hug->id, 'search_id' => $hug->search_id, 'created_at' => $hug->created_at]); }
public function getDeleteFinish($id) { $result = array('state' => 0, 'msg' => ''); try { if (!$id) { throw new \Exception("Id de Usuario Inválido"); } User::whereId($id)->forceDelete(); $result['state'] = 1; } catch (\Exception $e) { $result['msg'] = $e->getMessage(); } return response()->json($result); }
/** * Notifica l'utente che ha avviato la ricerca che la ricerca è stata conclusa con successo. Sarà l'app ad occuparsi * di inviarmi la conferma a voler entrare nell'abbraccio. * * @param Search $search */ private function notifyTheSearcher(Search $search) { $user = User::whereId($search->user_id)->first(); Notifier::send($user, 'search', 'userFound', ['search_id' => $search->id]); }
public function unlinkUser($userAccountId, $userId) { $userAccount = UserAccount::whereId($userAccountId)->first(); if ($userAccount->hasUserId($userId)) { $userAccount->removeUserId($userId); $userAccount->save(); } $user = User::whereId($userId)->first(); if (!$user->public_id && $user->account->company->accounts->count() > 1) { $company = Company::create(); $company->save(); $user->account->company_id = $company->id; $user->account->save(); } }
/** * Ritorna l'ultimo utente estratto * * @return User|null */ public function getLastFetchedUser() { $userId = (int) $this->getLastFetchedUserId(); $user = User::whereId($userId)->first(); return $user; }
/** * Update User Group * * @param Int $id * @param Int $group * @param Request $request * @return Response */ public function putGroup($id, $group, Request $request) { if (!$this->appKeyAvailable($request)) { return $this->notAuthorized($request); } if ($this->isSessionEmpty($request)) { $this->setResultError("Session token is missing", 401); } elseif ($this->setSessionUser($request)) { $user = User::whereId($id)->first(); if (!$this->isAdmin()) { $this->setResultError("Unauthorized action", 403); } elseif ($user === null) { $this->setResultError("User not found", 404); } elseif ($group < 1 || $group > 3) { $this->setResultError("Group not found", 404); } else { $user->group_id = $group; $user->save(); $this->setResultOk(); } } else { $this->setResultError("Mismatched session token", 401); } return $this->setResponse(); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { User::whereId($id)->update($request->get('user')); return redirect()->route('ref.profile'); }
return \App\models\Project::whereSlug($slug)->first(); }); $router->bind('clients', function ($id) { return \App\models\Client::whereId($id)->first(); }); $router->bind('types', function ($id) { return \App\models\Type::whereId($id)->first(); }); $router->bind('phases', function ($id) { return \App\models\Phase::whereId($id)->first(); }); Route::get('search/{word}', 'PagesController@search'); Route::resource('clients', 'ClientsController'); Route::resource('types', 'TypesController'); Route::resource('phases', 'PhasesController'); Route::get('phases/addTiming/{id}', 'PhasesController@timing'); Route::get('searchPhase/{word}', 'PhasesController@search'); Route::get('searchClientsPhases/{word}', 'PhasesController@searchcp'); Route::get('searchPerType/{word}', 'PhasesController@searchPerType'); Route::get('phases/updateTaskTitle/{id}', 'PhasesController@updateTaskTitle'); Route::resource('projects', 'PagesController'); Route::get('projects/updateProjectStatus/{arr}', 'PagesController@updateProjectStatus'); Route::get('projects/sortby/{status}', 'PagesController@sortby'); Route::resource('clientsProjects', 'PagesController@searchClientsProjects'); Route::get('projects/singleTask/{id}', 'PagesController@updateSingleTask'); Route::resource('comments', 'CommentController'); Route::get('usersCreate', 'UsersController@create'); $router->bind('users', function ($id) { return \App\models\User::whereId($id)->first(); }); Route::resource('users', 'UsersController');