예제 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['holidate' => 'unique:holiday']);
     Holiday::create($request->all());
     flash('Successfully added.');
     return redirect('holiday');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = $request->all();
     // delta tra data inizio e fine
     $inizio = new Carbon($input['start']);
     $fine = new Carbon($input['end']);
     $input['days'] = date_diff($fine, $inizio)->format('%d');
     $vacanza = Holiday::create($input);
     /// passo identificativo post salvato x hasmany
     // multiple upload
     foreach (\Input::file('image') as $photo) {
         if (\Input::hasFile('image')) {
             $file = $photo;
             //photo perchè Inputfile lo definisco nel foreach
             $imagename = 'cycling_passion_' . time() . '-' . $vacanza['slug'] . '-' . $file->getClientOriginalName();
             $file->move(public_path() . '/uploads/holiday/', $imagename);
             $path = public_path('uploads/holiday/thumb/' . $imagename);
             $image = \Image::make(public_path('/uploads/holiday/') . $imagename)->resize(200, 100)->save($path);
             // fit invece di resize x ritagliare
             $h_gallery = new HolidayGallery();
             $h_gallery['holiday_id'] = $vacanza['id'];
             $h_gallery['image'] = $imagename;
             $h_gallery->save();
         }
     }
     // endforeach
     return redirect('/admin/holidays')->with('message', 'Vacanza Member created');
 }
예제 #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     if ($this->validator($request->all())->fails()) {
         flash()->error("Please fill the missing fields.");
         return redirect()->back()->withInput();
     }
     $holiday = Holiday::create($request->all());
     if ($holiday) {
         flash($holiday->title . ' successfully added to holidays list.');
         return redirect()->to('/holidays');
     } else {
         flash()->error("Holiday not added successfully!");
         return redirect()->back();
     }
 }