public function find($id, $columns = array()) { try { return parent::find($id); } catch (ModelNotFoundException $ex) { return ['success' => false, 'message' => "O id '" . $id . "' nao foi localizado!", 'error' => $ex->getMessage()]; } }
public function find($id, $columns = ['*']) { try { return parent::find($id); } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'Cliente não encontrado.']; } }
public function delete($id) { try { $client = parent::find($id); parent::delete($id); return ['success' => true]; } catch (ModelNotFoundException $ex) { return ['success' => false, 'message' => 'O id ' . $id . ' nao foi localizado!', 'error' => $ex->getMessage()]; } catch (Exception $ex2) { return ['success' => false, 'message' => 'Erro ao excluir client: ' + $ex2 . getMessage(), 'error' => $ex2->getMessage()]; } }
/** * Find data by id * * @param $id * @param array $columns * @return mixed */ public function find($id, $columns = ['*']) { try { $result = parent::find($id, $columns); if ($this->with_relation_count) { foreach ($this->relations as $relation => $options) { $tmp = $this->getRelationRecordCount($relation, $relation)->whereIn('main.id', [$id])->get()->all(); $tmp2 = []; foreach ($options['fields'] as $field) { foreach ($tmp as $record) { $tmp2[$record->id] = $record->{$field}; } $result->{$field} = !empty($tmp2[$id]) ? $tmp2[$id] : 0; } } } return $result; } catch (ModelNotFoundException $e) { throw new RepositoryException('Entity is not found!', null, $e); } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { return $this->repository->find($id); }