public function slots()
 {
     $user = Auth::user();
     $location = $user->location;
     $slot = Slot::where('location', '=', $location)->first();
     $input = Input::get('wager');
     $owner = User::where('name', '=', $slot->owner)->first();
     $num1 = rand(1, 10);
     $num2 = rand(5, 7);
     $num3 = rand(5, 7);
     if ($user->name != $owner->name) {
         if ($num1 & $num2 & $num3 == 6) {
             $money = rand(250, 300);
             $payment = $money += $input * 1.75;
             $user->money += $payment;
             $user->save();
             session()->flash('flash_message', 'You rolled three sixes!!');
             return redirect('/home');
         } else {
             $user->money -= $input;
             $user->save();
             $owner->money += $input;
             $owner->save();
             session()->flash('flash_message_important', 'You failed to roll three sixes!!');
             return redirect(action('SlotsController@show', [$slot->location]));
         }
     } else {
         session()->flash('flash_message_important', 'You own this slot!!');
         return redirect(action('SlotsController@show', [$slot->location]));
     }
 }
 public function duzenleForm($id)
 {
     $data = Input::all();
     $kural = array('baslik' => 'required|min:3', 'resim' => 'max:1536|required|mimes:jpeg,jpg,bmp,png,gif');
     $dogrulama = \Validator::Make($data, $kural);
     if (!$dogrulama->passes()) {
         return \Redirect::to('admin/galeriler/duzenle/' . $id)->withErrors($dogrulama)->withInput();
     } else {
         if (Input::hasFile('resim')) {
             $dosya = Input::file('resim');
             $uzanti = $dosya->getClientOriginalExtension();
             if (strlen($uzanti) == 3) {
                 $dosyaAdi = substr($dosya->getClientOriginalName(), 0, -4);
             } else {
                 if (strlen($uzanti) == 4) {
                     $dosyaAdi = substr($dosya->getClientOriginalName(), 0, -5);
                 }
             }
             $dosyaAdi = $dosyaAdi . "_" . date('YmdHis') . '.' . $uzanti;
             $path = base_path('galeriResimler/600x450/' . $dosyaAdi);
             Image::make($dosya->getRealPath())->resize(600, 450)->save($path);
             $path = base_path('galeriResimler/defaultSize/' . $dosyaAdi);
             Image::make($dosya->getRealPath())->save($path);
             $path = $dosyaAdi;
             $query = DB::insert('insert into gal_resim values (null,?,?,?)', array($id, $data["baslik"], $path));
             return Redirect::back();
         }
     }
 }
Example #3
0
 public function update()
 {
     $profile = Profile::where('user_id', Auth::user()->id)->first();
     $profile->fill(Input::all());
     $profile->save();
     return Redirect::to("/edit_profile");
 }
 public function facebookLogin(Request $request)
 {
     $fb = new Facebook();
     // если код не предоставлен
     if (Input::get('code') === null) {
         return Redirect::to('http://what-it-means.ru/#/site/auth/facebook/error/rejected-by-user');
     }
     // если код предоставлен, но он не верен (кто то вмешался по середине)
     $authResult = $fb->auth(Input::get('code'));
     if (!$authResult) {
         return Redirect::to('http://what-it-means.ru/#/site/auth/facebook/error/auth-error');
     }
     // если все в порядке, выполним нужные нам действия (авторизация, регистрация)
     $fbUserData = $fb->api('/me');
     // нужно ли зарегистрировать пользователя или авторизовать?
     if (isset($fbUserData->email)) {
         $user = User::findByEmail($fbUserData->email);
         if (!$user) {
             $user = User::create(array('name' => $fbUserData->name, 'email' => $fbUserData->email, 'password' => md5(Func::hash(8))));
         }
         Auth::login($user, true);
         return Redirect::to('http://what-it-means.ru/#/site/auth/facebook/success/');
     }
     //echo var_dump($fbUserData);
     // нужно ли только авторизовать пользователя даже если емейл не предоставлен?
     $userSocGlueData = UserSocGlue::where(['provider' => 'facebook', 'provider_user_id' => $fbUserData->id])->first();
     if ($userSocGlueData) {
         Auth::login(User::find($userSocGlueData->user_id), true);
         return Redirect::to('http://what-it-means.ru/#/site/auth/facebook/success/');
     }
     // если не хватает данных о юзере и он не зарегистрирован
     if (!isset($fbUserData->email)) {
         return Redirect::to('http://what-it-means.ru/#/site/auth/facebook/error/no-email');
     }
 }
 /**
  * 验证方法
  * @throws \HttpRequestException
  */
 public function validate()
 {
     foreach ($this->getKform()->getFormFields() as $formField) {
         if ($formField instanceof FormField) {
             $formField->setValue(Input::get($formField->getFieldName()), $this);
         }
     }
     if (!$this->getKform()->isPassed()) {
         $errors = $this->getKform()->getErrors();
         if ($this->ajax() || $this->wantsJson()) {
             $response = new APIJsonResponse();
             $error = new FailedValidtionError();
             $error->setErrorContext($errors);
             $response->pushError($error);
             throw new HttpResponseException($response->getResponse());
         } else {
             $messenger = new KMessenger();
             foreach ($this->getKform()->getFormFields() as $formField) {
                 foreach ($formField->getErrors() as $error) {
                     $messenger->push($error, KMessenger::ERROR);
                 }
             }
             $view = $this->directlyErrorView();
             if ($view instanceof View) {
                 $response = \Response::make($view);
             } else {
                 $response = $this->redirectBackResponse();
             }
             throw new HttpResponseException($response);
         }
     }
 }
 public function store(PostRequest $request)
 {
     if (Input::has('link')) {
         $input['link'] = Input::get('link');
         $info = Embed::create($input['link']);
         if ($info->image == null) {
             $embed_data = ['text' => $info->description];
         } else {
             if ($info->description == null) {
                 $embed_data = ['text' => ''];
             } else {
                 $orig = pathinfo($info->image, PATHINFO_EXTENSION);
                 $qmark = str_contains($orig, '?');
                 if ($qmark == false) {
                     $extension = $orig;
                 } else {
                     $extension = substr($orig, 0, strpos($orig, '?'));
                 }
                 $newName = public_path() . '/images/' . str_random(8) . ".{$extension}";
                 if (File::exists($newName)) {
                     $imageToken = substr(sha1(mt_rand()), 0, 5);
                     $newName = public_path() . '/images/' . str_random(8) . '-' . $imageToken . ".{$extension}";
                 }
                 $image = Image::make($info->image)->fit(70, 70)->save($newName);
                 $embed_data = ['text' => $info->description, 'image' => basename($newName)];
             }
         }
         Auth::user()->posts()->create(array_merge($request->all(), $embed_data));
         return redirect('/subreddit');
     }
     Auth::user()->posts()->create($request->all());
     return redirect('/subreddit');
 }
Example #7
0
 public function search(Request $request)
 {
     $this->validate($request, ['str' => 'required']);
     $keyword = Input::get('str');
     $songs = Song::where('song_name', 'like', "%{$keyword}%")->orderBy('song_id', 'desc')->limit(15)->get();
     return $songs;
 }
Example #8
0
 public function upload()
 {
     $userName = Auth::user()->id;
     if (Input::hasFile('rnaVcfFile')) {
         $fileRNA = Input::file('rnaVcfFile');
         if ($fileRNA->isValid()) {
             /*$clientName = $file->getClientOriginalName();
               $tmpName = $file->getFileName();
               $realPath = $file->getRealPath();
               $entension = $file->getClientOriginalExtension();
               $mimeType = $file->getMimeType();*/
             $newName = $userName . '_rna.vcf';
             /*$path = */
             $fileRNA->move('../storage/vcf_file', $newName);
             redirect('/');
         }
     } elseif (Input::hasFile('dnaVcfFile')) {
         $fileDNA = Input::file('dnaVcfFile');
         if ($fileDNA->isValid()) {
             $newName = $userName . '_dna.vcf';
             /*$path = */
             $fileDNA->move('../storage/vcf_file', $newName);
             redirect('/');
         }
     }
 }
Example #9
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $a = new \App\Popups();
     $a->judul = Input::get('judul');
     $a->slug = str_slug(Input::get('judul'));
     $a->deskripsi = Input::get('keterangan');
     $a->tipe_valid = Input::get('type_valid');
     if ($a->tipe_valid == "by_datetime" or $a->tipe_valid == "by_date") {
         $a->date_valid_start = date_format(date_create(Input::get('date_valid_start')), "Y-m-d");
         $a->date_valid_end = date_format(date_create(Input::get('date_valid_end')), "Y-m-d");
     }
     if ($a->tipe_valid == "by_datetime" or $a->tipe_valid == "by_time") {
         $a->time_valid_start = date_format(date_create(Input::get('time_valid_start')), "H:i:s");
         $a->time_valid_end = date_format(date_create(Input::get('time_valid_end')), "H:i:s");
     }
     if (Input::hasFile('image') and Input::file('image')->isValid()) {
         $image = date("YmdHis") . uniqid() . "." . Input::file('image')->getClientOriginalExtension();
         Input::file('image')->move(storage_path() . '/popup_image', $image);
         $a->image = $image;
     }
     $a->keep_open = Input::get('keep_open');
     $a->hotlink = Input::get('hotlink');
     $a->idpengguna = Auth::user()->id;
     $a->save();
     return redirect(url('admin/popups'));
 }
Example #10
0
 public function postRegister(Request $request)
 {
     $validator = $this->registrar->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $this->auth->login($this->registrar->create($request->all()));
     $id = DB::getPdo()->lastInsertId();
     $user = \Auth::user();
     if (Input::get('state') === 'company') {
         $user->isCompany = 1;
         $user->save();
         return Redirect('company/project');
     } else {
         if (Input::get('state') === 'student') {
             $user->isStudent = True;
             $user->save();
             return Redirect('profile');
         } else {
             if (Input::get('state') === 'expertise') {
                 $user->isExpertise = True;
                 $user->save();
                 return Redirect('profile');
             }
         }
     }
 }
 public function generate()
 {
     $input = Input::get('number');
     $birthday = Input::get('bd');
     $location = Input::get('l');
     if (!ctype_digit($input)) {
         return Redirect::back()->with('message', 'You did not enter a number!');
     }
     $input = intval($input);
     if ($input < 0 || $input > 99) {
         return Redirect::back()->with('message', 'You have to enter number between 1 to 99!');
     }
     $faker = \Faker\Factory::create();
     $users = array();
     for ($i = 0; $i < $input; $i++) {
         if (is_null($birthday) && is_null($location)) {
             $users[$i] = "<p>" . $faker->userName . "</p>";
         } elseif (isset($birthday) && !isset($location)) {
             $users[$i] = "<p>" . $faker->userName . "</br>" . $faker->dateTimeThisCentury->format('Y-m-d') . "</p>";
         } elseif (!isset($birthday) && isset($location)) {
             $users[$i] = $faker->userName . "</br>" . $faker->city;
         } else {
             $users[$i] = "<p>" . $faker->userName . "</br>" . $faker->dateTimeThisCentury->format('Y-m-d') . "</br>" . $faker->city . "</p>";
         }
     }
     $generated = implode('<br>', $users);
     return view('randomuser')->with('generated', $generated);
 }
Example #12
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store()
 {
     $advBuss = new AdvertiserBusiness();
     $data = Input::all();
     $validator = $this->checkValidation();
     if ($validator->fails()) {
         $messages = $validator->messages();
         foreach ($messages->all() as $message) {
             $msg[] = $message;
         }
         return $this->errorMessage($msg);
     }
     $img_hash1 = $advBuss->imageUpload($data['img_hash1'], $this->uploaddir);
     if (isset($img_hash1) and !empty($img_hash1)) {
         $data['img_hash1'] = $img_hash1;
     }
     $img_hash2 = $advBuss->imageUpload($data['img_hash2'], $this->uploaddir);
     if (isset($img_hash2) and !empty($img_hash2)) {
         $data['img_hash2'] = $img_hash2;
     }
     $img_hash3 = $advBuss->imageUpload($data['img_hash3'], $this->uploaddir);
     if (isset($img_hash3) and !empty($img_hash3)) {
         $data['img_hash3'] = $img_hash3;
     }
     $userDetail = $advBuss->getDetailByUserId($data['user_id']);
     if (empty($userDetail)) {
         $advertiserProfile = $advBuss->insert($data);
         $msg[] = "Profile saved successfully.";
         return $this->successMessageWithVar($msg, $advertiserProfile);
     } else {
         $advertiserProfile = $advBuss->updateData($data);
         $msg[] = "Profile updated successfully.";
         return $this->successMessageWithVar($msg, $advertiserProfile);
     }
 }
 /**
  * Execute the command
  *
  * @param  string $command
  * @param  array|null $input
  * @param  string|array $decorators
  * @return mixed
  */
 public function execute($command, $input = null, $decorators = [])
 {
     $input = $input ?: Input::all();
     $command = $this->mapInputToCommand($command, (array) $input);
     $bus = $this->getCommandBus();
     return $bus->before($decorators)->execute($command);
 }
Example #14
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function ListaPagos()
 {
     $alumno_mensualidad = Input::get('alumno_mensualidad');
     $apellido_mensualidad = Input::get('apellido_mensualidad');
     $data = PagoMensualidad::with('mensualidad');
     if ($alumno_mensualidad != '') {
         $data = $data->join('mensualidad as m', 'pago_mensualidad.mensualidad_id', '=', 'm.id')->join('users as u', 'm.user_id', '=', 'u.id')->where('u.name', $alumno_mensualidad);
     }
     if ($apellido_mensualidad != '') {
         $data = $data->join('mensualidad as m', 'pago_mensualidad.mensualidad_id', '=', 'm.id')->join('users as u', 'm.user_id', '=', 'u.id')->where('u.last_name', $apellido_mensualidad);
     }
     $filter = DataFilter::source($data);
     $filter->attributes(array('class' => 'form-inline'));
     $filter->add('fecha_pago', 'Fecha Pago', 'daterange')->format('d/m/Y', 'es');
     $filter->submit('Buscar');
     $filter->reset('Limpiar');
     $filter->build();
     $grid = DataGrid::source($filter);
     $grid->attributes(array("class" => "table table-striped"));
     $grid->add('mensualidad.alumno.fullname', 'Nombre');
     $grid->add('mensualidad.alumno.email', 'Email');
     $grid->add('mensualidad.plan.nombre', 'Plan');
     $grid->add('fecha_pago|strtotime|date[d/m/Y]', 'Fecha', true);
     $grid->add('monto', 'Monto', true);
     $grid->add('tipo_pago', 'Tipo Pago', true);
     $grid->add('observacion', 'Observación', true);
     $grid->add('{!! ("<a class=text-info title=Delete href=/pago_mensualidad/$mensualidad_id/edit?modify=$id><span class=\\"glyphicon glyphicon-edit\\"> </span></a>
     	<a class=text-danger title=Delete href=/pago_mensualidad/$mensualidad_id/edit?delete=$id><span class=\\"glyphicon glyphicon-trash\\"> </span></a>
     	") !!}', 'Borrar');
     $grid->orderBy('pago_mensualidad.id', 'desc');
     $grid->paginate(10);
     return view('pagos/lista', compact('filter', 'grid'));
 }
Example #15
0
 public function delete()
 {
     $id = Input::get('id');
     $this->model = Terrain::find($id);
     $this->model->delete();
     return Response::json(['success' => true]);
 }
Example #16
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $service = service::findOrFail($id);
     $validator = Validator::make($data = Input::all(), service::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     /**
      * Check if Request param contains
      * status, if so activate
      * if not deactivate status
      */
     $status_exists = false;
     foreach ($data as $key => $value) {
         if ($key == 'status') {
             $status_exists = true;
         }
     }
     if ($status_exists) {
         $data['status'] = 1;
     } else {
         $data['status'] = 0;
     }
     $service->update($data);
     return Redirect::route('admin.services.index');
 }
Example #17
0
 public function postReceive()
 {
     $code = Input::get('code');
     if ($code) {
         $coupon = AdminCoupon::where(['coupon_code' => $code])->first();
         if ($coupon) {
             $data = [];
             $data['coupon_id'] = $coupon->id;
             $data['user_id'] = Session::get('uid');
             $data['is_used'] = 0;
             $isCoupon = PhoneUserToCoupon::where($data)->first();
             if ($isCoupon) {
                 flash('亲,您已经领取过这个红包啦~');
                 return redirect()->back();
             }
             $couponToUser = new PhoneUserToCoupon();
             $couponToUser->coupon_id = $coupon->id;
             $couponToUser->user_id = Session::get('uid');
             if ($couponToUser->save()) {
                 $coupon->used += 1;
                 $coupon->save();
                 return redirect("coupon/success/{$coupon->coupon_price}");
             } else {
                 flash('亲~现在服务器压力山大~请稍后再试');
                 return redirect()->back();
             }
         } else {
             flash('亲~兑换码不对呦~请重试');
             return redirect()->back();
         }
     } else {
         flash('亲~兑换码不能为空哦~请重试');
         return redirect()->back();
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::only('first_name', 'last_name', 'email', 'password');
     $command = new CreateNewUserCommand($input['email'], $input['first_name'], $input['last_name'], $input['password']);
     $this->commandBus->execute($command);
     return Redirect::to('/profile');
 }
 /**
  * Returns HTML markup for search results in users search form.
  *
  * @return \Illuminate\View\View
  */
 public function search()
 {
     $input = Input::get('input');
     // Populates search results of users with first and last names similar to user input.
     $user_results = User::where('first_name', 'LIKE', '%' . $input . '%')->orWhere('last_name', 'LIKE', '%' . $input . '%')->get();
     return view('search.users', compact('user_results'));
 }
Example #20
0
 public function updateTask($id)
 {
     $task = Task::find($id);
     $task->update(Input::all());
     Flash::success('Task was updated');
     return redirect()->back();
 }
Example #21
0
 /**
  * Process the second intermediate contact form.
  */
 public function send()
 {
     $input = Input::only(array('name', 'email', 'comment', 'to_email', 'to_name', 'security-code'));
     $input['security-code'] = $this->quickSanitize($input['security-code']);
     if (strlen($input['security-code']) < 2) {
         $message = "Please enter the security code again. Thank you!";
         return view('lasallecmscontact::step_two_form', ['input' => $input, 'message' => $message]);
     }
     // Guess it couldn't hurt to run inputs through the quick sanitize...
     $input['name'] = $this->quickSanitize($input['name']);
     $input['email'] = $this->quickSanitize($input['email']);
     $input['comment'] = $this->quickSanitize($input['comment']);
     // The "to_email" comes from the LaSalleCRMContact package. If it contains an email address,
     // then the contact form was filled out in that package. So, let's figure out the "to" email
     $to_email = Config::get('lasallecmscontact.to_email');
     $to_name = Config::get('lasallecmscontact.to_name');
     if ($input['to_email'] != "") {
         $to_email = $input['to_email'];
         $to_name = $input['to_name'];
     }
     Mail::send('lasallecmscontact::email', $input, function ($message) use($to_email, $to_name) {
         $message->from(Config::get('lasallecmscontact.from_email'), Config::get('lasallecmscontact.from_name'));
         $message->to($to_email, $to_name)->subject(Config::get('lasallecmscontact.subject_email'));
     });
     // Redir to confirmation page
     return Redirect::route('contact-processing.thankyou');
 }
Example #22
0
 /**
  * Handle an authentication attempt.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('email' => 'required|email', 'password' => 'required');
     $validate = Validator::make(Input::all(), $rules);
     if ($validate->fails()) {
         return Redirect::to('/');
     } else {
         if (Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password'), 'status' => 'Activate'))) {
             /*$user = User::where('email','=',$email)->get();
               Session::put('user_type',$user[0]->role);
               $id = $user[0]->id;
               Session::put('created_by',$id);*/
             Session::put('user_id', Auth::user()->id);
             Session::put('user_name', Auth::user()->username);
             Session::put('user_role', Auth::user()->role);
             Session::flash('message', 'User has been Successfully Login.');
             $roles = Auth::user()->role;
             if ($roles = 'admin' || 'manager') {
                 return Redirect::to('dashboard');
             } elseif ($roles = 'user') {
                 return Redirect::to('profile');
             }
         } else {
             Session::flash('message', 'Your username or password incorrect');
             return Redirect::to('/');
         }
     }
 }
 public function postOrder()
 {
     log::debug('postOrder::Input params');
     log::debug(Input::all());
     //Validation rules
     $rules = array('pizza_marinara' => array('required', 'integer', 'between:0,3'), 'pizza_margherita' => array('required', 'integer', 'between:0,3'), 'olio' => array('min:1|max:20'), 'name' => array('required', 'min:1|max:20'), 'email' => array('required', 'email', 'min:1|max:20'), 'freeOrder' => array('exists:menu,dish'));
     // The validator
     $validation = Validator::make(Input::all(), $rules);
     // Check for fails
     if ($validation->fails()) {
         // Validation has failed.
         log::error('Validation has failed');
         $messages = $validation->messages();
         $returnedMsg = "";
         foreach ($messages->all() as $message) {
             $returnedMsg = $returnedMsg . " - " . $message;
         }
         log::error('Validation fail reason: ' . $returnedMsg);
         return redirect()->back()->withErrors($validation);
     }
     log::debug('Validation passed');
     $msg = array('email' => Input::get('email'), 'name' => Input::get('name'));
     $response = Event::fire(new ExampleEvent($msg));
     $response = Event::fire(new OrderCreated($msg));
     return view('orderdone', ['msg' => $msg]);
 }
 public function materiaMaestroEnpalme()
 {
     $maestroId = Materia::join('maestro_materia', 'materias.id', '=', 'maestro_materia.materia_id')->where('materia_id', '=', Input::get('materia_id'))->select('materia', 'materia_id', 'maestro_id')->first();
     $maestroMateria = DB::table('horarios')->join('materias', 'materias.id', '=', 'horarios.materia_id')->join('maestro_materia', 'maestro_materia.materia_id', '=', 'materias.id')->join('maestros', 'maestros.id', '=', 'maestro_materia.maestro_id')->where('hora_id', Input::get('hora_id'))->where('horarios.ciclo_id', Input::get('ciclo_id'))->where('dia_id', Input::get('dia_id'))->where('maestro_id', $maestroId->maestro_id)->get();
     //dd($maestroMateria);
     return $maestroMateria;
 }
Example #25
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user = Auth::user();
     $pusher = new Pusher(Config::get('services.pusher.key'), Config::get('services.pusher.secret'), Config::get('services.pusher.id'));
     $pusher->trigger('my-channel', 'my-event', array('message' => $user->name . ': ' . Input::get('msg'), 'user_id' => $user->id));
     return 'done';
 }
 /**
  * This method is called when a post request is received from the 
  * corresponding page. The method checks which component was triggered and
  * calls the corresponding method
  * @param Request $request
  * @return view
  */
 public function postButton(Request $request)
 {
     if (Input::get('save_comp')) {
         $this->competenceForm($request);
         return view('application_form');
     } elseif (Input::get('save_period')) {
         $this->periodForm($request);
         return view('application_form');
     } elseif (Input::get('submit')) {
         $this->submitForm();
         return view('submit_success');
     } elseif (Input::get('cancel')) {
         $this->cancelForm();
         return view('application_form');
     } elseif (Input::get('en')) {
         App::setLocale('en');
         Session::put('application_locale', 'en');
         $this->changeLanguage('en');
         return view('application_form');
     } elseif (Input::get('sv')) {
         App::setLocale('sv');
         Session::put('application_locale', 'sv');
         $this->changeLanguage('sv');
         return view('application_form');
     } elseif (Input::get('tr')) {
         App::setLocale('tr');
         Session::put('application_locale', 'tr');
         $this->changeLanguage('tr');
         return view('application_form');
     }
 }
Example #27
0
 public function sender($id)
 {
     $order = Order::where('id', '=', $id)->where('user_id', '=', Auth::user()->id)->first();
     $order->sender_city_id = (int) Input::get("sender_city_id");
     $this->recalculateDelivery($order);
     return $this->orderToJson($order);
 }
 /**
  * Traitement du formulaire de validation
  *
  * @return Redirect
  */
 public function postEntrepriseValidation(ValidationEntrepriseRequest $request)
 {
     $user = User::find(Input::get('_id'));
     $user->valide = 1;
     $user->save();
     return Redirect::refresh()->with('flash_success', 'L\'entreprise a bien été validée');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     //
     // 先验证
     $this->validate($request, ['title' => 'required', 'content' => 'required']);
     //
     $wdInfo = WdInfo::findOrFail($id);
     $wdInfo->title = Input::get('title');
     $wdInfo->content = Input::get('content');
     // 单独处理图片
     $newLogo = ImageUtil::saveImgFromRequest($request, 'logo', 'img/wd/');
     if (!is_null($newLogo)) {
         $wdInfo->logo = $newLogo;
     }
     $newQr = ImageUtil::saveImgFromRequest($request, 'qrImg', 'img/wd/');
     if (!is_null($newQr)) {
         $wdInfo->qr_img = $newQr;
     }
     if ($wdInfo->save()) {
         //            return redirect($request->getPathInfo(). '/edit')->withData([
         //                'wdInfo' => $wdInfo,
         //                'message' => [trans('adminTip.wdInfo.editInfo.success.edit')]
         //            ]);
         return redirect($request->getPathInfo() . '/edit')->withInput()->withOk(trans('adminTip.wdInfo.editInfo.success.edit'));
     } else {
         return Redirect::back()->withInput()->withErrors('error');
     }
 }
Example #30
-1
 public function postimage(Request $request)
 {
     $user = User::whereId(Auth::user()->id)->first();
     $path = public_path() . '/images/profiles/';
     $currentimage = $path . $user->avatar;
     if ($user->avatar != 'default.png') {
         \File::delete($currentimage);
     }
     if (Input::hasFile('file')) {
         $this->validate($request, ['file' => ['required', 'image']]);
         $file = Input::file('file');
         $filename = Auth::user()->id . '_' . time() . '.' . Input::file('file')->guessClientExtension();
         $img = Image::make($file);
         $img->fit(300, 300, function ($constraint) {
             $constraint->aspectRatio();
         })->save($path . $filename);
         $user->avatar = $filename;
         $user->save();
         return 'ok -' . $filename;
     } else {
         $user->avatar = 'default.png';
         $user->save();
         return redirect('/membres/profil/');
     }
 }