Example #1
0
 /**
  * Process video upload
  *
  * @param  \Illuminate\Http\Request $request The form with the needed data
  * @return \Illuminate\Http\RedirectResponse
  */
 public function process(Request $request)
 {
     //validation rules
     $rules = ['title' => 'required', 'category_list' => 'required', 'user_id' => 'required', 'video' => 'isneededvideo'];
     //validation messages
     $msgs = ['title.required' => 'A cím kitöltése kötelező!', 'category_list.required' => 'A kategória kiválasztása kötelező!', 'user_id.required' => 'A szerző kiválasztása kötelező!', 'video.required' => 'Videó nélkül nincs mit feltölteni!', 'isneededvideo' => 'A videónak mp4 vagy webm formátumúnak kell lennie!'];
     \Validator::extend('isneededvideo', function ($attr, $value, $params) {
         return $value->getMimeType() == 'video/mp4' || $value->getMimeType() == 'video/webm';
     });
     $validator = \Validator::make($request->all(), $rules, $msgs);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator->errors())->withInput($request->all());
     }
     //ease up coding with some shortcuts
     $file = $request->file('video');
     $extension = strtolower($file->getClientOriginalExtension());
     $video = \App\Models\Video::create($request->except('video', 'category_list'));
     //set video filename
     $video->video = $video->getKey() . '.' . $extension;
     //move video file
     $file->move(public_path() . '/videos/', $video->video);
     //save object
     $video->save();
     //sync pivot
     $video->categories()->sync(array_filter($request->input('category_list')));
     //do the capture
     $this->capture($video);
     return redirect('/');
 }
 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(Request $request)
 {
     // error_log("------------------------------------------------------");
     $Mailer = new Email();
     $Mailer->email = $request['email'];
     /* $validator class with method fails() */
     $validator = Validator::make($request->all(), ['email' => 'required|email']);
     /* $isNewEmail =
                true: no email found in db
                false: duplicate email found in db
        */
     $isNewEmail = collect($Mailer->where('email', $Mailer->email)->get())->isEmpty() ? true : false;
     if ($validator->fails()) {
         error_log(json_encode(['error' => ['invalid_email' => $request->all()]]));
         return response()->json(['error' => 'E-mail is invalid'])->setCallback($request->input('callback'));
     } elseif (!$isNewEmail) {
         error_log(json_encode(['error' => ['duplicate_email' => $request->all()]]));
         return response()->json(['error' => 'E-mail is marked as being subscribed'])->setCallback($request->input('callback'));
         return redirect('/')->withErrors($validator)->withInput();
     } else {
         error_log(json_encode(['mailer' => ['newEmail' => $Mailer]]));
         // soon
         $Scribe = $this->subscribe($Mailer->email);
         // soon
         error_log(json_encode(['scribe' => $Scribe]));
         $Mailer->save();
         return response()->json(['success' => true])->setCallback($request->input('callback'));
     }
 }
Example #4
0
 public function postPokaz(Request $request)
 {
     if (Session::has('nls')) {
         $tar = Session::get('tar');
         $nls = Session::get('nls');
         if ($tar == 1) {
             $messages = array('required' => Lang::get('book.nls_required'), 'numeric' => Lang::get('book.nls_numeric'));
             $v = Validator::make($request->all(), Geng::$rules['t1'], $messages);
             if ($v->fails()) {
                 return redirect()->back()->withInput()->withErrors($v);
             } else {
                 $kontr_d = $request->input('t1');
                 Pokaz::create(array('kontr_pk' => $kontr_d, 'nls' => $nls));
                 return Redirect('/input/pokaz')->withAlert(Lang::get('book.pok_save'));
             }
         } else {
             $messages = array('required' => Lang::get('book.nls_required'), 'numeric' => Lang::get('book.nls_numeric'));
             $v = Validator::make($request->all(), Geng::$rules['t2'], $messages);
             if ($v->fails()) {
                 return Redirect('/input/pokaz')->withInput()->withErrors($v);
             } else {
                 $kontr_d = Input::get('t1');
                 $kontr_n = Input::get('t2');
                 Pokaz::create(array('kontr_pk' => $kontr_d + $kontr_n, 'd_pok' => $kontr_d, 'n_pok' => $kontr_n, 'nls' => $nls));
                 return Redirect('/input/pokaz')->withAlert(Lang::get('book.pok_save'));
             }
         }
     }
 }
 /**
  * 用户通过邮箱和密码进行登录操作
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function login(Request $request)
 {
     //获取当前访问的全部的地址
     $request_url = str_replace("http://" . Config::get('app.url'), "", $request->url());
     //验证参数
     $validator = Validator::make($request->all(), ['email' => 'required|email', 'password' => 'required']);
     //验证参数完整性
     if ($validator->fails()) {
         // var_dump($validator);
         $error = $validator->errors()->all();
         //写入日志
         Log::error(['error' => $error, 'request' => $request->all(), 'header' => $request->headers, 'client_ip' => $request->getClientIp()]);
         //返回错误信息
         return Error::returnError($request_url, 1001);
     }
     $email = $request->get('email');
     $password = $request->get('password');
     //检查有没有
     $user_model = User::checkUserLogin($email, $password);
     if ($user_model == false) {
         return Error::returnError($request_url, 2001);
     }
     //更新token
     $token = User::updateToken($user_model);
     //返回对应的结果
     $json_arr = ['request' => $request_url, 'ret' => User::getUserInfo($user_model->id), 'token' => $token];
     return Common::returnResult($json_arr);
 }
 public function store(Request $request)
 {
     Validator::extend('not_contains', function ($attribute, $value, $parameters) {
         // Banned words
         $words = array('undefined');
         foreach ($words as $word) {
             if (stripos($value, $word) !== false) {
                 return false;
             }
         }
         return true;
     });
     $messages = array('not_contains' => 'The :attribute is required');
     $validator = Validator::make($request->all(), array('name' => 'required|unique:collections|min:3|not_contains'), $messages);
     if ($validator->fails()) {
         return $validator->messages();
     } else {
         $user = Auth::user();
         $user_id = $user['id'];
         $collection = Collection::create($request->all());
         $collection->created_by = $user_id;
         $collection->approved = False;
         $collection->slug = str_slug($collection->name . '-' . $collection->id, "-");
         $collection->save();
         return response()->json(['status' => 'success', 'data' => $collection]);
     }
 }
 /**
  * Checks the steam login
  *
  * @return bool
  */
 public function validate()
 {
     if ($this->request->has('openid_assoc_handle') && $this->request->has('openid_signed') && $this->request->has('openid_sig')) {
         $get = $this->request->all();
         try {
             $params = array('openid.assoc_handle' => $get['openid_assoc_handle'], 'openid.signed' => $get['openid_signed'], 'openid.sig' => $get['openid_sig'], 'openid.ns' => 'http://specs.openid.net/auth/2.0');
             $signed = explode(',', $get['openid_signed']);
             foreach ($signed as $item) {
                 $val = $get['openid_' . str_replace('.', '_', $item)];
                 $params['openid.' . $item] = get_magic_quotes_gpc() ? stripslashes($val) : $val;
             }
             $params['openid.mode'] = 'check_authentication';
             $data = http_build_query($params);
             $context = stream_context_create(array('http' => array('method' => 'POST', 'header' => "Accept-language: en\r\n" . "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($data) . "\r\n", 'content' => $data)));
             $result = file_get_contents(self::OPENID_URL, false, $context);
             preg_match("#^http://steamcommunity.com/openid/id/([0-9]{17,25})#", $get['openid_claimed_id'], $matches);
             $this->steamId = is_numeric($matches[1]) ? $matches[1] : 0;
             $this->parseInfo();
             $response = preg_match("#is_valid\\s*:\\s*true#i", $result) == 1 ? true : false;
         } catch (Exception $e) {
             $response = false;
         }
         if (is_null($response)) {
             throw new Exception('The Steam login request timed out or was invalid');
         }
         return $response;
     } else {
         return false;
     }
 }
Example #8
0
 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function change_password(Request $request)
 {
     $input = $request->all();
     $user = $request->user();
     $user_detail = json_decode($user, true);
     $user_id = $user_detail['id'];
     $current_password = $input['current_password'];
     $new_password = $input['new_password'];
     $confirm_password = $input['confirm_password'];
     $validator = Validator::make($request->all(), ['current_password' => 'required|min:6', 'new_password' => 'required|min:6', 'confirm_password' => 'required|same:new_password']);
     if ($validator->fails()) {
         return redirect('/change-password')->withErrors($validator)->withInput();
     }
     if (Hash::check(Input::get('current_password'), Auth::user()->password)) {
         $user->password = bcrypt($new_password);
         $user->save();
         $request->session()->flash('alert-success', 'Password changed successful.');
         return view("auth/change_password");
     } else {
         return Redirect::back()->withErrors(['Sorry! Your current password not match,Please try again']);
     }
     /* echo "<pre>";
     			print_r($input);
     			die;*/
 }
 public function DoiHinhDaiDienGV(Request $req)
 {
     $macb = \Auth::user()->taikhoan;
     $hoten = DB::table('giang_vien')->where('macb', $macb)->value('hoten');
     $post = $req->all();
     $v = \Validator::make($req->all(), ['fHinh' => 'required|image']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors());
     } else {
         $file = Input::file('fHinh');
         // Đặt đường dẫn lưu file upload
         $luuden = public_path() . '/hinhdaidien/';
         // Lấy đuôi mở rộng
         //           $extension = Input::file('fHinh')->getClientOriginalExtension();
         //Gắn đuôi mở rộng lúc nào cũng là png
         $extension = "png";
         // Đặt lại tên file vừa upload lên
         $tachten = $this->lay_ten($hoten);
         $fileName = $tachten . str_replace("/", "", str_replace(" ", "", $macb)) . '.' . $extension;
         //Lưu Hình Vào CSDL
         DB::table('giang_vien')->where('macb', $macb)->update(['hinhdaidien' => $fileName]);
         // Chuyển file upload vào thư mục lưu trữ đã đặt trươc đó
         $upload_success = $file->move($luuden, $fileName);
         if ($upload_success) {
             return Redirect('giangvien/doimatkhaugv')->with('message', 'Upload hình đại diện thành công!');
         }
     }
 }
Example #10
0
 /**
  * Associate relationships to other table
  * 
  * @param object $object
  * @param Request $request
  */
 public function associateRelationships($object, Request $request)
 {
     /**
      * Validate user ID, if failed set to actual authorized user
      */
     $validator = Validator::make($request->all(), ['user_id' => 'required|integer|min:1|exists:users,id']);
     /**
      * Validator fails - add actual authorized user
      */
     if ($validator->fails()) {
         $object->users()->associate(Auth::user()->id);
     } else {
         $object->users()->associate($request->input('user_id'));
     }
     /**
      * Validate image ID, if failed set to default
      */
     $validator = Validator::make($request->all(), ['image_id' => 'integer|min:1|exists:image,id']);
     /**
      * Validator fails - nothing to do
      */
     if ($validator->fails()) {
     } else {
         $object->images()->associate($request->input('image_id'));
     }
 }
 /**
  * post的方式添加一条记录
  *
  * @return \Illuminate\Http\Response
  */
 public function create(Request $request)
 {
     $request_url = str_replace("http://" . Config::get('app.url'), "", $request->url());
     //验证参数
     $validator = Validator::make($request->all(), ['name' => 'required|max:255']);
     //验证参数完整性
     if ($validator->fails()) {
         $error = $validator->errors()->all();
         //写入日志
         Log::error(['error' => $error, 'request' => $request->all(), 'header' => $request->headers, 'client_ip' => $request->getClientIp()]);
         //返回错误信息
         return Error::returnError($request_url, 1001);
     }
     //验证token
     //        $user_id=Common::validateToken($request->get('token'));
     //
     //        if($user_id == false){
     //            return Error::returnError($request_url,2002);
     //        }
     $name = $request->get('name');
     //写入操作
     $add = Task::addTask($name);
     $info = Task::getTaskInfo($add);
     //返回对应的结果
     $json_arr = ['request' => $request_url, 'ret' => $info];
     return Common::returnResult($json_arr);
 }
 public function getRequestAsArray($method)
 {
     if ($old = $this->request->old()) {
         return $old;
     }
     return $this->request->all();
 }
 /**
  * New status comment
  *
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->commentForm->validate($request->all());
     $input = array_add($request->all(), 'user_id', Auth::id());
     $this->statusRepo->leaveComment($input);
     return back();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $body = $request->all();
     $status = new Status($request->all());
     \Auth::user()->statuses()->save($status);
     return \Redirect::back();
 }
Example #15
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $property = Property::findOrFail($request->all()['property_id']);
     $rental = ['id' => $request->all()['rental_id'], 'dailyAmount' => $request->all()['rental_dailyAmount'], 'from' => $request->all()['rental_from'], 'to' => $request->all()['rental_to'], 'media' => self::stripMedia($request)];
     Rental::store($rental['dailyAmount'], $rental['from'], $rental['to'], $property, $rental['media'], $rental['id']);
     return Redirect::route('rental.index');
 }
Example #16
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     // validation
     $v = \Validator::make($request->all(), ['url_file' => 'required|max:5000', 'place_id' => 'required|numeric', 'type_print' => 'required|numeric']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors())->withInput();
     }
     // generate code print
     $code = app('App\\Repositories\\PrintList\\PrintListRepository')->_get_code();
     $file_name = "";
     $old_name_file = "";
     // section untuk file
     if ($request->hasFile('url_file')) {
         $file_extensi = $request->file('url_file')->getClientOriginalExtension();
         $file_name = $code . "." . $file_extensi;
         $old_name_file = $request->file('url_file')->getClientOriginalName();
         if ($file_extensi == "doc" || $file_extensi == "docx" || $file_extensi == "pdf" || $file_extensi == "xls" || $file_extensi == "xlsx" || $file_extensi == "ods" || $file_extensi == "odt") {
             $request->file('url_file')->move(base_path() . '/public/file', $code . "." . $file_extensi);
         } else {
             return redirect()->back()->withErrors('Sorry the file must be with extension doc, docx or pdf');
         }
     } else {
         return redirect()->back()->withErrors($v->errors())->withInput();
     }
     // saving data
     app('App\\Repositories\\PrintList\\PrintListRepository')->savePrintList($request->all(), $this->user_id, $code, $file_name, $old_name_file);
     return redirect('konfirm/' . $code);
 }
Example #17
0
 /**
  * Save role
  *
  * @param Illuminate\Http\Request $request
  *
  * @return response
  *
  * @throws \Exception
  */
 public function save(Request $request)
 {
     if ($request->isMethod('POST')) {
         $edit = $request->has('id');
         $role = $edit ? $this->_getRoleById($request->get('id')) : $this->role;
         $rules = $this->role->rules();
         $messages = $this->role->messages();
         if ($edit && str_equal($role->role, $request->get('role'))) {
             $rules = remove_rules($rules, ['role.unique:roles,role']);
         }
         $validator = Validator::make($request->all(), $rules, $messages);
         if ($validator->fails()) {
             return back()->withInput()->withErrors($validator, 'all');
         }
         try {
             $role = $this->bind($role, $request->all());
             if (!$edit) {
                 $role->created_at = new \DateTime();
             }
             $role->updated_at = new \DateTime();
             $role->save();
         } catch (Exception $ex) {
             throw new \Exception(_t('backend_common_opp') . $ex->getMessage());
         }
         return redirect(route('backend_roles'))->with('success', _t('backend_common_saved'));
     }
 }
Example #18
0
 public function contact_us(Request $request)
 {
     if ($request->all()) {
         $rules = array('name' => 'required', 'email' => 'required|email', 'type' => 'required', 'message' => 'required');
         $validator = Validator::make($request->all(), $rules);
         if (!$validator->fails()) {
             $ask = new Ask();
             $ask->name = $request->input('name');
             $ask->email = $request->input('email');
             $ask->type = $request->input('type');
             $ask->ask = $request->input('message');
             $ask->status = 0;
             if ($ask->save()) {
                 return redirect('contact')->with('success', 'Pesan anda telah dikirimkan, kami akan membalas pesan anda secepatnya');
             }
         } else {
             return redirect('contact')->with('error', 'harap isi semua form');
         }
     } else {
         $this->data['css_assets'] = Assets::load('css', ['lib-bootstrap', 'style', 'font-awesome', 'font-awesome-min', 'flexslider', 'color-schemes-core', 'color-schemes-turquoise', 'jquery-parallax', 'bootstrap-responsive', 'font-family']);
         $this->data['js_assets'] = Assets::load('js', ['jquery', 'jquery-ui', 'jquery-easing', 'bootstrap-min-lib', 'jquery-isotope', 'jquery-flexslider', 'jquery.elevatezoom', 'jquery-sharrre', 'jquery-gmap3', 'imagesloaded', 'la_boutique', 'jquery-cookie', 'jquery-parallax-lib']);
         $this->data['title'] = 'Kontak Kami';
         return view('main_layout')->with('data', $this->data)->nest('content', 'contact_us', array('data' => $this->data));
     }
 }
Example #19
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['accountname' => 'required|max:255', 'iban' => 'required|min:20|max:20', 'subject' => 'required|max:255', 'sum' => 'required', 'order_id' => 'required|integer|min:1']);
     $values = $request->all();
     $values = array_map('trim', $values);
     //remove leading and trailing whitespaces on all values
     $values['group'] = Auth::user()->group;
     //try calculating the sum from string
     try {
         $calculator = new \NXP\MathExecutor();
         $values['sum'] = $calculator->execute($values['sum']);
     } catch (Exception $e) {
         Log::Info('Input: "' . $values['sum'] . '" has failed to evaluate');
     }
     // Check whether the order exists and is actually owned by the given group
     $order = Order::where('id', $values['order_id'])->where('group', $values['group'])->firstOrFail();
     if ($validator->fails()) {
         // Return JSON response with 422 HTTP status code
         return $validator->errors()->all();
     }
     // Validation successful, store entity
     $payment = new Payment($values);
     $payment->save();
     return $payment;
 }
Example #20
0
 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function register(Request $request)
 {
     $this->validator($request->all())->validate();
     event(new Registered($user = $this->create($request->all())));
     $user->notify(new EmailVerification());
     return redirect()->back()->with('success', 'Please check your email for the confirmation link!');
 }
Example #21
0
 /**
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function post(Request $request)
 {
     $data['title'] = $request->bugTitle;
     $data['description'] = $request->bugDescription;
     $data['controller'] = $request->controller;
     if (!Auth::user()) {
         $data['email'] = $request->bugEmail;
         $data['name'] = $request->bugName;
         $validator = Validator::make($request->all(), ['bugEmail' => 'required|email|max:255', 'bugName' => 'required|max:255|alpha_space', 'bugTitle' => 'required|max:255', 'bugDescription' => 'required|max:255']);
     } else {
         $data['email'] = Auth::user()->email;
         $data['name'] = Auth::user()->name;
         $validator = Validator::make($request->all(), ['bugTitle' => 'required|max:255|email', 'bugDescription' => 'required|max:255']);
     }
     if ($validator->fails()) {
         return back()->withErrors($validator)->withInput()->with('modal', true);
     }
     $response = Mail::send('emails.ladybug', $data, function ($message) use($data) {
         $message->from($data['email'], $data['name']);
         $message->subject("Bug Report");
         $message->to('admin@uir-events.com');
     });
     if ($response) {
         return back()->with('success', 'Your report has been sent.');
     } else {
         return back()->with('error', 'An error occured, please try again.');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     Validator::make($request->all(), ['emp_firstname' => 'required', 'emp_middlename' => 'required', 'emp_lastname' => 'required', 'emp_gender' => 'required', 'emp_email' => 'required|email']);
     $employee = $this->employee;
     $employee->create($request->all());
     return redirect('employee')->with('status', 'Successfully Created.');
 }
Example #23
0
 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function register(Request $request)
 {
     $this->validator($request->all())->validate();
     event(new Registered($user = $this->create($request->all())));
     $this->guard()->login($user);
     return $this->registered($request, $user) ?: redirect($this->redirectPath());
 }
 public function store(Request $request)
 {
     $emp = Session::get('empresa');
     Parameter::where('par_company', $emp)->forceDelete();
     Parameter::create($request->all());
     return view('parameters')->with('data', $request->all());
 }
Example #25
0
 /**
  * Creates a new class and stores it in DB
  **/
 public function store(Request $request)
 {
     //create class entry
     $class = Auth::user()->classes()->create($request->all());
     //grab id
     $classID = $class->id;
     //set up array for later
     $missingUsers = array();
     //loop through submitted email addresses
     foreach ($request->all() as $key => $value) {
         if (preg_match('/^student/', $key)) {
             $result = $this->addStudentToClass($value, $classID);
             if ($result == false) {
                 //add user to $missingUsers array
                 $missingUsers[] = $value;
             }
         }
     }
     //check if any missing users
     if (count($missingUsers) >= 1) {
         //don't want to create class, destroy it
         $this->destroy($classID, true);
         //redirect with error message
         return redirect('/classes')->with(['flash_message' => 'Your class could not be created. The following users were not found: ', 'missingUsers' => $missingUsers, 'alert_class' => 'alert-danger']);
     } else {
         //redirect with success message
         return redirect('/classes')->with(['flash_message' => 'Your class has been created.', 'alert_class' => 'alert-success']);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validation = $this->validation($request->all());
     if ($validation->fails()) {
         return redirect()->back()->withInput()->withErrors($validation);
     }
     if (!($request->file('artwork')->isValid() || $request->file('signature')->isValid())) {
         return redirect()->back()->withInput()->withErrors(['there went something wrong while uploading the pictures.']);
     }
     $auction = new Art();
     $auction->fill($request->all());
     $auction->slug = $this->slugify($request->input('title'));
     $auction->description_nl = $request->input('description');
     $auction->description_en = $request->input('description');
     $auction->condition_nl = $request->input('condition');
     $auction->condition_en = $request->input('condition');
     $auction->user_id = 1;
     $auction->artist_id = 1;
     $auction->style_id = 1;
     $auction->save();
     //store the images
     $this->storeImage($auction, $request->file('artwork'), true);
     $this->storeImage($auction, $request->file('signature'), false);
     //store optional image if is set
     if ($request->file('optional_image')) {
         $this->storeImage($auction, $request->file('optional_image'), false);
     }
     return redirect()->route('art.index')->withSuccess('successfully made a new auction');
 }
Example #27
0
 public function update(Request $request, $model, $id)
 {
     $model = $this->baseModel . $model;
     $data = null;
     try {
         $model = $model::findOrFail($id);
         if (count($request->all())) {
             foreach ($request->all() as $key => $value) {
                 if (in_array($key, config('crudapi.hashing'))) {
                     $value = Hash::make($value);
                 }
                 $model->{$key} = $value;
             }
             try {
                 $data = $model->save();
             } catch (\Exception $e) {
                 $data = $e->getMessage();
                 return $this->response($data, 500);
             }
         }
     } catch (\Exception $e) {
         $data = 'Not found';
         return $this->response($data, 404);
     }
     return $this->response($data);
 }
Example #28
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validator = $this->validator($request->all());
     $this->create($request->all());
     $params = json_decode($request->params, TRUE);
     return redirect(route("oauth.authorize.get", $params));
 }
Example #29
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //validate this
     var_dump($request->all());
     $input = $request->all();
     $params = [];
     $quantities = $input['quantities'] = explode(',', $input['quantities']);
     $items = $this->item->getIn('id', explode(',', $input['ids']));
     $ctr = 0;
     $recipe = Recipe::create($request->all());
     foreach ($items as $key => $value) {
         $ing = ['name' => $value['name'] . " for " . $recipe->name, 'recipe_id' => $recipe->id, 'item_id' => $value['id'], 'quantity' => (int) $quantities[$ctr]];
         array_push($params, $ing);
         $ctr++;
     }
     $ingredients = Ingredient::insert($params);
     if ($recipe && $ingredients) {
         return redirect()->back()->with('flash_message', 'Recipe has been successfully saved.');
     }
     $this->recipe->fdelete($recipe);
     foreach ($ingredients as $key) {
         $key->forceDelete();
     }
     return redirect()->back()->withErrors('Could not save recipe');
 }
 public function edit($id, Request $request)
 {
     if (Distributor::find($id)) {
         if ($request->all()) {
             $rules = array('name' => 'required', 'email' => 'email');
             $validator = Validator::make($request->all(), $rules);
             if (!$validator->fails()) {
                 $distributor = Distributor::find($id);
                 $distributor->name = $request->input('name');
                 $distributor->email = $request->input('email');
                 $distributor->address = $request->input('address');
                 $distributor->phone = $request->input('phone');
                 if ($distributor->save()) {
                     return redirect('master/distributor/list');
                 }
             } else {
                 return redirect('master/distributor/edit/' . $id)->with('error', 'Terdapat form kosong');
             }
         } else {
             $this->data['css_assets'] = Assets::load('css', ['admin_bootstrap', 'admin_css', 'font-awesome', 'skins']);
             $this->data['js_assets'] = Assets::load('js', ['jquery', 'admin_js', 'admin_bootstrap-js', 'slimscroll', 'fastclick']);
             $this->data['title'] = 'Distributor | Edit';
             $this->data['distributor'] = Distributor::find($id);
             return view('admin_layout')->with('data', $this->data)->nest('content', 'admin/distributor/form', array('data' => $this->data));
         }
     } else {
         return redirect('master/distributor/list');
     }
 }