/** * Show the form for editing the specified resource. * * @param int $id * @param AttributeRepository $attributes * @return Response */ public function edit($id, AttributeRepository $attributes) { try { return view('attributes.edit')->with('model', $attributes->findById($id)); } catch (ModelNotFoundException $e) { flash()->warning(trans('attributes.not_found')); return redirect()->route('attribute.index'); } }
/** * Execute the command. * * @param AttributeRepository $attributes * @param AttributeValueRepository $values * @return Attribute */ public function handle(AttributeRepository $attributes, AttributeValueRepository $values) { $attribute = $attributes->findById($this->id)->fill($this->getProperties()); $attributes->save($attribute); if ($this->add_value) { $value = AttributeValue::register($attribute->id, $this->add_value); $values->save($value); } return $attribute; }