コード例 #1
0
 public function storeWeb(Request $request)
 {
     //Process Gravity Form Fields to match Database
     $input = $request->all();
     $input['type'] = 'Sailing School';
     !empty($input['dest_grenada']) ? $input['destination'] = 'Grenada' : ($input['destination'] = '');
     !empty($input['dest_stvincent']) ? $input['destination'] .= ' St. Vincent' : $input['destination'];
     !empty($input['boat_monohull']) ? $input['boat_type'] = 'Monohull' : ($input['boat_type'] = '');
     !empty($input['boat_catamaran']) ? $input['boat_type'] .= ' Catamaran' : $input['boat_type'];
     !empty($input['newsletter']) ? $input['newsletter'] = 1 : ($input['newsletter'] = 0);
     Log::info($input);
     $user = User::where('email', $input['email'])->first();
     if (!$user) {
         $this->user->store($request);
         $user = User::where('email', $input['email'])->first();
     }
     if (!$user->types()->where('user_types.id', 1)->first()) {
         $user->types()->attach([1]);
     }
     //@TODO: Use this form to capture inquiries for Charters, Boat Buying and Selling
     $input['user_id'] = $user->id;
     $inquiry = Inquiry::create(['user_id' => $input['user_id'], 'type' => $input['type'], 'destination' => $input['destination'], 'boat_type' => $input['boat_type'], 'notes' => $input['notes']]);
     //Create a Note
     $note = $user->notes()->create(['note_date' => Carbon::now(), 'title' => 'Website Inquiry', 'note_type' => 'Inquiry', 'create_user_id' => User::where('email', '*****@*****.**')->first()->id, 'note' => $input['notes']]);
     //Schedule Initial Inquiry Response for 37 Minutes after Inquiry
     $this->scheduleInitialResponse($user);
     //Fire Prospect Inquiry Scheduled Responses.
     \Event::fire(new ScheduleResponse($inquiry));
     //Mail::raw('Test Booking',function($message){$message->to('*****@*****.**'); $message->from('*****@*****.**');});
     return $request->all();
 }
コード例 #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('inquiries')->delete();
     for ($i = 0; $i < count($this->items); $i++) {
         $row = array_combine(['user_id', 'car_id', 'model', 'price_from', 'price_to', 'year_from', 'year_to', 'city_id', 'metro', 'street', 'name', 'phone', 'information'], $this->items[$i]);
         Inquiry::create($row);
     }
 }
コード例 #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required']);
     $item = Inquiry::create($request->all());
     if ($request->has('carinfo')) {
         $carinfoFilled = false;
         foreach ($request->get('carinfo') as $value) {
             if ($value) {
                 $carinfoFilled = true;
                 break;
             }
         }
         if ($carinfoFilled) {
             $carinfo = new Carinfo();
             $carinfo->fill($request->get('carinfo'));
             $item->carinfo()->save($carinfo);
         }
     }
     Flash::success("Запись - {$item->id} сохранена");
     return redirect(route('admin.inquiries.index'));
 }
コード例 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $user = User::find(Auth::user()->id);
     $rules = ['car_id' => 'required', 'city_id' => 'required', 'name' => 'required', 'phone' => 'required|min:7'];
     $messages = ['car_id.required' => 'Выберите марку автомобиля', 'city_id.required' => 'Выберите город', 'name.required' => 'Укажите свое имя', 'phone.required' => 'Укажите свой номер телефона', 'phone.min' => 'Укажите свой номер телефона'];
     $validator = Validator::make($request->all(), $rules, $messages);
     $validator->after(function ($validator) use($request) {
         if ($request->get('price_to') && $request->get('price_from') > $request->get('price_to')) {
             $validator->errors()->add('price_invalid', 'Значение "Цена, от" не может быть больше значения "Цена, до"');
         }
         if ($request->get('year_to') && $request->get('year_from') > $request->get('year_to')) {
             $validator->errors()->add('year_invalid', 'Значение "Год выпуска, от" не может быть больше значения "Год выпуска, до"');
         }
     });
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $item = Inquiry::create($request->all() + ['user_id' => $user->id]);
     if ($request->has('carinfo')) {
         $carinfoFilled = false;
         foreach ($request->get('carinfo') as $value) {
             if ($value) {
                 $carinfoFilled = true;
                 break;
             }
         }
         if ($carinfoFilled) {
             Carinfo::create($request->get('carinfo') + ['inquiry_id' => $item->id]);
         }
     }
     $inquiry = Inquiry::with('car', 'carinfo', 'city')->findOrFail($item->id);
     if ($request->ajax()) {
         return response()->json(['status' => 'success', 'message' => 'Объявление сохранено', 'inquiry' => $inquiry]);
     }
     Flash::success("Запись - {$inquiry->id} сохранена");
     return redirect('/');
 }
コード例 #5
0
ファイル: InquiryController.php プロジェクト: w1lliams/sh
 public function create(Request $request)
 {
     $this->validate($request, ['name' => 'required|max:255']);
     Inquiry::create($request->all());
     return redirect()->route('admin::inquiry');
 }
コード例 #6
0
ファイル: ContactController.php プロジェクト: evendev/mcmills
 public function postIndex(ContactFormRequest $request)
 {
     Inquiry::create($request->all());
     $url = $request->input('url');
     return redirect($url)->with('message.success', "<strong>Success!</strong> Thank you for contacting us. We'll be in touch very soon.");
 }