diff --git a/src/Repository.php b/src/Repository.php index 3d527b8..5cdcf05 100644 --- a/src/Repository.php +++ b/src/Repository.php @@ -32,7 +32,7 @@ abstract class Repository implements RepositoryInterface function __construct(Application $app) { $this->app = $app; $this->makeModel(); - $this->relations = ($this->model->_relations ? $this->model->_relations : [] ); + $this->relations = ($this->model->_relations ? $this->model->_relations : []); } /** @@ -51,7 +51,7 @@ public function makeModel() $name_model = $this->model(); $model = $this->app->make($name_model); - if(!$model instanceof Model) { + if (!$model instanceof Model) { throw new \Exception("Class { $name_model } must be an instance of Illuminate\\Database\\Eloquent\\Model"); } @@ -134,7 +134,7 @@ public function takeRandomByWithRelations($limit, $field, $value) /** * Return all rows with relations * @param array $columns - * @return mixed + * @return \Illuminate\Database\Eloquent\Collection */ public function allWithRelations($columns = array('*')) { @@ -167,7 +167,7 @@ public function paginateByFiltersWithAllRelations($filters = array(), $perPage = { $query = $this->model->with($this->relations); - foreach($filters as $field => $value) { + foreach ($filters as $field => $value) { $query->where($field, $value); } @@ -178,7 +178,7 @@ public function paginateByFiltersWithAllRelations($filters = array(), $perPage = /** * Create a record of model * @param array $data - * @return mixed + * @return Model */ public function create(array $data) { @@ -193,7 +193,7 @@ public function create(array $data) */ public function update(array $data, $entity) { - if(is_numeric($entity)) + if (is_numeric($entity)) { $entity = $this->findOrFail($entity); } @@ -207,13 +207,13 @@ public function update(array $data, $entity) /** * Delete a record by id of record or entity * @param $entity - * @return null + * @return boolean */ public function delete($entity) { try { - if(is_numeric($entity)) + if (is_numeric($entity)) { $this->model->destroy($entity); } @@ -223,7 +223,7 @@ public function delete($entity) } return true; } - catch(\Exception $e) + catch (\Exception $e) { return false; } @@ -244,7 +244,7 @@ public function where($field, $value, $columns = array('*')) * @param string $field * @param string $value * @param array $columns - * @return mixed + * @return \Illuminate\Database\Eloquent\Collection */ public function whereWithRelations($field, $value, $columns = array('*')) {