/** * Responds to requests to GET / */ public function getIndex() { if (\Auth::check()) { return redirect()->to('/books'); } return view('welcome.index'); }
public function postStore(UsersRequest $request = null, $id = "") { $input = $request->except('save_continue', 'password_confirmation'); $result = ''; if (\Input::hasFile('photo')) { $photo = (new \ImageUpload($input))->upload(); } if ($id == "") { $input['photo'] = isset($photo) ? $photo : ""; $input['active'] = $input['active']; $input['group_id'] = $input['group_id']; $input['created_by'] = \Auth::user()->username; $input['password'] = bcrypt($input['password']); $query = $this->model->create($input); $result = $query->id; } else { $input['active'] = $input['active']; $input['group_id'] = $input['group_id']; if (\Input::hasFile('photo')) { $input['photo'] = isset($photo) ? $photo : ""; } if (isset($input['password']) && $input['password'] != "") { $input['password'] = bcrypt($input['password']); } $this->model->find($id)->update($input); $result = $id; } $save_continue = \Input::get('save_continue'); $redirect = empty($save_continue) ? $this->url : $this->url . '/edit/' . $result; return redirect($redirect)->with('message', 'Admin saved successfully!'); }
public function index() { $questions = Question::all(); $tpl['user'] = \Auth::user(); $tpl['questions'] = $questions; return view('home', $tpl); }
public function create() { if (Auth::check()) { return Redirect::to("/admin"); } return View::make("sessions.create"); }
/** * Responds to requests to GET /books */ public function getIndex(Request $request) { // Get all the books "owned" by the current logged in users // Sort in descending order by id $books = \App\Book::where('user_id', '=', \Auth::id())->orderBy('id', 'DESC')->get(); return view('books.index')->with('books', $books); }
public function __construct() { $objUser = \Auth::User() ?: \App\User::GetGuestAccount(); View::share('CareerCount', \App\Career::where('status', \App\Career::STATUS_ENABLED)->count()); View::share('PageTitle', 'Welcome'); View::share('objUser', $objUser); }
public function getCreate(Request $request) { $accounts = \App\Account::where('user_id', '=', \Auth::id())->find($request->id); $transactions = new \App\Transaction(); $categories = ['Deposit/Credit', 'Automobile', 'Groceries', 'Health & Beauty', 'Home Improvement', 'Meals & Entertainment', 'Medical Expense', 'Utilities', 'Insurance', 'Miscellaneous']; return view('transaction.create')->with('transactions', $transactions)->with(['categories' => $categories])->with('accounts', $accounts); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Requests\PostsFormRequest $request) { $input = $request->all(); $input['alias'] = HelperFunctions::str2url($request->title); $input['user_id'] = \Auth::user()->id; $post = Posts::create($input); $categories_ids = []; foreach ($input['categories_list'] as $value) { $category = Categories::findOrNew($value); if ($category->exists) { array_push($categories_ids, $value); } else { $category->name = $value; $category->save(); array_push($categories_ids, $category->id); } } $post->categories()->attach($categories_ids); $tags_ids = []; foreach ($input['tags_list'] as $value) { $tag = Tags::findOrNew($value); if ($tag->exists) { array_push($tags_ids, $value); } else { $tag->name = $value; $tag->save(); array_push($tags_ids, $tag->id); } } $post->tags()->attach($tags_ids); \Session::flash('success', 'Post created'); return redirect('/'); }
public function inbox() { $name = \Auth::user()->name; $results = \DB::select('select * from notification.inbox_' . $name . ' order by created_at desc limit 70 offset 0'); \DB::update('update notification.inbox_' . $name . ' set n_read = true'); return view('profile.inbox')->with('results', $results); }
public function refresh() { $count = Message::where('id_receive', \Auth::user()->id)->where('read', NULL)->count(); if ($count) { return $count; } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $pro_exc = PromotionExceptional::where('user_id', \Auth::user()->id)->first(); if ($pro_exc) { $pro_exc->start = Carbon::parse($request->start); $pro_exc->end = Carbon::parse($request->end); $pro_exc->user_id = \Auth::user()->id; $pro_exc->price = $request->prix_exc; $pro_exc->active = 1; $pro_exc->save(); } else { $pro_exc = new PromotionExceptional(); $pro_exc->start = Carbon::parse($request->start); $pro_exc->end = Carbon::parse($request->end); $pro_exc->price = $request->prix_exc; $pro_exc->user_id = \Auth::user()->id; $pro_exc->active = 1; $pro_exc->save(); } // make promotion in advance not current $pro_adv = PromotionAdvance::where('user_id', \Auth::user()->id)->get(); if (!$pro_adv->isEmpty()) { foreach ($pro_adv as $item) { $pv = PromotionAdvance::where('user_id', \Auth::user()->id)->where('id', $item->id)->first(); $pv->active = 0; $pv->save(); } } return redirect()->back()->with('success', 'Bien Enregistrée'); }
/** * Show the application welcome screen to the user. * * @return Response */ public function index() { if (\Auth::guest()) { return redirect()->action('HomeController@index'); } return redirect('auth/login'); }
/** * Show the application dashboard. * * @return Response */ public function index() { $user = \Auth::user(); $friends = $user->friends()->get(); $comments = $user->comments()->get(); return view('users.show')->with(["user" => $user, "friends" => $friends, 'comments' => $comments]); }
public function logout() { Auth::logout(); // logout user return Redirect::to('admin/login'); //redirect back to login }
public function handleFacebookCallback() { //Since its the same callback function for registration & login. Check prev url and handle appropriately $prevUrl = session()->previousUrl(); $facebookUser = Socialize::with('facebook')->user(); $appUser = User::whereEmail($facebookUser->getEmail())->get(); if (strpos($prevUrl, "register")) { //If user is not already registered, register and login if ($appUser->count() == 0) { $user = User::create(['name' => $facebookUser->getName(), 'email' => $facebookUser->getEmail(), 'password' => str_random(8)]); $user->verified = true; $user->token = null; $user->save(); session()->flash('message', 'You are now registered. Please update your account details.'); \Auth::loginUsingId($user->id); return redirect('/myAccount'); } else { return redirect()->back()->withErrors('User already exists'); } } else { if ($appUser->count() == 0) { return redirect()->back()->withErrors('User not found'); } $user = $appUser[0]; } \Auth::loginUsingId($user->id); return redirect()->intended('/dashboard'); }
/** * edit the specified resource in storage. * * @param int $id * @return Response */ public function editQuestion($id) { $question = \App\Question::find($id); $fiche_id = Session::get('fiche_id'); $user = \Auth::user(); return view('back.editQuestion', compact('question', 'fiche_id', 'user')); }
protected function config() { $user = \Auth::user(); $this->responseData['data'] = ['class_note' => $user->class_note, 'go_class_note' => $user->go_class_note, 'test_note' => $user->test_note]; $this->responseCode = 200; return $this->send_response(); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $campaign = \Session::get('campaign'); $campaign->fillRelations(); foreach ($campaign->getRelations() as $relation) { foreach ($relation as $title => $components) { //Split it out into human readable terms $pieces = explode('\\', $title); $title_component = $pieces[count($pieces) - 1]; $data['objects'][$title_component] = $components; } } $data['campaigns'] = CampaignMembership::where('user_id', \Auth::user()->id)->get(); foreach ($data['campaigns'] as $campaign) { $campaign->details; } $data['object_count'] = count($data['objects']); $data['columns'] = 5; $data['logs'] = QuestLog::where('campaign_id', \Session::get('campaign')->id)->orderBy('id', 'desc')->get(); //Let's remove restricted content for non dms foreach ($data['logs'] as $key => $value) { foreach ($value as $component) { if ($value->restricted == 1 && \Session::get('dm') == 0) { unset($data['logs'][$key]); } } } return view('dashboards.index')->with($data); }
/** * @param $id * @return mixed */ public function update() { $input = \Request::all(); $orgs = Org::findOrFail(\Auth::user()->org_id); $orgs->update($input); return \Response::json(['success' => true, 'message' => 'Org Updated.', 'data' => $orgs]); }
public function favorites() { $favorites = \Auth::user()->sqls()->get(); $page_title = 'SQL'; $page_description = 'Favorites'; return view('sql.favorites', compact('favorites', 'page_title', 'page_description')); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(CreateEventRequest $req) { $input = $req->all(); // Makes sure chair_id enters database as an integer or null if left empty. strcmp($input['chair_id'], "") == 0 ? $input['chair_id'] = null : ($input['chair_id'] = (int) $input['chair_id']); // Ensures database times are always in UTC. foreach ($input as $key => $value) { // Ensures only time fields are changed. if (!strpos($key, 'time')) { continue; } // Converts time from PST to UTC. $pst = new Carbon($value, 'America/Los_Angeles'); $utc = $pst->setTimezone('UTC'); // Sets date/time string back into values for database. $input[$key] = $utc->toDateTimeString(); } $input['creator_id'] = \Auth::id(); // Set creator ID by default // Set default close time if needed if (!isset($input['close_time'])) { $input['close_time'] = $input['start_time']; } // Set default open time if needed if (!isset($input['open_time'])) { $input['open_time'] = Carbon::now(); } // Create event $event = Event::create($input); return redirect()->action('EventsController@show', $event->slug); }
public function makeOrder(Request $request) { $validator = $this->validator($request->all()); if (!isset(\Auth::user()->name)) { if ($validator->fails()) { return redirect('order/save')->withErrors($validator)->withInput(); } } $input = $request->all(); $cartCollection = Cart::getContent(); $products = $cartCollection->toArray(); $productId = array_keys($products); if (isset(\Auth::user()->name)) { $authUser = \Auth::user(); $orderSave = Order::create(['telephone' => $authUser->telephone, 'user_name' => $authUser->name, 'email' => $authUser->email, 'adress' => $authUser->adress, 'town' => $authUser->town, 'comment' => $input['comment']]); } else { $orderSave = Order::create(['telephone' => $input['telephone'], 'user_name' => $input['name'], 'email' => $input['email'], 'adress' => $input['adress'], 'town' => $input['town'], 'comment' => $input['comment']]); } $order = Order::find($orderSave->id); $order->product()->attach($productId); foreach ($productId as $rm) { Cart::remove($rm); } return redirect(LaravelLocalization::setLocale() . "/")->with('msg', 'Направихте успешна поръчка. Ще се свържем скоро.'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(CreateLikeRequest $request) { $input = $request->all(); $like = new Like($input); Auth::user()->likes()->save($like); return redirect()->back(); }
public function proposeSolution() { $questionId = Request::get('questionId'); $question = Question::find($questionId); $answers = $question->answers()->get()->toArray(); // Prepare array of proposed answers $proposedSolution = []; if ($question->question_type == 'one_variant') { $proposedSolution[] = (int) Request::get('chosenAnswer'); } else { $proposedSolution = Request::get('chosenAnswers'); } // Prepare array of correct answers $correctSolution = []; foreach ($answers as $answer) { if ($answer['is_correct']) { $correctSolution[] = $answer['id']; } } $proposedSolutionResult = $proposedSolution == $correctSolution; // pass to response detailed results on proposed solution $proposedSolutionWithDetailedResult = []; foreach ($proposedSolution as $answerId) { foreach ($answers as $answer) { if ($answer['id'] == $answerId) { $is_correct = $answer['is_correct']; } } $proposedSolutionWithDetailedResult[$answerId] = $is_correct; } if (\Auth::user()) { \Auth::user()->replies()->updateOrCreate(['question_id' => $questionId], ['is_correct' => $proposedSolutionResult]); } return response()->json(['correctSolution' => $correctSolution, 'proposedSolutionWithDetailedResult' => $proposedSolutionWithDetailedResult, 'proposedSolutionResult' => $proposedSolutionResult]); }
/** * 动作:登录 * * @param Request $request * @return \Illuminate\Http\RedirectResponse */ public function postLogin(Request $request) { if (Auth::attempt(['username' => $request->input('username'), 'password' => $request->input('password')])) { return redirect()->back(); } return redirect()->intended('auth/login'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $user = \Auth::user(); $v = \Validator::make($request->all(), $this->form_rules); if ($v->fails()) { return \Response::json(['success' => false, 'message' => trans('address.error_validation'), 'class' => 'alert alert-danger']); } $this->resetDefault(); $address = new Address(); $address->name_contact = $request->get('name_contact'); $address->line1 = $request->get('line1'); $address->line2 = $request->get('line2'); $address->city = $request->get('city'); $address->state = $request->get('state'); $address->zipcode = $request->get('zipcode'); $address->country = $request->get('country'); $address->phone = $request->get('phone'); $address->user_id = $user->id; $address->default = '1'; $address->save(); if ($address) { \Session::put('message', trans('address.success_save')); \Session::save(); return \Response::json(['success' => true, 'callback' => '/user/address']); } else { return \Response::json(['success' => false, 'message' => trans('address.error_updating'), 'class' => 'alert alert-danger']); } }
public function doLogout() { Auth::logout(); // log the user out of our application return Redirect::to('login'); // redirect the user to the login screen }
public function show($name) { if (\Auth::check() && \Auth::user()->permission->name == 'admin') { if (is_numeric($name)) { $dl = Downloads::where('id', '=', $name)->where('trash', '=', '0')->first(); if (is_null($dl)) { return \Redirect::to('404'); } return \View::make('downloads.show')->with('entry', $dl); } else { $dl = Downloads::where('name', '=', $name)->where('trash', '=', '0')->first(); if (is_null($dl)) { return \Redirect::to('404'); } return \View::make('downloads.show')->with('entry', $dl); } } else { if (is_numeric($name)) { $dl = Downloads::where('id', '=', $name)->where('trash', '=', '0')->where('state', '=', '1')->first(); if (is_null($dl)) { return \Redirect::to('404'); } return \View::make('downloads.show')->with('entry', $dl); } else { $dl = Downloads::where('name', '=', $name)->where('trash', '=', '0')->where('state', '=', '1')->first(); if (is_null($dl)) { return \Redirect::to('404'); } return \View::make('downloads.show')->with('entry', $dl); } } }
public function open() { if (!\Auth::check()) { return view('start'); } return \Redirect::action('HomeController@dashboard'); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function getIndex() { if (\Auth::check()) { return redirect('/store'); } return view('welcome.index'); }