Esempio n. 1
0
 /**
  * Supplier create form processing.
  *
  * @return Redirect
  */
 public function postCreate()
 {
     // get the POST data
     $new = Input::all();
     // Create a new supplier
     $supplier = new Supplier();
     // Save the location data
     $supplier->name = e(Input::get('name'));
     $supplier->address = e(Input::get('address'));
     $supplier->address2 = e(Input::get('address2'));
     $supplier->city = e(Input::get('city'));
     $supplier->state = e(Input::get('state'));
     $supplier->country = e(Input::get('country'));
     $supplier->zip = e(Input::get('zip'));
     $supplier->contact = e(Input::get('contact'));
     $supplier->phone = e(Input::get('phone'));
     $supplier->fax = e(Input::get('fax'));
     $supplier->email = e(Input::get('email'));
     $supplier->notes = e(Input::get('notes'));
     $supplier->url = $supplier->addhttp(e(Input::get('url')));
     $supplier->user_id = Auth::user()->id;
     if (Input::file('image')) {
         $image = Input::file('image');
         $file_name = str_random(25) . "." . $image->getClientOriginalExtension();
         $path = public_path('uploads/suppliers/' . $file_name);
         Image::make($image->getRealPath())->resize(300, null, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         })->save($path);
         $supplier->image = $file_name;
     }
     // Was it created?
     if ($supplier->save()) {
         // Redirect to the new supplier  page
         return redirect()->to("admin/settings/suppliers")->with('success', trans('admin/suppliers/message.create.success'));
     }
     return redirect()->back()->withInput()->withErrors($supplier->getErrors());
 }