@@ -7,101 +7,101 @@ |
||
| 7 | 7 | |
| 8 | 8 | class CachingDecorator |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * @var string |
|
| 12 | - */ |
|
| 13 | - public $service; |
|
| 10 | + /** |
|
| 11 | + * @var string |
|
| 12 | + */ |
|
| 13 | + public $service; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @var Cache |
|
| 17 | - */ |
|
| 18 | - protected $cache; |
|
| 15 | + /** |
|
| 16 | + * @var Cache |
|
| 17 | + */ |
|
| 18 | + protected $cache; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - public $modelKey; |
|
| 20 | + /** |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + public $modelKey; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - public $model; |
|
| 25 | + /** |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + public $model; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @var string |
|
| 32 | - */ |
|
| 33 | - public $modelClass; |
|
| 30 | + /** |
|
| 31 | + * @var string |
|
| 32 | + */ |
|
| 33 | + public $modelClass; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var mixed |
|
| 37 | - */ |
|
| 38 | - public $cacheConfig; |
|
| 35 | + /** |
|
| 36 | + * @var mixed |
|
| 37 | + */ |
|
| 38 | + public $cacheConfig; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @var string |
|
| 42 | - */ |
|
| 43 | - public $cacheTag; |
|
| 40 | + /** |
|
| 41 | + * @var string |
|
| 42 | + */ |
|
| 43 | + public $cacheTag; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Init new object. |
|
| 47 | - * |
|
| 48 | - * @param string $service |
|
| 49 | - * @param Cache $cache |
|
| 50 | - * |
|
| 51 | - * @return void |
|
| 52 | - */ |
|
| 53 | - public function __construct($service, Cache $cache) |
|
| 54 | - { |
|
| 55 | - $this->service = $service; |
|
| 56 | - $this->cache = $cache; |
|
| 57 | - $this->model = $this->service->repo->model; |
|
| 58 | - $this->modelClass = get_class($this->model); |
|
| 59 | - $serviceClass = explode('\\', get_class($this->service)); |
|
| 60 | - $serviceName = end($serviceClass); |
|
| 61 | - $this->cacheTag = lcfirst(substr($serviceName, 0, strpos($serviceName, 'Service'))); |
|
| 62 | - } |
|
| 45 | + /** |
|
| 46 | + * Init new object. |
|
| 47 | + * |
|
| 48 | + * @param string $service |
|
| 49 | + * @param Cache $cache |
|
| 50 | + * |
|
| 51 | + * @return void |
|
| 52 | + */ |
|
| 53 | + public function __construct($service, Cache $cache) |
|
| 54 | + { |
|
| 55 | + $this->service = $service; |
|
| 56 | + $this->cache = $cache; |
|
| 57 | + $this->model = $this->service->repo->model; |
|
| 58 | + $this->modelClass = get_class($this->model); |
|
| 59 | + $serviceClass = explode('\\', get_class($this->service)); |
|
| 60 | + $serviceName = end($serviceClass); |
|
| 61 | + $this->cacheTag = lcfirst(substr($serviceName, 0, strpos($serviceName, 'Service'))); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Handle the cache mechanism for the called method |
|
| 66 | - * based the configurations. |
|
| 67 | - * |
|
| 68 | - * @param string $name the called method name |
|
| 69 | - * @param array $arguments the method arguments |
|
| 70 | - * @return object |
|
| 71 | - */ |
|
| 72 | - public function __call($name, $arguments) |
|
| 73 | - { |
|
| 74 | - $this->setCacheConfig($name); |
|
| 64 | + /** |
|
| 65 | + * Handle the cache mechanism for the called method |
|
| 66 | + * based the configurations. |
|
| 67 | + * |
|
| 68 | + * @param string $name the called method name |
|
| 69 | + * @param array $arguments the method arguments |
|
| 70 | + * @return object |
|
| 71 | + */ |
|
| 72 | + public function __call($name, $arguments) |
|
| 73 | + { |
|
| 74 | + $this->setCacheConfig($name); |
|
| 75 | 75 | |
| 76 | - if ($this->cacheConfig && $this->cacheConfig == 'cache') { |
|
| 77 | - $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
|
| 78 | - $cacheKey = $name.$page.\Session::get('locale').serialize($arguments); |
|
| 79 | - return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function () use ($arguments, $name) { |
|
| 80 | - return call_user_func_array([$this->service, $name], $arguments); |
|
| 81 | - }); |
|
| 82 | - } elseif ($this->cacheConfig) { |
|
| 83 | - $this->cache->tags($this->cacheConfig)->flush(); |
|
| 84 | - return call_user_func_array([$this->service, $name], $arguments); |
|
| 85 | - } |
|
| 76 | + if ($this->cacheConfig && $this->cacheConfig == 'cache') { |
|
| 77 | + $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
|
| 78 | + $cacheKey = $name.$page.\Session::get('locale').serialize($arguments); |
|
| 79 | + return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function () use ($arguments, $name) { |
|
| 80 | + return call_user_func_array([$this->service, $name], $arguments); |
|
| 81 | + }); |
|
| 82 | + } elseif ($this->cacheConfig) { |
|
| 83 | + $this->cache->tags($this->cacheConfig)->flush(); |
|
| 84 | + return call_user_func_array([$this->service, $name], $arguments); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - return call_user_func_array([$this->service, $name], $arguments); |
|
| 88 | - } |
|
| 87 | + return call_user_func_array([$this->service, $name], $arguments); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Set cache config based on the called method. |
|
| 92 | - * |
|
| 93 | - * @param string $name |
|
| 94 | - * @return void |
|
| 95 | - */ |
|
| 96 | - private function setCacheConfig($name) |
|
| 97 | - { |
|
| 98 | - $cacheConfig = Arr::get(config('core.cache_config'), $this->cacheTag, false); |
|
| 99 | - $this->cacheConfig = false; |
|
| 90 | + /** |
|
| 91 | + * Set cache config based on the called method. |
|
| 92 | + * |
|
| 93 | + * @param string $name |
|
| 94 | + * @return void |
|
| 95 | + */ |
|
| 96 | + private function setCacheConfig($name) |
|
| 97 | + { |
|
| 98 | + $cacheConfig = Arr::get(config('core.cache_config'), $this->cacheTag, false); |
|
| 99 | + $this->cacheConfig = false; |
|
| 100 | 100 | |
| 101 | - if ($cacheConfig && in_array($name, $cacheConfig['cache'])) { |
|
| 102 | - $this->cacheConfig = 'cache'; |
|
| 103 | - } elseif ($cacheConfig && isset($cacheConfig['clear'][$name])) { |
|
| 104 | - $this->cacheConfig = $cacheConfig['clear'][$name]; |
|
| 105 | - } |
|
| 106 | - } |
|
| 101 | + if ($cacheConfig && in_array($name, $cacheConfig['cache'])) { |
|
| 102 | + $this->cacheConfig = 'cache'; |
|
| 103 | + } elseif ($cacheConfig && isset($cacheConfig['clear'][$name])) { |
|
| 104 | + $this->cacheConfig = $cacheConfig['clear'][$name]; |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | 107 | } |
@@ -76,7 +76,7 @@ |
||
| 76 | 76 | if ($this->cacheConfig && $this->cacheConfig == 'cache') { |
| 77 | 77 | $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
| 78 | 78 | $cacheKey = $name.$page.\Session::get('locale').serialize($arguments); |
| 79 | - return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function () use ($arguments, $name) { |
|
| 79 | + return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
|
| 80 | 80 | return call_user_func_array([$this->service, $name], $arguments); |
| 81 | 81 | }); |
| 82 | 82 | } elseif ($this->cacheConfig) { |
@@ -4,70 +4,70 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Media |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Upload the given image. |
|
| 9 | - * |
|
| 10 | - * @param object $image |
|
| 11 | - * @param string $dir |
|
| 12 | - * @return string |
|
| 13 | - */ |
|
| 14 | - public function uploadImage($image, $dir) |
|
| 15 | - { |
|
| 16 | - $image = \Image::make($image); |
|
| 17 | - return $this->saveImage($image, $dir); |
|
| 18 | - } |
|
| 7 | + /** |
|
| 8 | + * Upload the given image. |
|
| 9 | + * |
|
| 10 | + * @param object $image |
|
| 11 | + * @param string $dir |
|
| 12 | + * @return string |
|
| 13 | + */ |
|
| 14 | + public function uploadImage($image, $dir) |
|
| 15 | + { |
|
| 16 | + $image = \Image::make($image); |
|
| 17 | + return $this->saveImage($image, $dir); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Upload the given image. |
|
| 22 | - * |
|
| 23 | - * @param object $image |
|
| 24 | - * @param string $dir |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public function uploadImageBas64($image, $dir) |
|
| 28 | - { |
|
| 29 | - if (! strlen($image)) { |
|
| 30 | - return null; |
|
| 31 | - } |
|
| 20 | + /** |
|
| 21 | + * Upload the given image. |
|
| 22 | + * |
|
| 23 | + * @param object $image |
|
| 24 | + * @param string $dir |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public function uploadImageBas64($image, $dir) |
|
| 28 | + { |
|
| 29 | + if (! strlen($image)) { |
|
| 30 | + return null; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - if(filter_var($image, FILTER_VALIDATE_URL)) { |
|
| 34 | - return $image; |
|
| 35 | - } |
|
| 33 | + if(filter_var($image, FILTER_VALIDATE_URL)) { |
|
| 34 | + return $image; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - try { |
|
| 38 | - $base = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $image)); |
|
| 39 | - $image = \Image::make($base); |
|
| 40 | - } catch (\Exception $e) { |
|
| 41 | - \Errors::cannotUploadImage(); |
|
| 42 | - } |
|
| 37 | + try { |
|
| 38 | + $base = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $image)); |
|
| 39 | + $image = \Image::make($base); |
|
| 40 | + } catch (\Exception $e) { |
|
| 41 | + \Errors::cannotUploadImage(); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - return $this->saveImage($image, $dir); |
|
| 45 | - } |
|
| 44 | + return $this->saveImage($image, $dir); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Delete the given image. |
|
| 49 | - * |
|
| 50 | - * @param object $path |
|
| 51 | - * @return void |
|
| 52 | - */ |
|
| 53 | - public function deleteImage($path) |
|
| 54 | - { |
|
| 55 | - \Storage::delete($path); |
|
| 56 | - } |
|
| 47 | + /** |
|
| 48 | + * Delete the given image. |
|
| 49 | + * |
|
| 50 | + * @param object $path |
|
| 51 | + * @return void |
|
| 52 | + */ |
|
| 53 | + public function deleteImage($path) |
|
| 54 | + { |
|
| 55 | + \Storage::delete($path); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Save the given image. |
|
| 60 | - * |
|
| 61 | - * @param object $image |
|
| 62 | - * @param string $dir |
|
| 63 | - * @return string |
|
| 64 | - */ |
|
| 65 | - protected function saveImage($image, $dir) |
|
| 66 | - { |
|
| 67 | - $imageName = 'image'.uniqid().time().'.jpg'; |
|
| 68 | - $path = 'public'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.$imageName; |
|
| 69 | - \Storage::put($path, $image->stream()); |
|
| 58 | + /** |
|
| 59 | + * Save the given image. |
|
| 60 | + * |
|
| 61 | + * @param object $image |
|
| 62 | + * @param string $dir |
|
| 63 | + * @return string |
|
| 64 | + */ |
|
| 65 | + protected function saveImage($image, $dir) |
|
| 66 | + { |
|
| 67 | + $imageName = 'image'.uniqid().time().'.jpg'; |
|
| 68 | + $path = 'public'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.$imageName; |
|
| 69 | + \Storage::put($path, $image->stream()); |
|
| 70 | 70 | |
| 71 | - return $path; |
|
| 72 | - } |
|
| 71 | + return $path; |
|
| 72 | + } |
|
| 73 | 73 | } |
@@ -26,11 +26,11 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | public function uploadImageBas64($image, $dir) |
| 28 | 28 | { |
| 29 | - if (! strlen($image)) { |
|
| 29 | + if ( ! strlen($image)) { |
|
| 30 | 30 | return null; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - if(filter_var($image, FILTER_VALIDATE_URL)) { |
|
| 33 | + if (filter_var($image, FILTER_VALIDATE_URL)) { |
|
| 34 | 34 | return $image; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -4,38 +4,38 @@ |
||
| 4 | 4 | |
| 5 | 5 | class CoreErrors |
| 6 | 6 | { |
| 7 | - public function connectionError() |
|
| 8 | - { |
|
| 9 | - abort(500, trans('core::errors.connectionError')); |
|
| 10 | - } |
|
| 11 | - |
|
| 12 | - public function redisNotRunning() |
|
| 13 | - { |
|
| 14 | - abort(500, trans('core::errors.redisNotRunning')); |
|
| 15 | - } |
|
| 16 | - |
|
| 17 | - public function dbQueryError() |
|
| 18 | - { |
|
| 19 | - abort(500, trans('core::errors.dbQueryError')); |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - public function cannotCreateSetting() |
|
| 23 | - { |
|
| 24 | - abort(400, trans('core::errors.cannotCreateSetting')); |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - public function cannotUpdateSettingKey() |
|
| 28 | - { |
|
| 29 | - abort(400, trans('core::errors.cannotUpdateSettingKey')); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - public function notFound($text) |
|
| 33 | - { |
|
| 34 | - abort(404, trans('core::errors.notFound', ['replace' => $text])); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - public function cannotUploadImage() |
|
| 38 | - { |
|
| 39 | - abort(400, trans('core::errors.cannotUploadImage')); |
|
| 40 | - } |
|
| 7 | + public function connectionError() |
|
| 8 | + { |
|
| 9 | + abort(500, trans('core::errors.connectionError')); |
|
| 10 | + } |
|
| 11 | + |
|
| 12 | + public function redisNotRunning() |
|
| 13 | + { |
|
| 14 | + abort(500, trans('core::errors.redisNotRunning')); |
|
| 15 | + } |
|
| 16 | + |
|
| 17 | + public function dbQueryError() |
|
| 18 | + { |
|
| 19 | + abort(500, trans('core::errors.dbQueryError')); |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + public function cannotCreateSetting() |
|
| 23 | + { |
|
| 24 | + abort(400, trans('core::errors.cannotCreateSetting')); |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + public function cannotUpdateSettingKey() |
|
| 28 | + { |
|
| 29 | + abort(400, trans('core::errors.cannotUpdateSettingKey')); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + public function notFound($text) |
|
| 33 | + { |
|
| 34 | + abort(404, trans('core::errors.notFound', ['replace' => $text])); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + public function cannotUploadImage() |
|
| 38 | + { |
|
| 39 | + abort(400, trans('core::errors.cannotUploadImage')); |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /* |
|
| 5 | + /* |
|
| 6 | 6 | |-------------------------------------------------------------------------- |
| 7 | 7 | | Relations Between Models |
| 8 | 8 | |-------------------------------------------------------------------------- |
@@ -11,43 +11,43 @@ discard block |
||
| 11 | 11 | | |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | - 'relations' => [ |
|
| 15 | - 'user' => [ |
|
| 16 | - 'index' => [], |
|
| 17 | - 'show' => [], |
|
| 18 | - 'account' => [], |
|
| 19 | - ], |
|
| 20 | - 'permission' => [ |
|
| 21 | - 'index' => [], |
|
| 22 | - 'show' => [], |
|
| 23 | - ], |
|
| 24 | - 'role' => [ |
|
| 25 | - 'index' => [], |
|
| 26 | - 'show' => [], |
|
| 27 | - ], |
|
| 28 | - 'oauthClient' => [ |
|
| 29 | - 'index' => [], |
|
| 30 | - 'show' => [], |
|
| 31 | - ], |
|
| 32 | - 'notification' => [ |
|
| 33 | - 'index' => [], |
|
| 34 | - 'unread' => [], |
|
| 35 | - ], |
|
| 36 | - 'pushNotificationDevice' => [ |
|
| 37 | - 'index' => [], |
|
| 38 | - 'show' => [], |
|
| 39 | - ], |
|
| 40 | - 'report' => [ |
|
| 41 | - 'index' => [], |
|
| 42 | - 'show' => [], |
|
| 43 | - ], |
|
| 44 | - 'setting' => [ |
|
| 45 | - 'index' => [], |
|
| 46 | - 'show' => [], |
|
| 47 | - ], |
|
| 48 | - ], |
|
| 14 | + 'relations' => [ |
|
| 15 | + 'user' => [ |
|
| 16 | + 'index' => [], |
|
| 17 | + 'show' => [], |
|
| 18 | + 'account' => [], |
|
| 19 | + ], |
|
| 20 | + 'permission' => [ |
|
| 21 | + 'index' => [], |
|
| 22 | + 'show' => [], |
|
| 23 | + ], |
|
| 24 | + 'role' => [ |
|
| 25 | + 'index' => [], |
|
| 26 | + 'show' => [], |
|
| 27 | + ], |
|
| 28 | + 'oauthClient' => [ |
|
| 29 | + 'index' => [], |
|
| 30 | + 'show' => [], |
|
| 31 | + ], |
|
| 32 | + 'notification' => [ |
|
| 33 | + 'index' => [], |
|
| 34 | + 'unread' => [], |
|
| 35 | + ], |
|
| 36 | + 'pushNotificationDevice' => [ |
|
| 37 | + 'index' => [], |
|
| 38 | + 'show' => [], |
|
| 39 | + ], |
|
| 40 | + 'report' => [ |
|
| 41 | + 'index' => [], |
|
| 42 | + 'show' => [], |
|
| 43 | + ], |
|
| 44 | + 'setting' => [ |
|
| 45 | + 'index' => [], |
|
| 46 | + 'show' => [], |
|
| 47 | + ], |
|
| 48 | + ], |
|
| 49 | 49 | |
| 50 | - /* |
|
| 50 | + /* |
|
| 51 | 51 | |-------------------------------------------------------------------------- |
| 52 | 52 | | Cache Configurations |
| 53 | 53 | |-------------------------------------------------------------------------- |
@@ -56,42 +56,42 @@ discard block |
||
| 56 | 56 | | |
| 57 | 57 | */ |
| 58 | 58 | |
| 59 | - 'cache_config' => [ |
|
| 60 | - 'oauthClient' => [ |
|
| 61 | - 'cache' => [ |
|
| 62 | - 'list', |
|
| 63 | - 'find', |
|
| 64 | - 'findBy', |
|
| 65 | - 'paginate', |
|
| 66 | - 'paginateBy', |
|
| 67 | - 'first', |
|
| 68 | - 'deleted' |
|
| 69 | - ], |
|
| 70 | - 'clear' => [ |
|
| 71 | - 'save' => ['oauthClient'], |
|
| 72 | - 'delete' => ['oauthClient'], |
|
| 73 | - 'restore' => ['oauthClient'], |
|
| 74 | - 'revoke' => ['oauthClient'], |
|
| 75 | - 'ubRevoke' => ['oauthClient'], |
|
| 76 | - 'regenerateSecret' => ['oauthClient'], |
|
| 77 | - ], |
|
| 78 | - ], |
|
| 79 | - 'setting' => [ |
|
| 80 | - 'cache' => [ |
|
| 81 | - 'list', |
|
| 82 | - 'find', |
|
| 83 | - 'findBy', |
|
| 84 | - 'paginate', |
|
| 85 | - 'paginateBy', |
|
| 86 | - 'first', |
|
| 87 | - 'deleted' |
|
| 88 | - ], |
|
| 89 | - 'clear' => [ |
|
| 90 | - 'save' => ['setting'], |
|
| 91 | - 'delete' => ['setting'], |
|
| 92 | - 'restore' => ['setting'], |
|
| 93 | - 'saveMany' => ['setting'], |
|
| 94 | - ] |
|
| 95 | - ] |
|
| 96 | - ] |
|
| 59 | + 'cache_config' => [ |
|
| 60 | + 'oauthClient' => [ |
|
| 61 | + 'cache' => [ |
|
| 62 | + 'list', |
|
| 63 | + 'find', |
|
| 64 | + 'findBy', |
|
| 65 | + 'paginate', |
|
| 66 | + 'paginateBy', |
|
| 67 | + 'first', |
|
| 68 | + 'deleted' |
|
| 69 | + ], |
|
| 70 | + 'clear' => [ |
|
| 71 | + 'save' => ['oauthClient'], |
|
| 72 | + 'delete' => ['oauthClient'], |
|
| 73 | + 'restore' => ['oauthClient'], |
|
| 74 | + 'revoke' => ['oauthClient'], |
|
| 75 | + 'ubRevoke' => ['oauthClient'], |
|
| 76 | + 'regenerateSecret' => ['oauthClient'], |
|
| 77 | + ], |
|
| 78 | + ], |
|
| 79 | + 'setting' => [ |
|
| 80 | + 'cache' => [ |
|
| 81 | + 'list', |
|
| 82 | + 'find', |
|
| 83 | + 'findBy', |
|
| 84 | + 'paginate', |
|
| 85 | + 'paginateBy', |
|
| 86 | + 'first', |
|
| 87 | + 'deleted' |
|
| 88 | + ], |
|
| 89 | + 'clear' => [ |
|
| 90 | + 'save' => ['setting'], |
|
| 91 | + 'delete' => ['setting'], |
|
| 92 | + 'restore' => ['setting'], |
|
| 93 | + 'saveMany' => ['setting'], |
|
| 94 | + ] |
|
| 95 | + ] |
|
| 96 | + ] |
|
| 97 | 97 | ]; |
@@ -7,40 +7,40 @@ |
||
| 7 | 7 | |
| 8 | 8 | class PassportInstallCommand extends Command |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * The name and signature of the console command. |
|
| 12 | - * |
|
| 13 | - * @var string |
|
| 14 | - */ |
|
| 15 | - protected $signature = 'module:passport:install |
|
| 10 | + /** |
|
| 11 | + * The name and signature of the console command. |
|
| 12 | + * |
|
| 13 | + * @var string |
|
| 14 | + */ |
|
| 15 | + protected $signature = 'module:passport:install |
|
| 16 | 16 | {--force : Overwrite keys they already exist} |
| 17 | 17 | {--length=4096 : The length of the private key}'; |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * The console command description. |
|
| 21 | - * |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - protected $description = 'Run the commands necessary to prepare Passport for use'; |
|
| 19 | + /** |
|
| 20 | + * The console command description. |
|
| 21 | + * |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + protected $description = 'Run the commands necessary to prepare Passport for use'; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Execute the console command. |
|
| 28 | - * |
|
| 29 | - * @return void |
|
| 30 | - */ |
|
| 31 | - public function handle(ClientRepository $client) |
|
| 32 | - { |
|
| 33 | - $this->call('passport:keys', ['--force' => $this->option('force'), '--length' => $this->option('length')]); |
|
| 34 | - $oauthClient = \Core::oauthCLients()->first(['password_client' => 1]); |
|
| 35 | - if (! $oauthClient) { |
|
| 36 | - $oauthClient = $client->createPasswordGrantClient( |
|
| 37 | - null, |
|
| 38 | - config('app.name'), |
|
| 39 | - 'http://localhost' |
|
| 40 | - ); |
|
| 41 | - } |
|
| 42 | - \DotenvEditor::setKey('PASSWORD_CLIENT_ID', $oauthClient->id); |
|
| 43 | - \DotenvEditor::setKey('PASSWORD_CLIENT_SECRET', $oauthClient->secret); |
|
| 44 | - \DotenvEditor::save(); |
|
| 45 | - } |
|
| 26 | + /** |
|
| 27 | + * Execute the console command. |
|
| 28 | + * |
|
| 29 | + * @return void |
|
| 30 | + */ |
|
| 31 | + public function handle(ClientRepository $client) |
|
| 32 | + { |
|
| 33 | + $this->call('passport:keys', ['--force' => $this->option('force'), '--length' => $this->option('length')]); |
|
| 34 | + $oauthClient = \Core::oauthCLients()->first(['password_client' => 1]); |
|
| 35 | + if (! $oauthClient) { |
|
| 36 | + $oauthClient = $client->createPasswordGrantClient( |
|
| 37 | + null, |
|
| 38 | + config('app.name'), |
|
| 39 | + 'http://localhost' |
|
| 40 | + ); |
|
| 41 | + } |
|
| 42 | + \DotenvEditor::setKey('PASSWORD_CLIENT_ID', $oauthClient->id); |
|
| 43 | + \DotenvEditor::setKey('PASSWORD_CLIENT_SECRET', $oauthClient->secret); |
|
| 44 | + \DotenvEditor::save(); |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | { |
| 33 | 33 | $this->call('passport:keys', ['--force' => $this->option('force'), '--length' => $this->option('length')]); |
| 34 | 34 | $oauthClient = \Core::oauthCLients()->first(['password_client' => 1]); |
| 35 | - if (! $oauthClient) { |
|
| 35 | + if ( ! $oauthClient) { |
|
| 36 | 36 | $oauthClient = $client->createPasswordGrantClient( |
| 37 | 37 | null, |
| 38 | 38 | config('app.name'), |
@@ -8,42 +8,42 @@ |
||
| 8 | 8 | |
| 9 | 9 | class DummyController extends BaseApiController |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * Path of the sotre form request. |
|
| 13 | - * |
|
| 14 | - * @var string |
|
| 15 | - */ |
|
| 16 | - protected $storeFormRequest = 'App\Modules\DummyModule\Http\Requests\StoreDummy'; |
|
| 11 | + /** |
|
| 12 | + * Path of the sotre form request. |
|
| 13 | + * |
|
| 14 | + * @var string |
|
| 15 | + */ |
|
| 16 | + protected $storeFormRequest = 'App\Modules\DummyModule\Http\Requests\StoreDummy'; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Path of the model resource |
|
| 20 | - * |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - protected $modelResource = 'App\Modules\DummyModule\Http\Resources\DummyModel'; |
|
| 18 | + /** |
|
| 19 | + * Path of the model resource |
|
| 20 | + * |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + protected $modelResource = 'App\Modules\DummyModule\Http\Resources\DummyModel'; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * List of all route actions that the base api controller |
|
| 27 | - * will skip permissions check for them. |
|
| 28 | - * @var array |
|
| 29 | - */ |
|
| 30 | - protected $skipPermissionCheck = []; |
|
| 25 | + /** |
|
| 26 | + * List of all route actions that the base api controller |
|
| 27 | + * will skip permissions check for them. |
|
| 28 | + * @var array |
|
| 29 | + */ |
|
| 30 | + protected $skipPermissionCheck = []; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * List of all route actions that the base api controller |
|
| 34 | - * will skip login check for them. |
|
| 35 | - * @var array |
|
| 36 | - */ |
|
| 37 | - protected $skipLoginCheck = []; |
|
| 32 | + /** |
|
| 33 | + * List of all route actions that the base api controller |
|
| 34 | + * will skip login check for them. |
|
| 35 | + * @var array |
|
| 36 | + */ |
|
| 37 | + protected $skipLoginCheck = []; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Init new object. |
|
| 41 | - * |
|
| 42 | - * @param DummyService $service |
|
| 43 | - * @return void |
|
| 44 | - */ |
|
| 45 | - public function __construct(DummyService $service) |
|
| 46 | - { |
|
| 47 | - parent::__construct($service); |
|
| 48 | - } |
|
| 39 | + /** |
|
| 40 | + * Init new object. |
|
| 41 | + * |
|
| 42 | + * @param DummyService $service |
|
| 43 | + * @return void |
|
| 44 | + */ |
|
| 45 | + public function __construct(DummyService $service) |
|
| 46 | + { |
|
| 47 | + parent::__construct($service); |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -6,25 +6,25 @@ |
||
| 6 | 6 | |
| 7 | 7 | class StoreDummy extends FormRequest |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Determine if the user is authorized to make this request. |
|
| 11 | - * |
|
| 12 | - * @return bool |
|
| 13 | - */ |
|
| 14 | - public function authorize() |
|
| 15 | - { |
|
| 16 | - return true; |
|
| 17 | - } |
|
| 9 | + /** |
|
| 10 | + * Determine if the user is authorized to make this request. |
|
| 11 | + * |
|
| 12 | + * @return bool |
|
| 13 | + */ |
|
| 14 | + public function authorize() |
|
| 15 | + { |
|
| 16 | + return true; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Get the validation rules that apply to the request. |
|
| 21 | - * |
|
| 22 | - * @return array |
|
| 23 | - */ |
|
| 24 | - public function rules() |
|
| 25 | - { |
|
| 26 | - return [ |
|
| 27 | - // |
|
| 28 | - ]; |
|
| 29 | - } |
|
| 19 | + /** |
|
| 20 | + * Get the validation rules that apply to the request. |
|
| 21 | + * |
|
| 22 | + * @return array |
|
| 23 | + */ |
|
| 24 | + public function rules() |
|
| 25 | + { |
|
| 26 | + return [ |
|
| 27 | + // |
|
| 28 | + ]; |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -8,16 +8,16 @@ |
||
| 8 | 8 | |
| 9 | 9 | class DummyModel extends Model |
| 10 | 10 | { |
| 11 | - use SoftDeletes; |
|
| 12 | - protected $table = 'DummyTableName'; |
|
| 13 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 14 | - protected $hidden = ['deleted_at']; |
|
| 15 | - protected $guarded = ['id']; |
|
| 16 | - public $fillable = []; // Add attributes here |
|
| 11 | + use SoftDeletes; |
|
| 12 | + protected $table = 'DummyTableName'; |
|
| 13 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 14 | + protected $hidden = ['deleted_at']; |
|
| 15 | + protected $guarded = ['id']; |
|
| 16 | + public $fillable = []; // Add attributes here |
|
| 17 | 17 | |
| 18 | - public static function boot() |
|
| 19 | - { |
|
| 20 | - parent::boot(); |
|
| 21 | - DummyModel::observe(DummyObserver::class); |
|
| 22 | - } |
|
| 18 | + public static function boot() |
|
| 19 | + { |
|
| 20 | + parent::boot(); |
|
| 21 | + DummyModel::observe(DummyObserver::class); |
|
| 22 | + } |
|
| 23 | 23 | } |
@@ -6,64 +6,64 @@ |
||
| 6 | 6 | |
| 7 | 7 | class DummyTableSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - /** |
|
| 17 | - * Insert the permissions related to DummyModelName table. |
|
| 18 | - */ |
|
| 19 | - \DB::table('permissions')->insert( |
|
| 20 | - [ |
|
| 21 | - /** |
|
| 22 | - * DummyModelName model permissions. |
|
| 23 | - */ |
|
| 24 | - [ |
|
| 25 | - 'name' => 'index', |
|
| 26 | - 'model' => 'DummyModelName', |
|
| 27 | - 'created_at' => \DB::raw('NOW()'), |
|
| 28 | - 'updated_at' => \DB::raw('NOW()') |
|
| 29 | - ], |
|
| 30 | - [ |
|
| 31 | - 'name' => 'show', |
|
| 32 | - 'model' => 'DummyModelName', |
|
| 33 | - 'created_at' => \DB::raw('NOW()'), |
|
| 34 | - 'updated_at' => \DB::raw('NOW()') |
|
| 35 | - ], |
|
| 36 | - [ |
|
| 37 | - 'name' => 'store', |
|
| 38 | - 'model' => 'DummyModelName', |
|
| 39 | - 'created_at' => \DB::raw('NOW()'), |
|
| 40 | - 'updated_at' => \DB::raw('NOW()') |
|
| 41 | - ], |
|
| 42 | - [ |
|
| 43 | - 'name' => 'update', |
|
| 44 | - 'model' => 'DummyModelName', |
|
| 45 | - 'created_at' => \DB::raw('NOW()'), |
|
| 46 | - 'updated_at' => \DB::raw('NOW()') |
|
| 47 | - ], |
|
| 48 | - [ |
|
| 49 | - 'name' => 'destroy', |
|
| 50 | - 'model' => 'DummyModelName', |
|
| 51 | - 'created_at' => \DB::raw('NOW()'), |
|
| 52 | - 'updated_at' => \DB::raw('NOW()') |
|
| 53 | - ], |
|
| 54 | - [ |
|
| 55 | - 'name' => 'deleted', |
|
| 56 | - 'model' => 'DummyModelName', |
|
| 57 | - 'created_at' => \DB::raw('NOW()'), |
|
| 58 | - 'updated_at' => \DB::raw('NOW()') |
|
| 59 | - ], |
|
| 60 | - [ |
|
| 61 | - 'name' => 'restore', |
|
| 62 | - 'model' => 'DummyModelName', |
|
| 63 | - 'created_at' => \DB::raw('NOW()'), |
|
| 64 | - 'updated_at' => \DB::raw('NOW()') |
|
| 65 | - ] |
|
| 66 | - ] |
|
| 67 | - ); |
|
| 68 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + /** |
|
| 17 | + * Insert the permissions related to DummyModelName table. |
|
| 18 | + */ |
|
| 19 | + \DB::table('permissions')->insert( |
|
| 20 | + [ |
|
| 21 | + /** |
|
| 22 | + * DummyModelName model permissions. |
|
| 23 | + */ |
|
| 24 | + [ |
|
| 25 | + 'name' => 'index', |
|
| 26 | + 'model' => 'DummyModelName', |
|
| 27 | + 'created_at' => \DB::raw('NOW()'), |
|
| 28 | + 'updated_at' => \DB::raw('NOW()') |
|
| 29 | + ], |
|
| 30 | + [ |
|
| 31 | + 'name' => 'show', |
|
| 32 | + 'model' => 'DummyModelName', |
|
| 33 | + 'created_at' => \DB::raw('NOW()'), |
|
| 34 | + 'updated_at' => \DB::raw('NOW()') |
|
| 35 | + ], |
|
| 36 | + [ |
|
| 37 | + 'name' => 'store', |
|
| 38 | + 'model' => 'DummyModelName', |
|
| 39 | + 'created_at' => \DB::raw('NOW()'), |
|
| 40 | + 'updated_at' => \DB::raw('NOW()') |
|
| 41 | + ], |
|
| 42 | + [ |
|
| 43 | + 'name' => 'update', |
|
| 44 | + 'model' => 'DummyModelName', |
|
| 45 | + 'created_at' => \DB::raw('NOW()'), |
|
| 46 | + 'updated_at' => \DB::raw('NOW()') |
|
| 47 | + ], |
|
| 48 | + [ |
|
| 49 | + 'name' => 'destroy', |
|
| 50 | + 'model' => 'DummyModelName', |
|
| 51 | + 'created_at' => \DB::raw('NOW()'), |
|
| 52 | + 'updated_at' => \DB::raw('NOW()') |
|
| 53 | + ], |
|
| 54 | + [ |
|
| 55 | + 'name' => 'deleted', |
|
| 56 | + 'model' => 'DummyModelName', |
|
| 57 | + 'created_at' => \DB::raw('NOW()'), |
|
| 58 | + 'updated_at' => \DB::raw('NOW()') |
|
| 59 | + ], |
|
| 60 | + [ |
|
| 61 | + 'name' => 'restore', |
|
| 62 | + 'model' => 'DummyModelName', |
|
| 63 | + 'created_at' => \DB::raw('NOW()'), |
|
| 64 | + 'updated_at' => \DB::raw('NOW()') |
|
| 65 | + ] |
|
| 66 | + ] |
|
| 67 | + ); |
|
| 68 | + } |
|
| 69 | 69 | } |