@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | return $this->modelInstance; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public function getTable(){ |
|
| 63 | + public function getTable() { |
|
| 64 | 64 | /** |
| 65 | 65 | * @var $model Builder |
| 66 | 66 | */ |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | * @param $type |
| 96 | 96 | * @return mixed |
| 97 | 97 | */ |
| 98 | - public function getRules($type){ |
|
| 98 | + public function getRules($type) { |
|
| 99 | 99 | |
| 100 | - if(isset(static::${$type . 'Rules'})){ |
|
| 101 | - return static::${$type . 'Rules'}; |
|
| 100 | + if (isset(static::${$type.'Rules'})) { |
|
| 101 | + return static::${$type.'Rules'}; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | return []; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @return mixed |
| 113 | 113 | * |
| 114 | 114 | */ |
| 115 | - public function getForm($type, $id = null){ |
|
| 115 | + public function getForm($type, $id = null) { |
|
| 116 | 116 | |
| 117 | 117 | $data = [ |
| 118 | 118 | 'rules' => [], |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | ], |
| 123 | 123 | ]; |
| 124 | 124 | |
| 125 | - if(isset(static::${$type . 'Rules'})){ |
|
| 126 | - $data['rules'] = static::${$type . 'Rules'}; |
|
| 125 | + if (isset(static::${$type.'Rules'})) { |
|
| 126 | + $data['rules'] = static::${$type.'Rules'}; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | $class = $this->model(); |
@@ -135,13 +135,13 @@ discard block |
||
| 135 | 135 | if ($model) { |
| 136 | 136 | $data['model'] = $model->toArray(); |
| 137 | 137 | |
| 138 | - foreach ($model->toArray() as $key => $value){ |
|
| 138 | + foreach ($model->toArray() as $key => $value) { |
|
| 139 | 139 | |
| 140 | 140 | $data['schema']['fields'][$key] = [ |
| 141 | 141 | 'value' => $value |
| 142 | 142 | ]; |
| 143 | 143 | |
| 144 | - $enumKey = $key . 'Enums'; |
|
| 144 | + $enumKey = $key.'Enums'; |
|
| 145 | 145 | |
| 146 | 146 | if (isset($class::${$enumKey})) { |
| 147 | 147 | $data['schema']['fields'][$key]['values'] = $this->modelInstance->getEnums($key); |
@@ -153,13 +153,13 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | $fields = $this->modelInstance->getFillable(); |
| 155 | 155 | |
| 156 | - foreach ($fields as $key){ |
|
| 156 | + foreach ($fields as $key) { |
|
| 157 | 157 | |
| 158 | 158 | $data['schema']['fields'][$key] = [ |
| 159 | 159 | 'model' => $key |
| 160 | 160 | ]; |
| 161 | 161 | |
| 162 | - $enumKey = $key . 'Enums'; |
|
| 162 | + $enumKey = $key.'Enums'; |
|
| 163 | 163 | |
| 164 | 164 | if (isset($class::${$enumKey})) { |
| 165 | 165 | $data['schema']['fields'][$key]['values'] = $this->modelInstance->getEnums($key); |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $model = $this->model->where($attribute, '=', $id)->first(); |
| 206 | 206 | |
| 207 | 207 | if ($model) { |
| 208 | - if($model->update($data)){ |
|
| 208 | + if ($model->update($data)) { |
|
| 209 | 209 | return $model; |
| 210 | 210 | } |
| 211 | 211 | } |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * @param bool $status |
| 270 | 270 | * @return $this |
| 271 | 271 | */ |
| 272 | - public function skipCriteria($status = true){ |
|
| 272 | + public function skipCriteria($status = true) { |
|
| 273 | 273 | $this->skipCriteria = $status; |
| 274 | 274 | return $this; |
| 275 | 275 | } |
@@ -303,11 +303,11 @@ discard block |
||
| 303 | 303 | * @return $this |
| 304 | 304 | */ |
| 305 | 305 | public function applyCriteria() { |
| 306 | - if($this->skipCriteria === true) |
|
| 306 | + if ($this->skipCriteria === true) |
|
| 307 | 307 | return $this; |
| 308 | 308 | |
| 309 | - foreach($this->getCriteria() as $criteria) { |
|
| 310 | - if($criteria instanceof Criteria) |
|
| 309 | + foreach ($this->getCriteria() as $criteria) { |
|
| 310 | + if ($criteria instanceof Criteria) |
|
| 311 | 311 | $this->model = $criteria->apply($this->model, $this); |
| 312 | 312 | } |
| 313 | 313 | |
@@ -249,8 +249,9 @@ discard block |
||
| 249 | 249 | public function makeModel() { |
| 250 | 250 | $model = app()->make($this->model()); |
| 251 | 251 | |
| 252 | - if (!$model instanceof Model) |
|
| 253 | - throw new RepositoryException("Class {$this->model()} must be an instance of Illuminate\\Database\\Eloquent\\Model"); |
|
| 252 | + if (!$model instanceof Model) { |
|
| 253 | + throw new RepositoryException("Class {$this->model()} must be an instance of Illuminate\\Database\\Eloquent\\Model"); |
|
| 254 | + } |
|
| 254 | 255 | |
| 255 | 256 | $this->modelInstance = $model; |
| 256 | 257 | |
@@ -303,12 +304,14 @@ discard block |
||
| 303 | 304 | * @return $this |
| 304 | 305 | */ |
| 305 | 306 | public function applyCriteria() { |
| 306 | - if($this->skipCriteria === true) |
|
| 307 | - return $this; |
|
| 307 | + if($this->skipCriteria === true) { |
|
| 308 | + return $this; |
|
| 309 | + } |
|
| 308 | 310 | |
| 309 | 311 | foreach($this->getCriteria() as $criteria) { |
| 310 | - if($criteria instanceof Criteria) |
|
| 311 | - $this->model = $criteria->apply($this->model, $this); |
|
| 312 | + if($criteria instanceof Criteria) { |
|
| 313 | + $this->model = $criteria->apply($this->model, $this); |
|
| 314 | + } |
|
| 312 | 315 | } |
| 313 | 316 | |
| 314 | 317 | return $this; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public $model; |
| 28 | 28 | |
| 29 | - public function __construct(){ |
|
| 29 | + public function __construct() { |
|
| 30 | 30 | $this->app = app(); |
| 31 | 31 | $this->makeModel(); |
| 32 | 32 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @return \Illuminate\Http\Response |
| 51 | 51 | * @throws \ReflectionException |
| 52 | 52 | */ |
| 53 | - public function create(){ |
|
| 53 | + public function create() { |
|
| 54 | 54 | return $this->model->getForm('create'); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @return \Illuminate\Http\Response |
| 84 | 84 | * @throws \ReflectionException |
| 85 | 85 | */ |
| 86 | - public function edit($id){ |
|
| 86 | + public function edit($id) { |
|
| 87 | 87 | return $this->model->getForm('edit', $id); |
| 88 | 88 | } |
| 89 | 89 | |