Example #1
0
 public function news(Request $request)
 {
     if ($request->isMethod('POST')) {
         //            News::create($request->except('_token'));
         // read image from temporary file
         $file = $request->file('imagePrev');
         $img = Image::make($file->getRealPath());
         $nameFile = $file->getClientOriginalName();
         //          resize image
         $img->fit(263, 263);
         // save image
         $img->save("images/" . $nameFile);
         News::create(['text' => $request->input('editor1'), 'header' => $request->input('header'), 'picture' => "images/" . $nameFile]);
         //            switch ( $request->input('type') ) {
         //                case 'insert':
         //                    News::create($request->except('_token'));
         //                    break;
         //                case 'update':
         //                    News::find( $request->input('id') )->update([
         //                        'header' => $request->input('header'),
         //                        'text' => $request->input('editor1'),
         //                    ]);
         //                    break;
         //            }
     }
     if ($request->isMethod('GET')) {
         $item = News::find($request->input('remove'));
         if ($item) {
             $item->delete();
         }
     }
     $news = News::orderBy('created_at', 'DESC')->paginate(15);
     return view('admin/news', ['news' => $news]);
 }
Example #2
0
 /**
  * @param Request $request
  * this is the function where update the shopping cart and mainly consider about the change the quantity and display the total amount
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function update(Request $request)
 {
     if ($request->isMethod('post')) {
         if ($request->get('UpdateCart')) {
             $data = $request->session()->get('items');
             $request->session()->pull('items');
             foreach ($data as $item) {
                 $quantity = $request->get($item['id'] . 'quantity');
                 $request->session()->push('items', ['id' => $item['id'], 'quantity' => $quantity, 'name' => $item['name'], 'price' => $item['price'], 'imgpath' => $item['imgpath']]);
             }
             $data = $request->session()->get('items');
             $cat_name = $request->get('catName');
             return view('pages.cart.cart', compact('data', 'cart', 'total', 'n', 'cat_name'));
         }
     }
     //this is the remove item from shoiing cart
     if ($request->isMethod('post')) {
         if ($request->get('cartDestroy')) {
             $data = $request->session()->get('items');
             $item_id = $request->get('cartDestroy');
             //first pull product details from the session array
             $request->session()->pull('items');
             foreach ($data as $item) {
                 if ($item['id'] != $item_id) {
                     $request->session()->push('items', ['id' => $item['id'], 'quantity' => $item['quantity'], 'name' => $item['name'], 'price' => $item['price'], 'imgpath' => $item['imgpath']]);
                 }
             }
             $data = $request->session()->get('items');
             $cat_name = $request->get('catName');
             return view('pages.cart.cart', compact('data', 'cat_name'));
         }
     }
 }
Example #3
0
 public function anyUpload(InterfaceFileStorage $userFileStorage, AmqpWrapper $amqpWrapper, Server $server, UploadEntity $uploadEntity)
 {
     /* @var \App\Components\UserFileStorage $userFileStorage */
     $responseVariables = ['uploadStatus' => false, 'storageErrors' => [], 'uploadEntities' => []];
     if ($this->request->isMethod('post') && $this->request->hasFile('file') && $this->request->file('file')->isValid()) {
         $tmpDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tmp-user-files-to-storage' . DIRECTORY_SEPARATOR;
         $tmpFilePath = $tmpDir . $this->request->file('file')->getClientOriginalName();
         $this->request->file('file')->move($tmpDir, $this->request->file('file')->getClientOriginalName());
         $userFileStorage->setValidationRules($this->config->get('storage.userfile.validation'));
         $newStorageFile = $userFileStorage->addFile($tmpFilePath);
         if ($newStorageFile && !$userFileStorage->hasErrors()) {
             /* @var \SplFileInfo $newStorageFile */
             // AMQP send $newfile, to servers
             foreach ($server->all() as $server) {
                 if (count($server->configs) > 0) {
                     foreach ($server->configs as $config) {
                         // Send server and file info to upload queue task
                         $amqpWrapper->sendMessage($this->config->get('amqp.queues.uploader.upload'), json_encode(['file' => $newStorageFile->getRealPath(), 'url' => $server->scheme . '://' . $config->auth . '@' . $server->host . '/' . trim($config->path, '\\/')]));
                     }
                 } else {
                     // The server has no configuration
                     $amqpWrapper->sendMessage($this->config->get('amqp.queues.uploader.upload'), json_encode(['file' => $newStorageFile->getRealPath(), 'url' => $server->scheme . '://' . $server->host]));
                 }
             }
             $responseVariables['uploadStatus'] = true;
         } else {
             $responseVariables['storageErrors'] = $userFileStorage->getErrors();
         }
         if ($this->request->ajax()) {
             return $this->response->json($responseVariables);
         }
     }
     $responseVariables['uploadEntities'] = $uploadEntity->limit(self::UPLOAD_ENTITIES_LIMIT)->orderBy('created_at', 'DESC')->get();
     return $this->view->make('upload.index', $responseVariables);
 }
 /**
  * {@inheritdoc}
  */
 public function execute($request)
 {
     /** @var $request ObtainCreditCard */
     if (false == $this->supports($request)) {
         throw RequestNotSupportedException::createActionNotSupported($this, $request);
     }
     if ($this->request->isMethod('POST')) {
         $creditCard = new CreditCard();
         $creditCard->setHolder($this->request->get('card_holder'));
         $creditCard->setNumber($this->request->get('card_number'));
         $creditCard->setSecurityCode($this->request->get('card_cvv'));
         $creditCard->setExpireAt(new DateTime($this->request->get('card_expire_at')));
         $request->set($creditCard);
         return;
     }
     $form = $this->viewFactory->make($this->templateName, ['model' => $request->getModel(), 'firstModel' => $request->getFirstModel(), 'actionUrl' => $request->getToken() ? $request->getToken()->getTargetUrl() : null]);
     throw new HttpResponse(new Response($form->render(), 200, ['Cache-Control' => 'no-store, no-cache, max-age=0, post-check=0, pre-check=0', 'X-Status-Code' => 200, 'Pragma' => 'no-cache']));
     /*
         $content = $this->viewFactory->make($this->templateName, [
             'model'      => $request->getModel(),
             'firstModel' => $request->getFirstModel(),
             'form'       => $form->render(),
             'actionUrl'  => $request->getToken() ? $request->getToken()->getTargetUrl() : null,
         ]);
     
         $this->gateway->execute($renderTemplate);
     
         throw new HttpResponse(new Response($renderTemplate->getResult(), 200, [
             'Cache-Control' => 'no-store, no-cache, max-age=0, post-check=0, pre-check=0',
             'X-Status-Code' => 200,
             'Pragma'        => 'no-cache',
         ]));
     */
 }
Example #5
0
 /**
  * Create simple contact form
  * @return void
  */
 public function contact(Request $request)
 {
     if ($request->isMethod('get')) {
         return view('pages.contact');
     } elseif ($request->isMethod('post')) {
         dd($request->all());
     }
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->isMethod('POST') || $request->isMethod('PUT')) {
         json_decode($request->getContent());
         if (json_last_error() != JSON_ERROR_NONE) {
             return response()->json("Request must be json", 400);
         }
     }
     return $next($request);
 }
Example #7
0
 /**
  * @param \Illuminate\Http\Request $request
  */
 protected function correctSlug(&$request)
 {
     $slug = $request->input('slug');
     $validateMethod = $request->isMethod('POST') || $request->isMethod('PUT') || $request->isMethod('PATCH');
     if (!empty($slug) && $validateMethod) {
         $strSlug = Str::slug($slug);
         if ($strSlug !== $slug) {
             $request->request->set('slug', $strSlug);
         }
     }
 }
 public function update(Request $request, $id)
 {
     if ($request->isMethod('get')) {
         $data['item'] = Bahan::find($id);
         return view('update', $data);
     } elseif ($request->isMethod('post')) {
         $item = Bahan::find($id);
         $item->nama = Input::get('nama');
         $item->kode = Input::get('kode');
         $item->save();
         return redirect('bahan');
     }
 }
Example #9
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules(\Illuminate\Http\Request $request)
 {
     // validation rule for create request.
     if ($request->isMethod('POST')) {
         return ['name' => 'required', 'content' => 'required'];
     }
     // Validation rule for update request.
     if ($request->isMethod('PUT') || $request->isMethod('PATCH')) {
         return ['name' => 'required'];
     }
     // Default validation rule.
     return [];
 }
Example #10
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules(Request $request)
 {
     if ($request->isMethod('POST')) {
         // validation rule for create request.
         return [];
     }
     if ($request->isMethod('PUT') || $request->isMethod('PATCH')) {
         // Validation rule for update request.
         return [];
     }
     // Default validation rule.
     return [];
 }
Example #11
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules(\Illuminate\Http\Request $request)
 {
     $user = $this->route('user');
     // validation rule for create request.
     if ($request->isMethod('POST')) {
         return ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|min:6'];
     }
     // Validation rule for update request.
     if ($request->isMethod('PUT') || $request->isMethod('PATCH')) {
         return ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users,email,' . $user->id];
     }
     // Default validation rule.
     return [];
 }
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules(\Illuminate\Http\Request $request)
 {
     $role = $this->route('role');
     // validation rule for create request.
     if ($request->isMethod('POST')) {
         return ['name' => 'required|max:50|unique:roles'];
     }
     // Validation rule for update request.
     if ($request->isMethod('PUT') || $request->isMethod('PATCH')) {
         return [];
     }
     // Default validation rule.
     return [];
 }
 public function update(Request $request, $id)
 {
     if ($request->isMethod('get')) {
         $data['item'] = Resep::find($id);
         $data['kokis'] = Koki::all();
         return view('resep.update', $data);
     } elseif ($request->isMethod('post')) {
         $item = Resep::find($id);
         $item->nama = Input::get('nama');
         $item->kode = Input::get('kode');
         $item->koki_id = Input::get('koki_id');
         $item->save();
         return redirect('resep');
     }
 }
Example #14
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     //
     //Log::info('$request=<' . $request . '>');
     if ($request->isMethod('post')) {
         $bodyContent = $request->getContent();
         //Log::info('$bodyContent=<' . $bodyContent . '>');
         $bodyJson = json_decode($bodyContent);
         $keyPath = $this->keyRoot_ . $bodyJson->token . '/pubKey.pem';
         $fp = fopen($keyPath, 'r');
         $pubKeyMem = fread($fp, 8192);
         fclose($fp);
         $pubkeyid = openssl_pkey_get_public($pubKeyMem);
         $token = $bodyJson->token;
         $sign = $bodyJson->sign;
         $ok = openssl_verify($token, hex2bin($sign), $pubkeyid, "sha256");
         openssl_free_key($pubkeyid);
         if ($ok == 1) {
             $profilePath = $this->keyRoot_ . $bodyJson->token . '/profile';
             //Log::info('$bodyJson->payload=<' . json_encode($bodyJson->payload) . '>');
             file_put_contents($profilePath, json_encode($bodyJson->payload));
             return response()->json(['status' => 'success']);
         } else {
             return response()->json(['status' => 'failure']);
         }
     }
 }
Example #15
0
 public function reportsAction(Request $request)
 {
     $users = DB::select('select id, first_name, last_name, email from users');
     if ($request->isMethod('post')) {
         $id = substr($request->input('email'), strpos($request->input('email'), ":") + 2);
         $year = $request->input('year');
         $month = $request->input('month');
         $events = DB::select('select users.first_name, events.*, transport.name as t_name, transport.load_consumption,
               transport.moving_consumption, transport.stat_consumption
               from users inner join events on users.id = events.user_id
               left join transport on events.vehicle_id = transport.id
               where year(events.date) = ? and month(events.date) = ?
               AND users.id = ?', [$year, $month, $id]);
         $calc = [];
         foreach ($events as $event) {
             $parsed_arrive = date_parse($event->client_arrive);
             $parsed_leave = date_parse($event->client_leave);
             $hours['arrive'] = $parsed_arrive['hour'] + $parsed_arrive['minute'] / 60;
             $hours['leave'] = $parsed_leave['hour'] + $parsed_leave['minute'] / 60;
             $hours['actual'] = $hours['leave'] - $hours['arrive'] - $event->min_spent / 60;
             $calc[$event->id]['distance'] = (int) $event->spidometer_finish - (int) $event->spidometer_start;
             $calc[$event->id]['fuel'] = $calc[$event->id]['distance'] / 100 * $event->moving_consumption + $event->min_spent / 60 * $event->load_consumption + $hours['actual'] * $event->stat_consumption;
         }
         //        die(var_dump($calc));
         return view('admin/reports', ['events' => $events, 'calc' => $calc, 'users' => $users]);
     }
     return view('admin/reports', ['users' => $users]);
 }
 public function add_rule($hash_id, Request $request)
 {
     $enfermedad = Disease::findOrFail($this->decode($hash_id));
     $sintomas = Symptom::orderBy('name', 'asc')->lists('name', 'id')->toArray();
     $reglas = Rule::with('symptom')->where('disease_id', $enfermedad->id)->get()->groupBy('number');
     if ($request->isMethod('post')) {
         $this->validate($request, ['sintomas' => 'required']);
         if ($this->checkIfRuleExists($request->sintomas)) {
             alert('La regla ya existe, por favor ingrese otros síntomas', 'danger');
             return redirect()->back();
         }
         $lastRule = Rule::orderBy('id', 'desc')->first();
         if (is_null($lastRule)) {
             $numberRule = 1;
         } else {
             $numberRule = intval($lastRule->number) + 1;
         }
         $symptoms = Symptom::findOrFail($request->sintomas);
         foreach ($symptoms as $symptom) {
             $rule = new Rule();
             $rule->number = $numberRule;
             $rule->disease()->associate($enfermedad);
             $rule->symptom()->associate($symptom);
             $rule->save();
         }
         alert('Se registró la regla con éxito');
         return redirect()->back();
     }
     return view('admin.disease.add_rule')->with('enfermedad', $enfermedad)->with('reglas', $reglas)->with('sintomas', $sintomas);
 }
Example #17
0
 public function listUser(Request $request)
 {
     $page_title = "List User";
     $title = "Admin - List User";
     if ($request->isMethod('post')) {
         if (Input::get('txt_cari') != '') {
             Session::put('txt_cari_user', Input::get('txt_cari'));
             $users = m_user::where('dispname', 'LIKE', '%' . Input::get('txt_cari') . '%')->paginate(config('myconfig.paging_num'));
         } else {
             Session::forget('txt_cari_user');
             //$users = m_user::all();
             $users = m_user::where('usrid', '<>', Session::get('usrid'))->orderBy('usrid', 'ASC')->paginate(config('myconfig.paging_num'));
             //$users = m_user::orderBy('usrid','desc')->paginate(config('myconfig.paging_num'));
         }
     } else {
         if (Session::has('txt_cari_user')) {
             $users = m_user::where('dispname', 'LIKE', '%' . Session::get('txt_cari_user') . '%')->paginate(config('myconfig.paging_num'));
         } else {
             //$users = m_user::all();
             $users = m_user::where('usrid', '<>', Session::get('usrid'))->orderBy('usrid', 'ASC')->paginate(config('myconfig.paging_num'));
             //$users = m_user::orderBy('usrid','desc')->paginate(config('myconfig.paging_num'));
         }
     }
     $users->setPath('listUser');
     return view('backend.listuser', ['title' => $title, 'page_title' => $page_title, 'users' => $users]);
 }
Example #18
0
 public function add(Request $request)
 {
     if ($request->isMethod('post')) {
         $input = $request->all();
         $fileName = null;
         if (!empty($input['image_url'])) {
             $file = $input['image_url'];
             $extension = $file->getClientOriginalExtension();
             $fileName = rand(11111, 99999) . '.' . $extension;
             $file->move("admin/category", $fileName);
             $destinationPath = "admin/category";
             $fileThumb = "400x300_" . $fileName;
             $img = Image::make("{$destinationPath}/{$fileName}")->resize(400, 300);
             $img->save("{$destinationPath}/{$fileThumb}");
         }
         $category = new Category();
         $category->main_category = $input['main_category'];
         $category->image_url = $fileName;
         $category->slug = $this->slugify($input['title']);
         $category->translateOrNew(LaravelLocalization::setLocale())->title = $input['title'];
         $category->save();
         return redirect(LaravelLocalization::setLocale() . DIRECTORY_SEPARATOR . 'admin-category');
     }
     return view('admin.category.add');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(CookieJar $cookieJar, Request $request)
 {
     if ($request->isMethod('post')) {
         $supplier_email = $request->get('supplier_email');
         $supplier_password = $request->get('supplier_password');
         $checkAgentExists = Supplier::where("email", "=", $supplier_email);
         $checkAgentExists = $checkAgentExists->where("password", "=", md5($supplier_password . Config::get('constants.SITENAME')));
         $checkAgentExists = $checkAgentExists->get();
         if ($request->get('remember_login')) {
             $cookieJar->queue(Cookie::make('supplier_email', $supplier_email, 60));
             $cookieJar->queue(Cookie::make('supplier_password', $supplier_password, 60));
         } else {
             $cookieJar->queue(Cookie::forget('supplier_email'));
             $cookieJar->queue(Cookie::forget('supplier_password'));
         }
         if (count($checkAgentExists) > 0) {
             Session::put('SUPPLIER_ACCESS_ID', $checkAgentExists[0]->id);
             Session::put('SUPPLIER_ACCESS_FNAME', $checkAgentExists[0]->first_name);
             Session::put('SUPPLIER_ACCESS_LNAME', $checkAgentExists[0]->last_name);
             return redirect('supplier/dashboard');
         } else {
             return Redirect::route('supplier_land')->with('message', ['Invalid email address or/and password.']);
         }
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $data = array();
     $settings = Sitesetting::find(1);
     if ($request->isMethod('post')) {
         $validator = Validator::make($request->all(), ['site_name' => 'required', 'default_page_title' => 'required', 'default_meta_keywords' => 'required', 'default_meta_description' => 'required', 'contact_email' => 'required']);
         if ($validator->fails()) {
             return redirect::route('site_settings')->withErrors($validator);
         } else {
             $site_name = $request->site_name;
             $default_page_title = $request->default_page_title;
             $default_meta_keywords = $request->default_meta_keywords;
             $default_meta_description = $request->default_meta_description;
             $contact_email = $request->contact_email;
             $settings->site_name = $site_name;
             $settings->default_page_title = $default_page_title;
             $settings->default_meta_keywords = $default_meta_keywords;
             $settings->default_meta_description = $default_meta_description;
             $settings->contact_email = $contact_email;
             $settings->save();
             return redirect::route('site_settings')->with('success', 'Settings updated successfully.');
         }
     }
     $settings = Sitesetting::all()->first();
     $data['settings'] = $settings;
     return view('admin/sitesettings', $data);
 }
Example #21
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->isMethod('get') && !$request->has('PageSpeed') && !$request->is(config('site.admin_path') . '*') && !$request->is('avatar/*') && !$request->is('my/*') && !$request->is('*/login') && !$request->is('*/authorize') && !in_array($request->path(), ['sitemap.xml', 'logout', 'login'])) {
         $aSiteMap = Cache::get('sitemap', []);
         $changefreq = 'always';
         if (!empty($aSiteMap[$request->fullUrl()]['added'])) {
             $aDateDiff = Carbon::createFromTimestamp($aSiteMap[$request->fullUrl()]['added'])->diff(Carbon::now());
             if ($aDateDiff->y > 0) {
                 $changefreq = 'yearly';
             } else {
                 if ($aDateDiff->m > 0) {
                     $changefreq = 'monthly';
                 } else {
                     if ($aDateDiff->d > 6) {
                         $changefreq = 'weekly';
                     } else {
                         if ($aDateDiff->d > 0 && $aDateDiff->d < 7) {
                             $changefreq = 'daily';
                         } else {
                             if ($aDateDiff->h > 0) {
                                 $changefreq = 'hourly';
                             } else {
                                 $changefreq = 'always';
                             }
                         }
                     }
                 }
             }
         }
         $aSiteMap[$request->fullUrl()] = ['added' => time(), 'lastmod' => Carbon::now()->format('Y-m-d\\TH:i:sP'), 'priority' => 1 - substr_count($request->getPathInfo(), '/') / 10, 'changefreq' => $changefreq];
         Cache::forever('sitemap', $aSiteMap);
     }
     return $next($request);
 }
Example #22
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'));
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request        	
  * @return Response
  */
 public function store(Request $request)
 {
     if ($request->isMethod('post')) {
         return $this->insert($request);
     }
     echo "store";
 }
 public function login(Request $data)
 {
     if ($data->isMethod('post')) {
         $email = $data->input('email');
         $password = $data->input('password');
         $result['message'] = NULL;
         if ($email) {
             $obj = new User();
             $checkIfEmailExists = $obj->getUserWhere($email, $password);
             if ($checkIfEmailExists['status'] !== 200) {
                 $result['message'] = $checkIfEmailExists['message'];
                 return view('Auth.login', ['result' => $result]);
             } else {
                 if (Auth::attempt(['email' => $email, 'password' => $password])) {
                     Session::put('email', $email);
                     return redirect()->intended('view');
                 } else {
                     $result['message'] = 'Password Incorrect';
                     return view('Auth.login', ['result' => $result]);
                 }
             }
         } else {
             return view('auth.login', ['result' => $result]);
         }
     }
 }
 public function changeTicketStatusAjaxHandler(Request $request)
 {
     if ($request->isMethod('post')) {
         $method = $request->input('method');
         switch ($method) {
             case "changeStatus":
                 $ticketId = $request->input('id');
                 $status = $request->input('status');
                 $objModelUser = Ticket::getInstance();
                 $whereForUpdateUser = array('rawQuery' => 'ticket_id = ?', 'bindParams' => [$ticketId]);
                 //                    print_r($whereForUpdateUser);
                 $dataForUpdateUser = array('ticket_status' => $status);
                 print_r($dataForUpdateUser);
                 $updated = $objModelUser->updateTicketWhere($dataForUpdateUser, $whereForUpdateUser);
                 if ($updated) {
                     $message = '';
                     if ($status == 1) {
                         $message = "Ticket Closed.";
                     } else {
                         $message = "Ticket Opened.";
                     }
                     echo json_encode(array('status' => '200', 'message' => $message));
                 } else {
                     echo json_encode(array('status' => '400', 'message' => 'Failed. Plesae try again.'));
                 }
                 break;
             default:
                 break;
         }
     }
 }
Example #26
0
 public function edit($domain, Request $request, $code)
 {
     $orderService = new orderService();
     $addressService = new addressService();
     $shipService = new shipService();
     try {
         $order = $orderService->getOrderByOrderCode($code);
         $id = $order->id;
         if ($order->user_id != $this->_user->id) {
             return redirect('/order');
         }
         if ($request->isMethod('PUT')) {
             if ($order->user_id == $this->_user->id && $order->status == KACANA_ORDER_PARTNER_STATUS_NEW) {
                 $addressService->updateAddressReceive($request->all());
             }
         }
         $buyer = $order->user;
         $user_address = $order->addressReceive;
         $hubInfos = $shipService->getPickHubs();
         $mainHub = $shipService->getPickHubMain($hubInfos);
         $serviceList = $shipService->getServiceList($user_address->district->code, $mainHub->DistrictCode);
         $shippingServiceInfos = $shipService->calculateServiceFee($user_address->district->code, $mainHub->DistrictCode, $serviceList);
         $cities = $addressService->getListCity()->lists('name', 'id');
         $wards = $addressService->getListWardByDistrictId($user_address->district_id);
         $districts = $addressService->getListDistrict();
         return view('partner.order.edit', compact('order', 'buyer', 'user_address', 'cities', 'districts', 'wards', 'shippingServiceInfos', 'hubInfos'));
     } catch (\Exception $e) {
         if ($request->ajax()) {
             $result['error'] = $e->getMessage();
             return $result;
         } else {
             return view('errors.404', ['error_message' => $e]);
         }
     }
 }
 public function edit(Request $request)
 {
     $modelData = new \stdClass();
     /**
      * form is submitted check values and save if needed
      */
     if ($request->isMethod('post')) {
         /**
          * validate data
          */
         $rules = ['user_id_to' => 'required|integer|not_in:0', 'ad_id' => 'required|integer|not_in:0', 'mail_text' => 'required'];
         $validator = Validator::make($request->all(), $rules);
         if ($validator->fails()) {
             $this->throwValidationException($request, $validator);
         }
         /**
          * get data from form
          */
         $data = $request->all();
         /**
          * save and send mail
          */
         $current_user_id = Auth::user()->user_id;
         $mail_to = User::where('user_id', $data['user_id_to'])->firstOrFail()->email;
         $this->mail->saveMailToDbAndSendMail($current_user_id, $data['user_id_to'], $data['ad_id'], $data['mail_text'], $mail_to);
         /**
          * clear cache, set message, redirect to list
          */
         Cache::flush();
         session()->flash('message', trans('admin_common.Mail saved'));
         return redirect(url('admin/mail'));
     }
     return view('admin.mail.mail_edit', ['modelData' => $modelData]);
 }
 /**
  * Returns whether the request must be prerendered server side for crawler.
  *
  * @param Request $request
  * @return bool
  */
 private function shouldPrerender(Request $request)
 {
     $userAgent = strtolower($request->server->get('HTTP_USER_AGENT'));
     $bufferAgent = $request->server->get('X-BUFFERBOT');
     $shouldPrerender = false;
     if (!$userAgent) {
         return false;
     }
     if (!$request->isMethod('GET')) {
         return false;
     }
     //google bot
     if ($request->query->has('_escaped_fragment_')) {
         $shouldPrerender = true;
     }
     //other crawlers
     foreach ($this->userAgents as $crawlerUserAgent) {
         if (str_contains($userAgent, strtolower($crawlerUserAgent))) {
             $shouldPrerender = true;
         }
     }
     if ($bufferAgent) {
         $shouldPrerender = true;
     }
     if (!$shouldPrerender) {
         return false;
     }
     return true;
 }
 public function add(Request $request)
 {
     if ($request->isMethod('post')) {
         $input = $request->all();
         $fileName = null;
         if (!empty($input['image_url'])) {
             $file = $input['image_url'];
             $extension = $file->getClientOriginalExtension();
             $fileName = rand(11111, 99999) . '.' . $extension;
             $file->move("admin/slaider", $fileName);
             $destinationPath = "admin/slaider";
             $fileThumb = "450x250_" . $fileName;
             $img = Image::make("{$destinationPath}/{$fileName}")->resize(450, 250);
             $img->save("{$destinationPath}/{$fileThumb}");
         }
         $slaider = new Slaider();
         $slaider->translateOrNew(LaravelLocalization::setLocale())->name = $input['name'];
         $slaider->translateOrNew(LaravelLocalization::setLocale())->description = $input['description'];
         $slaider->link = $input['link'];
         $slaider->image_url = $fileName;
         $slaider->save();
         return redirect(LaravelLocalization::setLocale() . DIRECTORY_SEPARATOR . 'admin-slaider');
     }
     return view('admin.slaider.add');
 }
 /**
  * 获得指定搜索下面信息
  *
  * @param Request $request
  * @author yangyifan <yangyifanphp@gmail.com>
  */
 public function postSearchInfo(Request $request)
 {
     if ($request->isMethod('post')) {
         $data = SearchModel::getSearchInfo($request->get('id', 1));
         return !empty($data) ? $this->response(200, 'success', $data, false) : $this->response(400, trans('response.search_error'), [], false);
     }
 }