@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | public function generateForm($entity, $method = 'post') |
| 74 | 74 | { |
| 75 | 75 | $html = '<form method="post" action="#"> |
| 76 | - <input type="hidden" name="__method" value="'.$method.'">'; |
|
| 76 | + <input type="hidden" name="__method" value="'.$method . '">'; |
|
| 77 | 77 | $html .= $this->getInputs($entity); |
| 78 | 78 | $html .= '</form>'; |
| 79 | 79 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public function getFillables($entity) |
| 89 | 89 | { |
| 90 | - if (! empty($entity->getFillable())) { |
|
| 90 | + if (!empty($entity->getFillable())) { |
|
| 91 | 91 | return $entity->getFillable(); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -72,6 +72,6 @@ |
||
| 72 | 72 | |
| 73 | 73 | public function getFormStub($type) |
| 74 | 74 | { |
| 75 | - return file_get_contents(Config::get('repository.stubs_path').'/fields-'.$type.'.stub'); |
|
| 75 | + return file_get_contents(Config::get('repository.stubs_path') . '/fields-' . $type . '.stub'); |
|
| 76 | 76 | } |
| 77 | 77 | } |
@@ -6,11 +6,11 @@ |
||
| 6 | 6 | * Time: 09:58 am. |
| 7 | 7 | */ |
| 8 | 8 | return [ |
| 9 | - 'app_path' => realpath(__DIR__.'/../app/'), |
|
| 9 | + 'app_path' => realpath(__DIR__ . '/../app/'), |
|
| 10 | 10 | 'route_path' => realpath('routes/'), |
| 11 | 11 | 'resources_path' => realpath('resources'), |
| 12 | - 'stubs_path' => realpath('resources').'/stubs/', |
|
| 13 | - 'lang_path' => realpath('resources').'/lang/', |
|
| 12 | + 'stubs_path' => realpath('resources') . '/stubs/', |
|
| 13 | + 'lang_path' => realpath('resources') . '/lang/', |
|
| 14 | 14 | 'config_path' => realpath('config'), |
| 15 | 15 | |
| 16 | 16 | //relative to app path |
@@ -92,7 +92,7 @@ |
||
| 92 | 92 | * |
| 93 | 93 | * @return LengthAwarePaginator |
| 94 | 94 | */ |
| 95 | - public function get($criteria = [],$columns = []); |
|
| 95 | + public function get($criteria = [], $columns = []); |
|
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * @param string $name |
@@ -115,11 +115,11 @@ |
||
| 115 | 115 | if (isset($criteria['search'])) { |
| 116 | 116 | foreach ($this->model->searchable as $method => $columns) { |
| 117 | 117 | if (method_exists($this->model, $method)) { |
| 118 | - $latest->orWhereHas($method, function ($query) use ($criteria, $columns) { |
|
| 118 | + $latest->orWhereHas($method, function($query) use ($criteria, $columns) { |
|
| 119 | 119 | /* @var $query Builder */ |
| 120 | - $query->where(function ($query2) use ($criteria, $columns) { |
|
| 120 | + $query->where(function($query2) use ($criteria, $columns) { |
|
| 121 | 121 | /* @var $query2 Builder */ |
| 122 | - foreach ((array)$columns as $column) { |
|
| 122 | + foreach ((array) $columns as $column) { |
|
| 123 | 123 | $query2->orWhere($column, 'like', '%' . $criteria['search'] . '%'); |
| 124 | 124 | } |
| 125 | 125 | }); |
@@ -248,14 +248,16 @@ discard block |
||
| 248 | 248 | public function find($entityId = 0, $columns = ['*']) |
| 249 | 249 | { |
| 250 | 250 | if ($this->allowCaching) { |
| 251 | - if (isset($this->cache[$entityId])) |
|
| 252 | - return $this->cache[$entityId]; |
|
| 251 | + if (isset($this->cache[$entityId])) { |
|
| 252 | + return $this->cache[$entityId]; |
|
| 253 | + } |
|
| 253 | 254 | } |
| 254 | 255 | |
| 255 | 256 | $entity = $this->model->with($this->with)->find($entityId, $columns); |
| 256 | 257 | |
| 257 | - if ($this->allowCaching) |
|
| 258 | - $this->cache[$entityId] = $entity; |
|
| 258 | + if ($this->allowCaching) { |
|
| 259 | + $this->cache[$entityId] = $entity; |
|
| 260 | + } |
|
| 259 | 261 | |
| 260 | 262 | return $entity; |
| 261 | 263 | } |
@@ -271,14 +273,16 @@ discard block |
||
| 271 | 273 | public function findOrFail($entityId = 0, $columns = ['*']) |
| 272 | 274 | { |
| 273 | 275 | if ($this->allowCaching) { |
| 274 | - if (isset($this->cache[$entityId])) |
|
| 275 | - return $this->cache[$entityId]; |
|
| 276 | + if (isset($this->cache[$entityId])) { |
|
| 277 | + return $this->cache[$entityId]; |
|
| 278 | + } |
|
| 276 | 279 | } |
| 277 | 280 | |
| 278 | 281 | $entity = $this->model->with($this->with)->findOrFail($entityId, $columns); |
| 279 | 282 | |
| 280 | - if ($this->allowCaching) |
|
| 281 | - $this->cache[$entityId] = $entity; |
|
| 283 | + if ($this->allowCaching) { |
|
| 284 | + $this->cache[$entityId] = $entity; |
|
| 285 | + } |
|
| 282 | 286 | |
| 283 | 287 | return $entity; |
| 284 | 288 | } |
@@ -292,14 +296,16 @@ discard block |
||
| 292 | 296 | public function first($filter = [], $columns = ['*']) |
| 293 | 297 | { |
| 294 | 298 | if ($this->allowCaching) { |
| 295 | - if (isset($this->cache['first'])) |
|
| 296 | - return $this->cache['first']; |
|
| 299 | + if (isset($this->cache['first'])) { |
|
| 300 | + return $this->cache['first']; |
|
| 301 | + } |
|
| 297 | 302 | } |
| 298 | 303 | |
| 299 | 304 | $entity = $this->filter($filter)->with($this->with)->select($columns)->first(); |
| 300 | 305 | |
| 301 | - if ($this->allowCaching) |
|
| 302 | - $this->cache['first'] = $entity; |
|
| 306 | + if ($this->allowCaching) { |
|
| 307 | + $this->cache['first'] = $entity; |
|
| 308 | + } |
|
| 303 | 309 | |
| 304 | 310 | return $entity; |
| 305 | 311 | } |
@@ -313,14 +319,16 @@ discard block |
||
| 313 | 319 | public function last($filter = [], $columns = ['*']) |
| 314 | 320 | { |
| 315 | 321 | if ($this->allowCaching) { |
| 316 | - if (isset($this->cache['last'])) |
|
| 317 | - return $this->cache['last']; |
|
| 322 | + if (isset($this->cache['last'])) { |
|
| 323 | + return $this->cache['last']; |
|
| 324 | + } |
|
| 318 | 325 | } |
| 319 | 326 | |
| 320 | 327 | $entity = $this->filter($filter)->with($this->with)->select($columns)->orderBy('id', 'desc')->first(); |
| 321 | 328 | |
| 322 | - if ($this->allowCaching) |
|
| 323 | - $this->cache['last'] = $entity; |
|
| 329 | + if ($this->allowCaching) { |
|
| 330 | + $this->cache['last'] = $entity; |
|
| 331 | + } |
|
| 324 | 332 | |
| 325 | 333 | return $entity; |
| 326 | 334 | } |
@@ -63,10 +63,10 @@ |
||
| 63 | 63 | } |
| 64 | 64 | $limit = $request->get('limit', 10); |
| 65 | 65 | |
| 66 | - if ((bool)$request->get('with-trash', false)) { |
|
| 66 | + if ((bool) $request->get('with-trash', false)) { |
|
| 67 | 67 | $interface->withTrash(); |
| 68 | 68 | } |
| 69 | - if ((bool)$request->get('only-trash', false)) { |
|
| 69 | + if ((bool) $request->get('only-trash', false)) { |
|
| 70 | 70 | $interface->trash(); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -25,25 +25,25 @@ |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | $this->publishes([ |
| 28 | - __DIR__.'/config' => realpath('config'), |
|
| 28 | + __DIR__ . '/config' => realpath('config'), |
|
| 29 | 29 | ], 'repository-generator'); |
| 30 | 30 | |
| 31 | 31 | if (null === $this->app['config']->get('repository')) { |
| 32 | - $this->app['config']->set('repository', require __DIR__.'/config/repository.php'); |
|
| 32 | + $this->app['config']->set('repository', require __DIR__ . '/config/repository.php'); |
|
| 33 | 33 | } |
| 34 | - $this->mergeConfigFrom(__DIR__.'/config/repository.php', 'repository-config'); |
|
| 34 | + $this->mergeConfigFrom(__DIR__ . '/config/repository.php', 'repository-config'); |
|
| 35 | 35 | $resourcesPathStub = resource_path('/stubs'); |
| 36 | - $stubPath = realpath(__DIR__.'/../stubs'); |
|
| 37 | - $langPath = Config::get('repository.lang_path').'/en'; |
|
| 36 | + $stubPath = realpath(__DIR__ . '/../stubs'); |
|
| 37 | + $langPath = Config::get('repository.lang_path') . '/en'; |
|
| 38 | 38 | |
| 39 | - if(!is_dir($resourcesPathStub)) |
|
| 39 | + if (!is_dir($resourcesPathStub)) |
|
| 40 | 40 | { |
| 41 | - mkdir($resourcesPathStub,0777,true); |
|
| 41 | + mkdir($resourcesPathStub, 0777, true); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | $this->publishes([ |
| 45 | 45 | $stubPath => Config::get('repository.stubs_path', $resourcesPathStub), |
| 46 | - __DIR__.'/lang' => $langPath, |
|
| 46 | + __DIR__ . '/lang' => $langPath, |
|
| 47 | 47 | ], 'repository-stub'); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | */ |
| 52 | 52 | public function handle() |
| 53 | 53 | { |
| 54 | - $file = preg_split(' (/|\\\\) ', (string)$this->argument('name')) ?? []; |
|
| 54 | + $file = preg_split(' (/|\\\\) ', (string) $this->argument('name')) ?? []; |
|
| 55 | 55 | |
| 56 | 56 | if (!$file) { |
| 57 | 57 | return 'Something wrong with the inputs !'; |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function handle() |
| 62 | 62 | { |
| 63 | - $file = preg_split(' ([/\\\]) ', (string)$this->argument('name')) ?? []; |
|
| 63 | + $file = preg_split(' ([/\\\]) ', (string) $this->argument('name')) ?? []; |
|
| 64 | 64 | |
| 65 | 65 | if (!$file) { |
| 66 | 66 | return 'Something wrong with the inputs !'; |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | $requestBase = Config::get('repository.base_request', "{$base}\Request"); |
| 98 | 98 | $resourceBase = Config::get('repository.base_resource', "{$base}\JsonResource"); |
| 99 | 99 | |
| 100 | - $this->generate($path, $controller, 'Controller','', $controllerBase); |
|
| 101 | - $this->generate($path, $resource, 'Resource', '',$resourceBase); |
|
| 102 | - $this->generate($path, $model, 'Entity', '',$modelBase); |
|
| 103 | - $this->generate($path, $request, 'Request', '',$requestBase); |
|
| 104 | - $this->generate($path, $interface, 'Interface','', $interfaceBase); |
|
| 105 | - $this->generate($path, $repository, 'Repository', '',$repositoryBase); |
|
| 100 | + $this->generate($path, $controller, 'Controller', '', $controllerBase); |
|
| 101 | + $this->generate($path, $resource, 'Resource', '', $resourceBase); |
|
| 102 | + $this->generate($path, $model, 'Entity', '', $modelBase); |
|
| 103 | + $this->generate($path, $request, 'Request', '', $requestBase); |
|
| 104 | + $this->generate($path, $interface, 'Interface', '', $interfaceBase); |
|
| 105 | + $this->generate($path, $repository, 'Repository', '', $repositoryBase); |
|
| 106 | 106 | |
| 107 | 107 | $webFile = Config::get('repository.route_path') . '/web.php'; |
| 108 | 108 | $apiFile = Config::get('repository.route_path') . '/api.php'; |