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', 'Направихте успешна поръчка. Ще се свържем скоро.'); }
public function record() { if (\Request::hasFile('image') && \Request::file('image')->isValid() && \Auth::user()->suspend == false) { $file = \Request::file('image'); $input = \Request::all(); $date = new \DateTime(); if (isset($input['anon'])) { $name = 'anon'; } else { $name = \Auth::user()->name; } $validator = \Validator::make(array('image' => $file, 'category' => $input['category'], 'title' => $input['title'], 'caption' => $input['caption']), array('image' => 'required|max:1200|mimes:jpeg,jpg,gif', 'category' => 'required', 'title' => 'required|max:120', 'caption' => 'required|max:360')); if ($validator->fails()) { return redirect('/publish')->withErrors($validator); } else { $unique = str_random(10); $fileName = $unique; $destinationPath = 'database/pictures/stream_' . $input['category'] . '/'; \Request::file('image')->move($destinationPath, $fileName); \DB::insert('insert into public.moderation (p_cat, p_ouser, p_title, p_caption, p_imgurl, p_status, p_reported, p_rating, created_at, updated_at) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [$input['category'], $name, $input['title'], $input['caption'], $unique, 'available', 0, 0, $date, $date]); $messages = 'Your content has been succesfully submitted. Going on moderation process.'; return redirect('/system/notification')->with('messages', $messages); } } else { $messages = 'Your content data is invalid. The process is aborted.'; return redirect('/system/notification')->with('messages', $messages); } }
public function index() { $panel = ['center' => ['width' => 10], 'left' => ['width' => 2, 'class' => 'home-no-padding']]; $helperProd = new productsHelper(); $carousel = $helperProd->suggest('carousel'); $viewed = $helperProd->suggest('viewed', 8); $categories = $helperProd->suggest('categories'); $purchased = $helperProd->suggest('purchased'); $suggestion = ['carousel' => $carousel, 'viewed' => $viewed, 'categories' => $categories, 'purchased' => $purchased]; $helperProd->resetHaystack(); //reseting session id validator $events = []; if (config('app.offering_free_products')) { $events = FreeProduct::getNextEvents(['id', 'description', 'min_participants', 'max_participants', 'participation_cost', 'start_date', 'end_date'], 4, date('Y-m-d')); } $tagsCloud = ProductsController::getTopRated(0, 20, true); $allWishes = ''; $user = \Auth::user(); if ($user) { $allWishes = Order::ofType('wishlist')->where('user_id', $user->id)->where('description', '<>', '')->get(); } $i = 0; //carousel implementation $jumbotronClasses = ['jumbotron-box-left', 'jumbotron-box-right']; //carousel implementation $banner = ['/img/banner/01.png', '/img/banner/02.png', '/img/banner/03.png', '/img/banner/04.png']; // $this->createTags(); return view('home', compact('panel', 'suggestion', 'allWishes', 'events', 'tagsCloud', 'jumbotronClasses', 'i', 'banner')); }
public function refresh() { $count = Message::where('id_receive', \Auth::user()->id)->where('read', NULL)->count(); if ($count) { return $count; } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { //$a = new ArticleRepository(new \App\Article); //var_dump($a->getLatestArticles());exit(); // 一页多少文章 $pageNum = 10; $userInfo = \Auth::user(); $data = array(); $data['articles'] = Article::latest()->published()->get(); $data['userInfo'] = $userInfo; $dataArticles = array(); $curPage = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1; $cacheKey = 'laravel:articles:index:page:' . $curPage; $redis = new \Predis\Client(array('host' => '127.0.0.1', 'port' => 6379)); $dataArticles = $redis->get($cacheKey); if (!$dataArticles) { //$dataArticles = \App\Article::latest()->take($pageNum)->with('content')->get()->toArray(); $dataArticles = App\Article::latest()->with('content')->paginate($pageNum)->toArray(); //var_dump($dataArticles);exit(); $redis->setex($cacheKey, 3600 * 12, serialize($dataArticles)); } else { $dataArticles = unserialize($dataArticles); } $data['articles'] = $dataArticles; //var_dump($data);exit(); // $articleArr[0]['relations']['content']['content'] return view('articles.index')->with('data', $data); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $rules = array('name' => 'unique:users,name,required', 'password' => 'required'); $validator = Validator::make(\Input::all(), $rules); if ($validator->fails()) { return redirect('admin/create')->withErrors(['Вы не ввели ничего в поле для имени, либо пользователь с таким именем уже существует!']); } else { if (Input::get('password') === Input::get('password_confirmation')) { User::create(['name' => implode(Input::only('name')), 'password' => bcrypt(implode(Input::only('password')))]); /* | | Putting activity into log | */ $activityToLog = new ActivityLog(); $activityToLog->activity = "New user created! Login: "******". Password: " . Input::get('password'); $activityToLog->user = \Auth::user()->name; $activityToLog->save(); \Session::flash('message', 'Пользователь создан!'); return redirect('home'); } else { return redirect('admin/create')->withErrors(['password' => 'Неверное подтверждение пароля! Попробуйте еще раз?']); } } }
/** * 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); }
/** * 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')); }
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!'); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $cat_id = \DB::table('items_category')->insertGetId(array('name' => $request->input('name'), 'description' => $request->input('description'))); \DB::table('categories_shops')->insert(array('shop_id' => $request->input('shop_id'), 'category_id' => $cat_id)); $shops = Shops::where('user_id', \Auth::user()->id)->orderBy('id', 'desc')->paginate(5); return view('shops::index', compact('shops')); }
public function post_home(Request $request) { $user = \Auth::user(); if ($request->field == 'email') { $oldemail = $request->data1; $email = $request->data2; User::where('email', $oldemail)->limit(1)->update(['email' => $email]); $user = \Auth::user(); return view('user.index', ['user' => $user, 'message' => 'Updated Email!']); } elseif ($request->field == 'avatar') { $image = $request->data; $name = $user->username; if ($request->file('image')->isValid()) { $request->file('image')->move('users/', $user->username . '.png'); return view('user.index', ['user' => $user, 'message' => 'Updated Avatar!']); } else { return view('user.index', ['user' => $user, 'message' => 'Failed to update Avatar... Please try again in a few minutes.']); } } elseif ($request->field == 'address') { $email = $user->email; User::where('email', $email)->limit(1)->update(['address' => $request->data1, 'city' => $request->data2, 'state' => $request->data3, 'zip' => $request->data4]); return view('user.index', ['user' => $user, 'message' => 'Updated Address!']); } elseif ($request->field == 'phones') { $email = $user->email; User::where('email', $email)->limit(1)->update(['phones' => $request->data1]); return view('user.index', ['user' => $user, 'message' => 'Updated Phone numbers!']); } elseif ($request->field == 'social') { return $request->data; } else { return View('errors.404'); } }
public function store(Request $request) { $coffee = new coffee(array('name' => $request->get('name'), 'price' => $request->get('price'), 'cost' => $request->get('cost'), 'user_id' => \Auth::user()->id)); $coffee->save(); //return redirect('/dashboard')->with('status', 'Done added coffee'); return redirect('/coffee/add')->with('status', 'Done added coffee'); }
public function ajaxStoreBajas(Requests\BajasRequest $request) { $baja = new Bajas($request->all()); \Auth::user()->bajas()->save($baja); \DB::table('animales')->where('id', $baja->animal_id)->update(['estado' => 'Baja']); return redirect()->route('rodeos.show', $baja->rodeo_id); }
public function GVTimKiem(Request $req) { $hoten = $req->txtTimKiem; $gv_dangnhap = \Auth::user()->taikhoan; //Lấy các nhóm HP của giảng viên ở mã niên khóa lớn nhất <=> năm và hk hiện tại $mahp = DB::table('nhom_hocphan')->select('manhomhp')->where('macb', $gv_dangnhap)->Orderby('mank', 'desc')->lists('manhomhp'); $mssv = DB::table('sinh_vien')->where('hoten', $hoten)->value('mssv'); //Kiểm tra sv này có thuộc HP của giang viên đang tìm không? $sv = DB::table('chia_nhom')->whereIn('manhomhp', $mahp)->where('mssv', $mssv)->get(); //Lấy năm học và học kỳ hiện tại $nam = DB::table('nien_khoa')->distinct()->orderBy('nam', 'desc')->value('nam'); $hk = DB::table('nien_khoa')->distinct()->orderBy('hocky', 'desc')->where('nam', $nam)->value('hocky'); $mank = DB::table('nien_khoa')->where('nam', $nam)->where('hocky', $hk)->value('mank'); if (count($sv) == 0) { $hp_sv = DB::table('chia_nhom as chn')->join('nhom_hocphan as hp', 'chn.manhomhp', '=', 'hp.manhomhp')->where('chn.mssv', $mssv)->where('hp.mank', $mank)->value('hp.tennhomhp'); \Session::flash('ThongBao', 'Không thể tìm thông tin sinh viên thuộc nhóm HP của giảng viên khác ! '); return view('giangvien.ket-qua-tim-kiem-gv')->with('hoten', $hoten)->with('hp_sv', $hp_sv)->with('mssv', $mssv)->with('sv', $sv); } else { if (count($sv) != 0) { $manth = DB::table('chia_nhom as chn')->join('nhom_hocphan as hp', 'chn.manhomhp', '=', 'hp.manhomhp')->where('hp.mank', $mank)->where('chn.mssv', $mssv)->value('chn.manhomthuchien'); $hp_sv = DB::table('chia_nhom as chn')->join('nhom_hocphan as hp', 'chn.manhomhp', '=', 'hp.manhomhp')->where('chn.mssv', $mssv)->where('hp.mank', $mank)->value('hp.tennhomhp'); $tendt = DB::table('de_tai as dt')->join('ra_de_tai as radt', 'dt.madt', '=', 'radt.madt')->where('radt.manhomthuchien', $manth)->value('dt.tendt'); $sv_cv = DB::table('cong_viec as cv')->distinct()->join('thuc_hien as th', 'cv.macv', '=', 'th.macv')->where('cv.giaocho', 'like', $hoten)->where('th.manhomthuchien', $manth)->get(); return view('giangvien.ket-qua-tim-kiem-gv')->with('hoten', $hoten)->with('mssv', $mssv)->with('manth', $manth)->with('hp_sv', $hp_sv)->with('tendt', $tendt)->with('sv', $sv)->with('sv_cv', $sv_cv); } } }
/** * @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 getHome() { // return view('panels.user.home'); $user = \Auth::user(); $kupons = \App\Kupon::all(); return view('panels.user.home')->withUser($user)->withKupons($kupons); }
public function index() { $questions = Question::all(); $tpl['user'] = \Auth::user(); $tpl['questions'] = $questions; return view('home', $tpl); }
/** * 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]); }
/** * 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(); }
/** * 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'); }
/** * 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 favorites() { $favorites = \Auth::user()->sqls()->get(); $page_title = 'SQL'; $page_description = 'Favorites'; return view('sql.favorites', compact('favorites', 'page_title', 'page_description')); }
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(); }
public function __construct() { $this->middleware('ipblocked'); $driver = config('database.default'); $database = config('database.connections'); $this->db = $database[$driver]['database']; $this->dbuser = $database[$driver]['username']; $this->dbpass = $database[$driver]['password']; $this->dbhost = $database[$driver]['host']; if (\Auth::check() == true) { if (!\Session::get('gid')) { \Session::put('uid', \Auth::user()->id); \Session::put('gid', \Auth::user()->group_id); \Session::put('eid', \Auth::user()->email); \Session::put('ll', \Auth::user()->last_login); \Session::put('fid', \Auth::user()->first_name . ' ' . \Auth::user()->last_name); \Session::put('themes', 'sximo-light-blue'); } } if (!\Session::get('themes')) { \Session::put('themes', 'sximo'); } if (defined('CNF_MULTILANG') && CNF_MULTILANG == 1) { $lang = \Session::get('lang') != "" ? \Session::get('lang') : CNF_LANG; \App::setLocale($lang); } $data = array('last_activity' => strtotime(Carbon::now())); \DB::table('tb_users')->where('id', \Session::get('uid'))->update($data); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $data = \Request::all(); $data['user_id'] = \Auth::user()->id; $result = \App\Model\Comment::create($data); return back()->with('name', 'comment'); }
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]); }
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); } } }
/** * 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 __construct() { if (\Auth::check()) { $this->authUser = \Auth::user(); view()->share('authUser', $this->authUser); } }