コード例 #1
2
 public function adAnnounce(Request $request)
 {
     $data = ["name" => $request->name, "email" => $request->email, "phone" => $request->phone, "description" => $request->description, "chambres" => $request->chambres, "pieces" => $request->pieces, "surface" => $request->surface, "prix" => $request->prix, "aid" => $request->aid];
     $file = null;
     $data["email"] = $request->email;
     $input = array('image' => Input::file('image'));
     $rules = array('image' => 'image');
     $validator = Validator::make($input, $rules);
     if ($validator->fails()) {
         return response()->json(['data' => 'Fichier invalid', 'state' => false]);
     } else {
         if ($request->hasFile('image')) {
             $file = $request->file('image');
             $filename = $file->getClientOriginalName();
             $destinationPath = public_path() . '/uploads/ad';
             $file->move($destinationPath, $filename);
             $data['image'] = asset('uploads/ad/' . $filename);
             $manager = new \MongoDB\Driver\Manager('mongodb://localhost:27017');
             $collection = new \MongoDB\Collection($manager, 'builders', 'ads');
             $stat = ['email' => $request->email, 'data' => $data, 'created' => new \DateTime("now")];
             try {
                 $collection->insertOne($stat);
             } catch (\Exception $e) {
                 return response()->json(['state' => false]);
             }
             return response()->json(['data' => $data, 'state' => true]);
         }
     }
 }
コード例 #2
0
 public function postCreate()
 {
     $rules = array('name' => 'required', 'cover_image' => 'required|image');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::route('create_album_form')->withErrors($validator)->withInput();
     }
     // end if
     $file = Input::file('cover_image');
     $random_name = str_random(8);
     $destinationPath = 'albums/';
     $extension = $file->getClientOriginalExtension();
     $filename = $random_name . "." . $extension;
     $uploadSuccess = Input::file('cover_image')->move($destinationPath, $filename);
     $album = Album::create(array('name' => Input::get('name'), 'description' => Input::get('description'), 'cover_image' => $filename, 'user_id' => \Sentry::getUser()->id));
     /*
           $filename = Input::file('cover_image');
           $random_name = str_random(8);
           $destinationPath = 'albums/';
           $extension = $filename->getClientOriginalExtension();
           $uploadSuccess = Input::file('cover_image')->move($destinationPath, $filename . "." . $extension);
           $album = Album::create(array(
             'name' => Input::get('name'),
             'description' => Input::get('description'),
             'cover_image' => $filename . "." . $extension,
           ));
     */
     return Redirect::route('show_album', array('id' => $album->id));
 }
コード例 #3
0
ファイル: PageController.php プロジェクト: GHarutyunyan/cms
 /**
  * Edit page
  *
  * @param Request $request
  * @param int $id
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
  */
 public function edit(Request $request, $id = 0)
 {
     if ($request->isMethod('post')) {
         $rules = ['name' => 'required|unique:categories,name,' . $id, 'alias' => 'required|unique:categories,alias,' . $id, 'content' => 'required'];
         Validator::make($request->all(), $rules)->validate();
         $page = Category::find($id);
         $page->name = $request->input('name');
         $page->alias = $request->input('alias');
         $page->meta_keys = $request->input('meta_keys');
         $page->meta_desc = $request->input('meta_desc');
         if ($request->has('parent')) {
             $page->parent_id = $request->input('parent');
             $page->type = 2;
         } else {
             $page->type = 1;
         }
         $page->publish = $request->has('publish');
         $page->save();
         $page_content = $page->content;
         $page_content->content = $request->input('content');
         $page_content->save();
         return redirect()->route('pages');
     } else {
         $page = Category::getCategoryById($id);
         if (empty($page)) {
             return redirect()->back();
         } else {
             $pages = Category::getParentCategories($id);
             return view('admin.page.edit', compact('pages', 'page'));
         }
     }
 }
コード例 #4
0
 public function test_only_specific_locales_required()
 {
     $validator = Validator::make(['name' => ['en' => 'One', 'sp' => 'Uno']], ['name.en' => 'required']);
     $this->assertTrue($validator->passes());
     $validator = Validator::make(['name' => ['sp' => 'Uno']], ['name.en' => 'required']);
     $this->assertFalse($validator->passes());
 }
コード例 #5
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');
 }
コード例 #6
0
 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]);
 }
コード例 #7
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store($jenis)
 {
     if ($jenis == 'kategori') {
         $rules = array("judul" => "required", "status" => "required");
         $data = new Kategori();
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->passes()) {
             $data->judul = strtolower(Input::get('judul'));
             $data->aktif = Input::get('status');
             $data->save();
             return redirect('/bos/kategori');
         } else {
             return back()->withInput()->with('message', 'Lengkapi data terlebih dahulu');
         }
     }
     if ($jenis == 'artikel') {
         $rules = array("judul" => "required");
         $valid = Validator::make(Input::all(), $rules);
         if ($valid->passes()) {
             $data = new Artikel();
             $data->judul = ucwords(Input::get('judul'));
             $data->slug = strtolower(str_replace(" ", "-", trim(Input::get('judul'))));
             $data->kategori = Input::get('kategori');
             $data->aktif = Input::get('aktif');
             $data->isi = Input::get('isi');
             $data->save();
             return redirect('/bos/artikel');
         } else {
             return back()->withInput()->with('message', 'Lengkapi data anda terlebih dahulu');
         }
     }
 }
コード例 #8
0
ファイル: UserController.php プロジェクト: jarriaga/endaroo
 /**
  * This function create a new user after validate the request with the class NewUserRequest
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function createUser(Request $request)
 {
     switch ($request->input('type')) {
         //only for facebook user
         case 'facebook':
             $rules = ['email' => 'email|required', 'firstname' => 'required', 'facebook_id' => 'required', 'token' => 'required'];
             $validator = Validator::make($request->all(), $rules);
             if ($validator->fails()) {
                 return response()->json($validator->errors(), 400);
             }
             return $this->loginFacebookUser($request);
             break;
             //For every new user
         //For every new user
         default:
             $rules = ['email' => 'email|required', 'firstname' => 'required', 'password' => 'required'];
             $validator = Validator::make($request->all(), $rules);
             if ($validator->fails()) {
                 return response()->json($validator->errors(), 400);
             }
             $user = new User();
             $user->fill($request);
             if (!$user->save()) {
                 return response()->json('Error, the user was not created', 400);
             }
             return response()->json('success', 200);
     }
 }
 public function postRegister()
 {
     $rules = ['email' => 'required|email', 'ngo-name' => 'required|min:5', 'ngo-desc' => 'string|min:20', 'ngo-email' => 'required|email', 'ngo-phone' => 'required|min:7'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return redirect('/envy/auth/register')->withErrors($validator)->withInput();
     } else {
         $user = User::where('user_email', Input::get('email'))->first();
         if ($user && !$user->is_user_ngo) {
             $user->is_user_ngo = true;
             $user->save();
             $ngo = new Ngo();
             $ngo->user_id = $user->user_id;
             $ngo->ngo_name = Input::get('ngo-name');
             $ngo->ngo_email = Input::get('ngo-email');
             $ngo->ngo_phone = Input::get('ngo-phone');
             $ngo->ngo_description = Input::get('ngo-desc');
             $ngo->save();
         }
         // $user = new User;
         // $user->user_name = Input::get('name');
         // $user->user_email = Input::get('email');
         // $user->password = Hash::make(Input::get('password'));
         // $user->is_user_ngo = true;
         // $user->save();
         return redirect('/envy/auth/login');
     }
 }
コード例 #10
0
 public function sendContactForm()
 {
     $is_mail_sent = false;
     // Get data
     $lastname = post('lastname');
     $firstname = post('firstname');
     $email = post('email');
     $subject = post('subject');
     $message_body = post('message');
     $inputs = ['lastname' => $lastname, 'firstname' => $firstname, 'email' => $email, 'subject' => $subject, 'message' => $message_body];
     $rules = ['lastname' => 'required', 'firstname' => 'required', 'email' => 'required|email', 'subject' => 'required', 'message' => 'required'];
     $messages = ['lastname.required' => 'contactForm.lastname_required', 'firstname.required' => 'contactForm.firstname_required', 'email.required' => 'contactForm.email_required', 'email.email' => 'contactForm.email_invalid', 'subject.required' => 'contactForm.subject_required', 'message.required' => 'contactForm.message_required'];
     // Data Validation
     $validator = Validator::make($inputs, $rules, $messages);
     if ($validator->fails()) {
         $messages = $validator->messages();
         $this->page["inputs"] = $inputs;
         $this->page["messages"] = $messages;
         return;
     }
     $data = compact('firstname', 'lastname', 'email', 'subject', 'message_body');
     $is_mail_sent = Mail::send('algad.bootstrap::mail.contactform.message', $data, function ($message) use($firstname, $lastname, $email) {
         $message->from($email, $firstname . " " . $lastname);
         $message->addReplyTo($email, $lastname . ' ' . $firstname);
         $message->to($this->getProperty('recipient_email'));
     });
     if ($is_mail_sent) {
         $this->page["contact_success_message"] = $this->getProperty('email_sent_confirmation');
     } else {
         $this->page["contact_error_message"] = $this->getProperty('email_sent_failed');
     }
 }
コード例 #11
0
 public function postEdit(Request $request)
 {
     $validator = Validator::make($request->all(), ['first_name' => 'required', 'last_name' => 'required', 'gender' => ['required', 'in:male,female'], 'password' => 'min:6', 'martial_status' => ['in:single,engaged,married']]);
     if ($validator->fails()) {
         return redirect()->back()->withInput()->withErrors($validator);
     }
     if ($request->has('password') && $request->has('password_confirmation')) {
         if ($request->password === $request->password_confirmation) {
             Auth::user()->password = Hash::make($request->password);
             Auth::user()->save();
         } else {
             return redirect()->back()->withInput()->with('errors', ['Passwords does not match.']);
         }
     }
     $user = Auth::user();
     $user->first_name = $request->first_name;
     $user->last_name = $request->last_name;
     $user->gender = $request->gender;
     $user->birth_date = $request->has('birth_date') ? $request->birth_date : null;
     $user->phone = $request->has('phone') ? $request->phone : null;
     $user->bio = $request->has('bio') ? $request->bio : null;
     $user->marital_status = $request->has('marital_status') ? $request->marital_status : null;
     $user->save();
     return redirect()->route('profile.edit')->with('info', 'your profile has been updated');
 }
コード例 #12
0
ファイル: OrderController.php プロジェクト: venomir/tc
 public function postCreate()
 {
     $validator = Validator::make(Input::all(), Order::$rules);
     if ($validator->passes()) {
         $order = new Order();
         $order->user_id = Auth::id();
         $order->delivery_address = Input::get('delivery_address');
         $order->sum = Cart::total();
         $order->payment_type = Input::get('payment_type');
         $order->save();
         foreach (Cart::content() as $cart_item) {
             $order_product = new OrderProduct();
             $order_product->order_id = $order->id;
             $order_product->product_id = $cart_item->id;
             $order_product->qty = $cart_item->qty;
             $order_product->sum = $cart_item->price;
             $order_product->save();
         }
         Cart::destroy();
         if ($order->payment_type == 0) {
             //pay card
             return Redirect::to('order/pay');
         }
         return Redirect::to('cart/confirmed')->with('message', 'Заказ оформлен.');
     }
     return Redirect::to('cart/confirm')->with('message', 'Проверьте корректность заполнения полей!')->withErrors($validator)->withInput();
 }
コード例 #13
0
 public function create()
 {
     $p = new Post();
     $inputs = \Input::all();
     $rules = array('title' => 'required', 'metadescription' => 'required', 'content' => 'required', 'tags' => 'required', 'photo' => 'required', 'category' => 'required');
     $validation = Validator::make($inputs, $rules);
     if ($validation->fails()) {
         return var_dump($validation->errors());
     } else {
         $p->title = \Input::get('title');
         $p->metadescription = \Input::get('metadescription');
         $p->content = \Input::get('content');
         $p->tags = \Input::get('tags');
         $p->category = \Input::get('category');
         //		$p->photo = \Input::get('photo');
         if ($file = \Input::file('photo')) {
             //getting timestamp
             $timestamp = str_replace([' ', ':'], '-', Carbon::now()->toDateTimeString());
             $name = $timestamp . '-' . $file->getClientOriginalName();
             $file->move(public_path() . '/uploads/', $name);
             $p->photo = '/uploads/' . $name;
         } else {
             return 'Pic Not uploaded Properly! Press Back Button';
         }
         $p->save();
         return \Redirect::route('adminsite')->with('alert', 'Publication created successfully!');
     }
 }
コード例 #14
0
ファイル: Configuracoes.php プロジェクト: safaricco/admfw
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $validacao = Validator::make($request->all(), ['nome_site' => 'required|string', 'logo' => 'image|mimes:jpg,jpeg,png,gif', 'logo_footer' => 'image|mimes:jpg,jpeg,png,gif']);
     if ($validacao->fails()) {
         return redirect('admin/configuracoes/site')->withErrors($validacao)->withInput();
     } else {
         try {
             $config = Configuracao::find($id);
             $config->nome_site = $request->nome_site;
             if ($request->hasFile('logo')) {
                 if ($request->file('logo')->isValid()) {
                     $nomeOriginal = $request->file('logo')->getClientOriginalName();
                     $novoNome = md5(uniqid($nomeOriginal)) . '.' . $request->file('logo')->getClientOriginalExtension();
                     $request->file('logo')->move('uploads/logo', $novoNome);
                     $config->logo = $novoNome;
                 }
             }
             if ($request->hasFile('logo_footer')) {
                 if ($request->file('logo_footer')->isValid()) {
                     $nomeOriginal = $request->file('logo_footer')->getClientOriginalName();
                     $novoNome = md5(uniqid($nomeOriginal)) . '.' . $request->file('logo_footer')->getClientOriginalExtension();
                     $request->file('logo_footer')->move('uploads/logo', $novoNome);
                     $config->logo_footer = $novoNome;
                 }
             }
             $config->save();
             session()->flash('flash_message', 'Registro atualizado com sucesso!');
         } catch (\Exception $e) {
             LogR::exception($config, $e);
             session()->flash('flash_message', 'Ops!! Ocorreu algum problema!. ' . $e->getMessage());
         }
         return Redirect::back();
     }
 }
コード例 #15
0
 public function login(Request $request)
 {
     $input = $request->json()->all();
     $validator = Validator::make($input, ['email' => 'required|email', 'password' => 'required', 'deviceId' => 'required']);
     if ($validator->fails()) {
         $error = $validator->errors()->all();
         return response()->json(['errorMessage' => [$error]], 404);
     }
     $deviceId = $input['deviceId'];
     $result = DB::table('users')->where('email', $input['email'])->first();
     if ($result && Hash::check($input['password'], $result->password)) {
         $res = DB::table('tokens')->where('deviceId', $deviceId)->first();
         if ($res) {
             $token = Token::find($res->id);
             $token->token = bin2hex(openssl_random_pseudo_bytes(64));
             $token->save();
         } else {
             DB::table('tokens')->insert(['token' => bin2hex(openssl_random_pseudo_bytes(64)), 'userId' => $result->id, 'deviceId' => $deviceId]);
         }
         $token = DB::table('tokens')->select('token')->where('userId', $result->id)->where('deviceId', $deviceId)->first();
         if ($token) {
             return response()->json($token);
         } else {
             return response()->json(['errorMessage' => 'login failed'], 404);
         }
     } else {
         return response()->json(['errorMessage' => 'this user not found'], 404);
     }
 }
コード例 #16
0
ファイル: TerritorialArea2.php プロジェクト: syscover/pulsar
 public static function validate($data, $specialRules = [])
 {
     if (isset($specialRules['idRule']) && $specialRules['idRule']) {
         static::$rules['id'] = 'required|between:1,10';
     }
     return Validator::make($data, static::$rules);
 }
コード例 #17
0
 /**
  * save gallery in the database
  */
 public function saveGallery(Request $request)
 {
     // POST request requires the 'Request' object as parameter
     // validate the request throught the validation rules
     // 1st argument: the request (specifically, all request)
     // 2nd argument is the validation rules array based on the name of the user input and piped with other rules
     // 3rd argument is optionally used to override the default error message that already comes with Validator
     $validator = Validator::make($request->all(), ['gallery_name' => 'required|min:3']);
     // take action if validation fails
     // this will redirect user back to the gallery list but will include the errors and the user's previous input
     // use the $errors variable on the html page so that you can output using a foreach loop
     // use the html <input value="{{ old('gallery_name') }}"> to catch the previous input for display
     if ($validator->fails()) {
         return redirect('gallery/list')->withErrors($validator)->withInput();
         // include user's previous input
     }
     // request validation has passed the validation rules at this point, now proceed with saving gallery
     $gallery = new Gallery();
     // save a new gallery
     $gallery->name = $request->input('gallery_name');
     // 'gallery_name' is the name of the html input field
     $gallery->created_by = 1;
     // hard coded for now
     $gallery->published = 1;
     // hard coded for now
     $gallery->save();
     // save the user's input into the database
     return redirect()->back();
     // redirect user back to the previous page (page where the user saves a gallery)
 }
コード例 #18
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(), ['file' => 'mimes:pdf', 'year' => 'required']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors(['file' => 'ไฟล์จะต้องเป็น .pdf เท่านั้น'])->withInput();
     }
     //example of delete exist file
     $existMeetingReport = MeetingReport::where('year', '=', $request->get('year'))->where('no', '=', $request->get('no'))->first();
     if ($existMeetingReport != null) {
         $filename = base_path() . '/public/uploads/Meeting-reports/' . $request->get('year') . '/' . $existMeetingReport->file_path;
         if (File::exists($filename)) {
             File::delete($filename);
         }
         MeetingReport::destroy($existMeetingReport->id);
     }
     if (Input::file('file')->isValid()) {
         $filePath = $request->get('no') . '.pdf';
         if (Input::file('file')->move(base_path() . '/public/uploads/Meeting-reports/' . $request->get('year'), $filePath)) {
             $meetingReport = new MeetingReport();
             $meetingReport->file_path = $filePath;
             $meetingReport->year = $request->get('year');
             $meetingReport->no = $request->get('no');
             $meetingReport->save();
             return redirect('/admin/management');
         } else {
             return redirect()->back()->withErrors(['error_message' => 'ไฟล์อัพโหลดมีปัญหากรุณาลองใหม่อีกครั้ง']);
         }
     }
 }
コード例 #19
0
ファイル: CustomField.php プロジェクト: syscover/pulsar
 public static function validate($data, $specialRules = [])
 {
     if (isset($specialRules['group'])) {
         static::$rules['group'] = '';
     }
     return Validator::make($data, static::$rules);
 }
コード例 #20
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(), ['file' => 'mimes:pdf', 'name' => 'max:100']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors(['file' => 'ไฟล์จะต้องเป็น .pdf เท่านั้น'])->withInput();
     }
     if (Input::file('file')->isValid()) {
         $filePath = date('Ymd_His') . '.pdf';
         if (Input::file('file')->move(base_path() . '/public/uploads/Announces/Announce-' . $request->get('year'), $filePath)) {
             //example of delete exist file
             $announceList = Announce::all();
             if (sizeof($announceList) != 0) {
                 $lastAnnounce = $announceList[sizeof($announceList) - 1];
                 $filename = base_path() . '/public/uploads/Announces/Announce-/' . $request->get('year') . '/' . $lastAnnounce->file_path;
                 if (File::exists($filename)) {
                     File::delete($filename);
                 }
                 //                    $oldAnnounce = Announce::findOrNew($lastAnnounce->id);
                 $lastAnnounce = DB::table('announces')->where('year', $request->get('year'))->first();
                 //                    dd($lastAnnounce);die;
                 if ($lastAnnounce != null) {
                     Announce::destroy($lastAnnounce->id);
                 }
             }
             $announce = new Announce();
             $announce->file_path = $filePath;
             $announce->year = $request->get('year');
             $announce->save();
             return redirect('/announces');
         } else {
             return redirect()->back()->withErrors(['error_message' => 'ไฟล์อัพโหลดมีปัญหากรุณาลองใหม่อีกครั้ง']);
         }
     }
 }
コード例 #21
0
 public function upload($form_data)
 {
     $validator = Validator::make($form_data, Image::$rules, Image::$messages);
     if ($validator->fails()) {
         return Response::json(['error' => true, 'message' => $validator->messages()->first(), 'code' => 400], 400);
     }
     $photo = $form_data['file'];
     $originalName = $photo->getClientOriginalName();
     $originalNameWithoutExt = substr($originalName, 0, strlen($originalName) - 4);
     $filename = $this->sanitize($originalNameWithoutExt);
     $allowed_filename = $this->createUniqueFilename($filename);
     $filenameExt = $form_data['id_auxiliar'] . $allowed_filename . '.jpg';
     $uploadSuccess1 = $this->original($photo, $filenameExt);
     $uploadSuccess2 = $this->icon($photo, $filenameExt);
     if (!$uploadSuccess1 || !$uploadSuccess2) {
         return Response::json(['error' => true, 'message' => 'Server error while uploading', 'code' => 500], 500);
     }
     $sessionImage = new Image();
     $sessionImage->filename = $form_data['id_auxiliar'] . $allowed_filename . '.jpg';
     $sessionImage->original_name = $originalName;
     $sessionImage->id_catalogo_fotografia = $form_data['id_catalogo_fotografia'];
     $sessionImage->id_usuario_servicio = $form_data['id_usuario_servicio'];
     $sessionImage->id_auxiliar = $form_data['id_auxiliar'];
     $sessionImage->estado_fotografia = 1;
     $sessionImage->save();
     return Response::json(['error' => false, 'code' => 200], 200);
 }
コード例 #22
0
 public function sendEnquireMail()
 {
     $name = Input::get('name');
     $email = Input::get('email');
     $mobile = Input::get('mobile');
     $message2 = Input::get('message');
     $result = array();
     $validation = $validator = Validator::make(array('Name' => $name, 'email' => $email, 'Mobile' => $mobile, 'Message' => $message2), array('Name' => 'required', 'email' => 'required|email', 'Mobile' => 'required|numeric', 'Message' => 'required'));
     if ($validation->fails()) {
         $result['status'] = 'Failure';
         $result['message'] = 'Fill all fields with valid values';
         return response()->json($result);
     }
     $data['name'] = $name;
     $data['email'] = $email;
     $data['mobile'] = $mobile;
     $data['message2'] = $message2;
     Mail::send('mail.enquire', $data, function ($message1) use($data) {
         $message1->from($data['email'], $data['name']);
         $message1->to('*****@*****.**', 'Enquiry - Oxoniya')->subject('Enquiry - Oxoniya');
     });
     $result['status'] = 'Success';
     $result['message'] = 'Contact Form Successfully Submitted';
     return response()->json($result);
 }
コード例 #23
0
 private function validate($data)
 {
     $v = Validator::make($data, array("path" => "required", "caption" => "", "extension" => "required"));
     if ($v->fails()) {
         throw new \Exception("Please pass the required fields.");
     }
 }
コード例 #24
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //$this->validate($request, ['name' => 'required']); // Uncomment and modify if needed.
     $valoriformular = array('HotelID' => $request->HotelID, 'DetaliiScurte' => $request->DetaliiScurte, 'DetaliiComplete' => $request->DetaliiComplete, 'ServiciiIncluse' => $request->ServiciiIncluse, 'ExtraServicii' => $request->ExtraServicii, 'DataExpirare' => $request->DataExpirare);
     $insertformular = Ofertestatices::create($valoriformular);
     $id = $insertformular->id;
     $files = Input::file('DocOferta');
     $file_count = count($files);
     $uploadcount = 0;
     foreach ($files as $file) {
         $rules = array('file' => 'required');
         $validare = Validator::make(array('file' => $file), $rules);
         if ($validare->passes()) {
             $destinationPath = 'oferte';
             // upload path
             $extension = $file->getClientOriginalExtension();
             // getting image extension
             $fileName = rand(11111, 99999) . '.' . $extension;
             // renameing image
             $upload = $file->move($destinationPath, $fileName);
             $valoridoc = array('idOferta' => $id, 'url' => 'oferte/' . $fileName);
             Documente::create($valoridoc);
             $uploadcount++;
         }
     }
     if ($uploadcount == $file_count) {
         return redirect("admin/oferte");
     }
 }
コード例 #25
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('/');
         }
     }
 }
コード例 #26
0
ファイル: ValidateTrait.php プロジェクト: johnjjung/support
 /**
  * Validate the form submission.
  *
  * @param array $data
  *
  * @throws FormValidationException
  */
 protected function validate(array $data)
 {
     $validator = Validator::make($data, $this->rules);
     if ($validator->fails()) {
         throw new FormValidationException('Fix errors in the form below.', $validator);
     }
 }
コード例 #27
0
ファイル: UserController.php プロジェクト: DevTrad/tradbiz
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     // validate the inputs
     $validator = Validator::make($data = $request->all(), $this->user->rules);
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     }
     // fill the user with the inputs and save to DB
     unset($data['password_conf']);
     $this->user->fill($data);
     $this->user->password = Hash::make($this->user->password);
     $maxid = User::all()->max('id');
     if ($maxid == 0) {
         $this->user->account_type = 99;
     } else {
         $this->user->account_type = 1;
     }
     $this->user->active = 0;
     $this->user->activation_token = uniqid();
     $this->user->save();
     // send activation email
     $this->user->sendActivationEmail();
     Auth::logout();
     return view('notifications.accountsuccess', ['title' => 'Account Created!']);
 }
コード例 #28
0
 public function update(Request $request, $id = 0)
 {
     if ($id) {
         try {
             $user = User::findOrFail($id);
         } catch (ModelNotFoundException $e) {
             $request->flash();
             return redirect('admin/user', ['act' => $id, 'errors' => $e]);
         }
     } else {
         return redirect('admin/user');
     }
     $data = ['email' => $request->input('email'), 'name' => $request->input('name'), 'slug' => $request->input('slug')];
     $validator = Validator::make($data, ['name' => 'required', 'email' => "required|email|unique:users,email,{$id}", 'slug' => 'required|exists:roles,id']);
     if ($validator->fails()) {
         $request->flashExcept('password');
         return view('admin.user.show', ['act' => $id, 'user' => [], 'errors' => $validator->messages(), 'roles' => Role::all()]);
     } else {
         $user->email = $data['email'];
         $user->name = $data['name'];
         if ($request->input('password')) {
             $user->password = bcrypt($request->input('password'));
         }
         $user->detachAllRoles();
         $user->attachRole($request->input('slug'));
         $user->save();
         return redirect('admin/user');
     }
 }
コード例 #29
0
 /**
  * @param $command
  * @throws EntryValidationException
  */
 protected function performValidation($command)
 {
     $validator = Validator::make($command->input, $this->rules);
     if ($validator->fails()) {
         throw new EntryValidationException($validator);
     }
 }
コード例 #30
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(), ['file' => 'mimes:pdf', 'name' => 'max:100']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors(['file' => 'ไฟล์จะต้องเป็น .pdf เท่านั้น'])->withInput();
     }
     $riskManagements = RiskManagement::where('year', '=', $request->get('year'))->where('period', '=', $request->get('period'))->get();
     if (sizeof($riskManagements) > 0) {
         foreach ($riskManagements as $riskManagement) {
             $filename = base_path() . '/public/uploads/Risk-Management/' . $request->get('year') . '/' . $request->get('period') . '/' . $riskManagement->file_path;
             if (File::exists($filename)) {
                 File::delete($filename);
             }
             RiskManagement::destroy($riskManagement->id);
         }
     }
     if (Input::file('file')->isValid()) {
         $filePath = date('Ymd_His') . '.pdf';
         if (Input::file('file')->move(base_path() . '/public/uploads/Risk-Management/' . $request->get('year') . '/' . $request->get('period'), $filePath)) {
             //example of delete exist file
             $riskManagement = new RiskManagement();
             $riskManagement->file_path = $filePath;
             $riskManagement->year = $request->get('year');
             $riskManagement->period = $request->get('period');
             $riskManagement->save();
             return redirect('/admin/management');
         } else {
             return redirect()->back()->withErrors(['error_message' => 'ไฟล์อัพโหลดมีปัญหากรุณาลองใหม่อีกครั้ง']);
         }
     }
 }