public function getElementoAttribute() { if (!empty($this->attributes['elemento_id'])) { return FarmaciaElemento::find($this->attributes['elemento_id']); } else { return null; } }
public function postElementos() { $input = Input::all(); foreach ($input['form'] as $elemento) { if ($elemento['name'] != 'elemento_add' && $elemento['value'] != null) { $e = ['elemento_pai' => $elemento['value']]; } } $e = $e + ['descricao' => $input['form'][count($input['form']) - 1]['value']]; return FarmaciaElemento::create($e); }