public function postUpdate($id, Request $request) { $user = Auth::getUser(); if ($user->email == $request->get('email')) { // user try to change own password $validatorRules = ['password' => 'confirmed|min:6']; } else { // user try another email $validatorRules = ['email' => 'required|email|max:255|unique:users', 'password' => 'confirmed|min:6']; } $this->validate($request, $validatorRules); $data = $request->all(); // password crypt if (isset($data['password'])) { if (empty($data['password'])) { unset($data['password']); } else { $data['password'] = bcrypt($data['password']); } } $user = User::findOrFail($id); $user->update($data); Flash::success('Benutzerdaten sind aktualisiert.'); return redirect()->action('Auth\\EditController@getEdit'); }
public function panel() { $user = Auth::getUser(); $rooms = $user->rooms()->wherePivot('owner', '=', 1)->get(); $rooms_foreign = $user->rooms()->wherePivot('owner', '=', 0)->get(); return view('panel', compact('rooms', 'rooms_foreign')); }
public function getCurrentUserId() { $user = Auth::getUser(); if (!is_null($user)) { return $user->email; } else { return 'guest'; } }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $group = RoomGroup::with('room')->find($id); $room = $group->room; $user = Auth::getUser(); $isOwner = $room->checkIfUserIsOwner($user->id); $comments = $group->comments()->paginate(5); $comments->setPath(route('room.groups.show', [$room->id, $id])); return view('group', compact('group', 'room', 'user', 'isOwner', 'comments')); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null $guard * @return mixed */ public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->guest()) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { return redirect()->guest('login'); } } else { if (Auth::getUser() and Auth::getUser()->type == 1) { if (substr($request->path(), 0, 5) == 'admin') { return redirect('/'); } else { return $next($request); } } else { return $next($request); } } //return $next($request); }
public function isJudged($comment_id) { return $this->commentjudge->where('comment_id', $comment_id)->where('stu_id', Auth::getUser()->stu_id)->first() !== null; }
public function join(Request $request) { $room = Room::code($request->input('code'))->first(); if (!$room) { return redirect()->route('panel'); } $user = Auth::getUser(); if (!in_array($room->id, $room->users->lists('id')->all())) { $user->rooms()->attach($room->id); } return redirect()->route('rooms.show', $room->id); }
public function getJobs() { $jobs = Job::where("company_id", Auth::getUser()->company_id)->with(["company", "customer"]); return view("jobs", ["jobs" => $jobs]); }
public function postAddForumNewTopicAction() { $user = Auth::getUser(); Page::create(array('title' => Input::get('title'), 'parent_id' => Input::get('parent_page_id'), 'is_sheet' => false, 'is_protected' => false)); /* ForumPageMessage::create(array( 'page_title' => Input::get('title'), 'content' => Input::get('content'), 'page_id' => Input::get('parent_page_id'), 'user' => $user->name, ));*/ return redirect('/admin/contents'); }
public function deleteFavorite($course_id) { return $this->favorite->where('course_id', $course_id)->where('stu_id', Auth::getUser()->stu_id)->delete(); }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return Auth::getUser(); }