/**
  * Store a newly created resource in storage.
  * @param ItemFormRequest $request
  * @return mixed
  */
 public function store(ItemFormRequest $request)
 {
     $item = new Item();
     $item->name = $request->get('name');
     $item->active = $request->get('active');
     $item->save();
     return \Redirect::route('item')->with('message', 'Item saved');
 }
Esempio n. 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, ItemFormRequest $request)
 {
     $item = Item::whereId($id)->firstOrFail();
     $item->name = $request->get('name');
     $item->description = $request->get('description');
     $item->save();
     $item->categories()->sync($request->input('category_list'));
     return redirect()->route('items.edit', ['id' => $item->id])->with('status', 'The item ' . $item->name . ' has been updated!');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(ItemFormRequest $request)
 {
     //
     $item = new Item_hc(array('id_sede' => 1, 'id_usuario' => $request->get('user'), 'id_paciente' => $request->get('id_paciente'), 'titulo' => $request->get('titulo'), 'descripcion' => $request->get('descripcion'), 'path' => $request->get('path')));
     $item->save();
     return redirect('/admin/items/create')->with('status', 'Un item de historia clínica ha sido creado.');
 }
Esempio n. 4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, ItemFormRequest $request)
 {
     $item = Item::find($id);
     $data = $request->input();
     $data['childable'] = empty($data['childable']) ? false : true;
     if (empty($data['quantity'])) {
         $data['quantity'] = 1;
     }
     //Debug
     // dd($data);
     $item->update(['name' => $data['name'], 'quantity' => $data['quantity'], 'parent_id' => $data['parent_id'], 'parent_name' => $data['parent_name'], 'location_id' => $data['location_id'], 'location_name' => $data['location_name'], 'childable' => $data['childable']]);
     return redirect()->route('items.index');
 }
 public function save(ItemFormRequest $request)
 {
     // подготовка изображений
     $url_img = $this->image_processing($request->file('preview'));
     $preview = !empty($url_img) ? implode(';', $url_img) : "";
     // создание, запись информации
     $item = new Items();
     $item->title = $request->title;
     $item->description = $request->description;
     $item->price = $request->price;
     $item->sub_categories_id = $request->subcat;
     $item->preview = $preview;
     $item->save();
     if (empty($request->parameter)) {
         return back()->with('message', 'Товар сохранен');
     }
     $out = array_combine($request->parameter, $request->value);
     foreach ($out as $param => $value) {
         $parameters = new Items_parameters();
         $parameters->parameters_id = $param;
         $parameters->items_id = $item->id;
         $parameters->value = $value;
         $parameters->save();
     }
     return back()->with('message', 'Товар сохранен');
 }