/** * Recherche un utilisateur * * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function users(Request $request) { if ($request->isMethod('post')) { $query = $request->input('search_user'); $users = User::where(DB::raw("CONCAT(firstname, ' ', lastname)"), 'LIKE', "%{$query}%")->orWhere('username', 'LIKE', "%{$query}%")->paginate(15); } else { $users = []; } return view('search.users_results', ['users' => $users]); }
/** * Permet de supprimer un membre de ses contacts * * @param $username * @return \Illuminate\Http\RedirectResponse */ public function remove($username) { $user = User::where('username', $username)->first(); if (!$user) { alert()->error('Cet utilisateur n\'existe pas'); return redirect()->route('front.index'); } alert()->success($user->full_name . ' ne fait plus parti de vos contacts'); return redirect()->route('front.index'); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); }
/** * Run the database seeds. * * @return void */ public function run() { \WebCoding\Models\User::create(['email' => '*****@*****.**', 'password' => bcrypt('azerty'), 'username' => 'SquallX']); }
/** * Edition du compte * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function editAccount() { $user = User::findOrFail(Auth::user()->id); return view('profile.user_account', compact('user')); }
/** * L'auteur et ses amis peuvent liker une publication * * @param User $user * @param Activity $activity * @return bool */ public function like(User $user, Activity $activity) { return $user->id != $activity->user->id && !$user->isFriendWith($activity->user); }
/** * Est ce qu'un utilisateur peut commenter le statut d'un autre ? * * @param User $user * @param Activity $activity * @return bool */ public function create(User $user, Activity $activity) { return $user->isFriendWith($activity->user) || $user->id === $activity->user->id; }