Пример #1
0
 public function postForm(FormProviderRequest $request)
 {
     $id = $request->input('id', NULL);
     $message = "Se ingresó correctamente el proveedor.";
     $modelProvider = new PrProviders();
     $data = $request->all();
     if ($request->hasfile('picture_face')) {
         $validator = Validator::make($request->all(), ['picture_face' => ['mimes:jpg,png,jpeg']]);
         if ($validator->fails()) {
             return redirect(action('Admin\\ProviderController@postForm'))->withErrors($validator)->withInput();
         }
         $file = $request->file('picture_face');
         $nameimage = date('Ymdhis') . rand(1, 1000) . '.' . $file->getClientOriginalExtension();
         $file->move(public_path() . "/dinamic/provider/", $nameimage);
         $pathImage = '/dinamic/provider/' . $nameimage;
         $data['picture_face'] = $pathImage;
     }
     try {
         if (isset($id) && $id != '') {
             $provider = $modelProvider->find($id);
             $provider->fill($data);
             $provider->save();
             $message = "Se actualizó la información del proveedor de manera correcta.";
         } else {
             $modelProvider->fill($data);
             $modelProvider->save($data);
         }
     } catch (Exception $ex) {
     }
     $url = isset($data['modulo']) ? str_replace("|", "/", $data['modulo']) : self::NAMEC;
     return redirect('admpanel/' . $url)->with('messageSuccess', $message);
 }
Пример #2
0
 public function postForm(FormProviderRequest $request)
 {
     $id = $request->input('id', NULL);
     $message = "Se ingresó correctamente el proveedor.";
     $modelProvider = new PrProviders();
     $data = $request->all();
     try {
         if (isset($id) && $id != '') {
             $provider = $modelProvider->find($id);
             $provider->fill($data);
             $provider->save();
             $message = "Se actualizó la información del proveedor de manera correcta.";
         } else {
             $modelProvider->fill($data);
             $modelProvider->save($data);
         }
     } catch (Exception $ex) {
     }
     return redirect('admpanel/provider')->with('messageSuccess', $message);
 }