Ejemplo n.º 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param Services $services
  * @param ServiceRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update(Services $services, ServiceRequest $request)
 {
     $oldImage = null;
     if ($request->file('upl')) {
         $oldImage = Attachment::where('id', $services->attachment_id);
         $imageModel = ImageUploadFacade::attachmentUpload($request->file('upl'), new Attachment(), 'services');
         $services->attachment_id = $imageModel->id;
     }
     $services->update($request->input());
     if ($oldImage) {
         $oldImage->delete();
     }
     return redirect()->route('admin.services.index');
 }
Ejemplo n.º 2
0
 public function newService($id)
 {
     if ($_POST) {
         $request = (object) $_POST;
         $imagen = (object) $_FILES;
         $service = new Services();
         if (isset($id)) {
             $service->update($id, $request->nombre, $request->descripcion);
             newFlashMessage('test', 'Servicio ' . ucwords($request->nombre) . " actualizada.");
             return redirect('admin/service');
         } else {
             $dir_file = '../resource/images/services/';
             $name_real = $imagen->imagen['name'];
             if (move_uploaded_file($imagen->imagen['tmp_name'], $dir_file . $name_real)) {
                 $service->create($request->nombre, $name_real, $request->descripcion);
                 newFlashMessage('test', 'Servicio ' . ucwords($request->nombre) . " creado.");
                 return redirect('admin/service');
             }
             return redirect('admin/service');
         }
     } elseif (isset($id)) {
         $service = new Services();
         $service = $service->find($id);
         return view('admin/service/update', compact('service'), 'baseAdmin');
     } else {
         return view('admin/service/create', '', 'baseAdmin');
     }
 }