@@ -7,75 +7,75 @@ |
||
| 7 | 7 | class ModuleServiceProvider extends ServiceProvider |
| 8 | 8 | { |
| 9 | 9 | /** |
| 10 | - * Bootstrap the module services. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function boot() |
|
| 15 | - { |
|
| 16 | - $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'core'); |
|
| 17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'core'); |
|
| 10 | + * Bootstrap the module services. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function boot() |
|
| 15 | + { |
|
| 16 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'core'); |
|
| 17 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'core'); |
|
| 18 | 18 | |
| 19 | - $factory = app('Illuminate\Database\Eloquent\Factory'); |
|
| 20 | - $factory->load(__DIR__.'/../Database/Factories'); |
|
| 21 | - } |
|
| 19 | + $factory = app('Illuminate\Database\Eloquent\Factory'); |
|
| 20 | + $factory->load(__DIR__.'/../Database/Factories'); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Register the module services. |
|
| 25 | - * |
|
| 26 | - * @return void |
|
| 27 | - */ |
|
| 28 | - public function register() |
|
| 29 | - { |
|
| 30 | - //Bind Core Facade to the IoC Container |
|
| 31 | - \App::bind('Core', function() |
|
| 32 | - { |
|
| 33 | - return new \App\Modules\Core\Core; |
|
| 34 | - }); |
|
| 23 | + /** |
|
| 24 | + * Register the module services. |
|
| 25 | + * |
|
| 26 | + * @return void |
|
| 27 | + */ |
|
| 28 | + public function register() |
|
| 29 | + { |
|
| 30 | + //Bind Core Facade to the IoC Container |
|
| 31 | + \App::bind('Core', function() |
|
| 32 | + { |
|
| 33 | + return new \App\Modules\Core\Core; |
|
| 34 | + }); |
|
| 35 | 35 | |
| 36 | - //Bind ErrorHandler Facade to the IoC Container |
|
| 37 | - \App::bind('ErrorHandler', function() |
|
| 38 | - { |
|
| 39 | - return new \App\Modules\Core\Utl\ErrorHandler; |
|
| 40 | - }); |
|
| 36 | + //Bind ErrorHandler Facade to the IoC Container |
|
| 37 | + \App::bind('ErrorHandler', function() |
|
| 38 | + { |
|
| 39 | + return new \App\Modules\Core\Utl\ErrorHandler; |
|
| 40 | + }); |
|
| 41 | 41 | |
| 42 | - //Bind CoreConfig Facade to the IoC Container |
|
| 43 | - \App::bind('CoreConfig', function() |
|
| 44 | - { |
|
| 45 | - return new \App\Modules\Core\Utl\CoreConfig; |
|
| 46 | - }); |
|
| 42 | + //Bind CoreConfig Facade to the IoC Container |
|
| 43 | + \App::bind('CoreConfig', function() |
|
| 44 | + { |
|
| 45 | + return new \App\Modules\Core\Utl\CoreConfig; |
|
| 46 | + }); |
|
| 47 | 47 | |
| 48 | - //Bind Mpgs Facade to the IoC Container |
|
| 49 | - \App::bind('Media', function() |
|
| 50 | - { |
|
| 51 | - return new \App\Modules\Core\Utl\Media; |
|
| 52 | - }); |
|
| 48 | + //Bind Mpgs Facade to the IoC Container |
|
| 49 | + \App::bind('Media', function() |
|
| 50 | + { |
|
| 51 | + return new \App\Modules\Core\Utl\Media; |
|
| 52 | + }); |
|
| 53 | 53 | |
| 54 | - \Validator::extend('base64image', function ($attribute, $value, $parameters, $validator) { |
|
| 55 | - $explode = explode(',', $value); |
|
| 56 | - $allow = ['png', 'jpg', 'svg']; |
|
| 57 | - $format = str_replace( |
|
| 58 | - [ |
|
| 59 | - 'data:image/', |
|
| 60 | - ';', |
|
| 61 | - 'base64', |
|
| 62 | - ], |
|
| 63 | - [ |
|
| 64 | - '', '', '', |
|
| 65 | - ], |
|
| 66 | - $explode[0] |
|
| 67 | - ); |
|
| 68 | - // check file format |
|
| 69 | - if (!in_array($format, $allow)) { |
|
| 70 | - return false; |
|
| 71 | - } |
|
| 72 | - // check base64 format |
|
| 73 | - if (!preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $explode[1])) { |
|
| 74 | - return false; |
|
| 75 | - } |
|
| 76 | - return true; |
|
| 77 | - }); |
|
| 54 | + \Validator::extend('base64image', function ($attribute, $value, $parameters, $validator) { |
|
| 55 | + $explode = explode(',', $value); |
|
| 56 | + $allow = ['png', 'jpg', 'svg']; |
|
| 57 | + $format = str_replace( |
|
| 58 | + [ |
|
| 59 | + 'data:image/', |
|
| 60 | + ';', |
|
| 61 | + 'base64', |
|
| 62 | + ], |
|
| 63 | + [ |
|
| 64 | + '', '', '', |
|
| 65 | + ], |
|
| 66 | + $explode[0] |
|
| 67 | + ); |
|
| 68 | + // check file format |
|
| 69 | + if (!in_array($format, $allow)) { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 72 | + // check base64 format |
|
| 73 | + if (!preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $explode[1])) { |
|
| 74 | + return false; |
|
| 75 | + } |
|
| 76 | + return true; |
|
| 77 | + }); |
|
| 78 | 78 | |
| 79 | - $this->app->register(RouteServiceProvider::class); |
|
| 80 | - } |
|
| 79 | + $this->app->register(RouteServiceProvider::class); |
|
| 80 | + } |
|
| 81 | 81 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | return new \App\Modules\Core\Utl\Media; |
| 52 | 52 | }); |
| 53 | 53 | |
| 54 | - \Validator::extend('base64image', function ($attribute, $value, $parameters, $validator) { |
|
| 54 | + \Validator::extend('base64image', function($attribute, $value, $parameters, $validator) { |
|
| 55 | 55 | $explode = explode(',', $value); |
| 56 | 56 | $allow = ['png', 'jpg', 'svg']; |
| 57 | 57 | $format = str_replace( |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | $explode[0] |
| 67 | 67 | ); |
| 68 | 68 | // check file format |
| 69 | - if (!in_array($format, $allow)) { |
|
| 69 | + if ( ! in_array($format, $allow)) { |
|
| 70 | 70 | return false; |
| 71 | 71 | } |
| 72 | 72 | // check base64 format |
| 73 | - if (!preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $explode[1])) { |
|
| 73 | + if ( ! preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $explode[1])) { |
|
| 74 | 74 | return false; |
| 75 | 75 | } |
| 76 | 76 | return true; |
@@ -2,117 +2,117 @@ |
||
| 2 | 2 | |
| 3 | 3 | class CachingDecorator |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * The repo implementation. |
|
| 7 | - * |
|
| 8 | - * @var string |
|
| 9 | - */ |
|
| 10 | - public $repo; |
|
| 5 | + /** |
|
| 6 | + * The repo implementation. |
|
| 7 | + * |
|
| 8 | + * @var string |
|
| 9 | + */ |
|
| 10 | + public $repo; |
|
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * The cache implementation. |
|
| 14 | - * |
|
| 15 | - * @var object |
|
| 16 | - */ |
|
| 17 | - protected $cache; |
|
| 12 | + /** |
|
| 13 | + * The cache implementation. |
|
| 14 | + * |
|
| 15 | + * @var object |
|
| 16 | + */ |
|
| 17 | + protected $cache; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * The modelKey implementation. |
|
| 21 | - * |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - public $modelKey; |
|
| 19 | + /** |
|
| 20 | + * The modelKey implementation. |
|
| 21 | + * |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + public $modelKey; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * The model implementation. |
|
| 28 | - * |
|
| 29 | - * @var string |
|
| 30 | - */ |
|
| 31 | - public $model; |
|
| 26 | + /** |
|
| 27 | + * The model implementation. |
|
| 28 | + * |
|
| 29 | + * @var string |
|
| 30 | + */ |
|
| 31 | + public $model; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * The modelClass implementation. |
|
| 35 | - * |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 38 | - public $modelClass; |
|
| 33 | + /** |
|
| 34 | + * The modelClass implementation. |
|
| 35 | + * |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | + public $modelClass; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * The cacheConfig implementation. |
|
| 42 | - * |
|
| 43 | - * @var array |
|
| 44 | - */ |
|
| 45 | - public $cacheConfig; |
|
| 40 | + /** |
|
| 41 | + * The cacheConfig implementation. |
|
| 42 | + * |
|
| 43 | + * @var array |
|
| 44 | + */ |
|
| 45 | + public $cacheConfig; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * The cacheTag implementation. |
|
| 49 | - * |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 52 | - public $cacheTag; |
|
| 47 | + /** |
|
| 48 | + * The cacheTag implementation. |
|
| 49 | + * |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | + public $cacheTag; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Create new CachingDecorator instance. |
|
| 56 | - */ |
|
| 57 | - public function __construct($repo, $cache) |
|
| 58 | - { |
|
| 59 | - $this->repo = $repo; |
|
| 60 | - $this->cache = $cache; |
|
| 61 | - $this->model = $this->repo->model; |
|
| 62 | - $this->modelClass = get_class($this->model); |
|
| 63 | - $repoClass = explode('\\', get_class($this->repo)); |
|
| 64 | - $repoName = end($repoClass); |
|
| 65 | - $this->cacheTag = str_plural(lcfirst(substr($repoName, 0, strpos($repoName, 'Repository')))); |
|
| 66 | - } |
|
| 54 | + /** |
|
| 55 | + * Create new CachingDecorator instance. |
|
| 56 | + */ |
|
| 57 | + public function __construct($repo, $cache) |
|
| 58 | + { |
|
| 59 | + $this->repo = $repo; |
|
| 60 | + $this->cache = $cache; |
|
| 61 | + $this->model = $this->repo->model; |
|
| 62 | + $this->modelClass = get_class($this->model); |
|
| 63 | + $repoClass = explode('\\', get_class($this->repo)); |
|
| 64 | + $repoName = end($repoClass); |
|
| 65 | + $this->cacheTag = str_plural(lcfirst(substr($repoName, 0, strpos($repoName, 'Repository')))); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Handle the cache mechanism for the called method |
|
| 70 | - * based the configurations. |
|
| 71 | - * |
|
| 72 | - * @param string $name the called method name |
|
| 73 | - * @param array $arguments the method arguments |
|
| 74 | - * @return object |
|
| 75 | - */ |
|
| 76 | - public function __call($name, $arguments) |
|
| 77 | - { |
|
| 78 | - $this->setCacheConfig($name); |
|
| 68 | + /** |
|
| 69 | + * Handle the cache mechanism for the called method |
|
| 70 | + * based the configurations. |
|
| 71 | + * |
|
| 72 | + * @param string $name the called method name |
|
| 73 | + * @param array $arguments the method arguments |
|
| 74 | + * @return object |
|
| 75 | + */ |
|
| 76 | + public function __call($name, $arguments) |
|
| 77 | + { |
|
| 78 | + $this->setCacheConfig($name); |
|
| 79 | 79 | |
| 80 | - if ($this->cacheConfig && $this->cacheConfig == 'cache') |
|
| 81 | - { |
|
| 82 | - $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
|
| 83 | - $cacheKey = $name . $page . \Session::get('locale') . serialize($arguments); |
|
| 84 | - return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
|
| 85 | - return call_user_func_array([$this->repo, $name], $arguments); |
|
| 86 | - }); |
|
| 87 | - } |
|
| 88 | - else if ($this->cacheConfig) |
|
| 89 | - { |
|
| 90 | - $this->cache->tags($this->cacheConfig)->flush(); |
|
| 91 | - return call_user_func_array([$this->repo, $name], $arguments); |
|
| 92 | - } |
|
| 80 | + if ($this->cacheConfig && $this->cacheConfig == 'cache') |
|
| 81 | + { |
|
| 82 | + $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
|
| 83 | + $cacheKey = $name . $page . \Session::get('locale') . serialize($arguments); |
|
| 84 | + return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
|
| 85 | + return call_user_func_array([$this->repo, $name], $arguments); |
|
| 86 | + }); |
|
| 87 | + } |
|
| 88 | + else if ($this->cacheConfig) |
|
| 89 | + { |
|
| 90 | + $this->cache->tags($this->cacheConfig)->flush(); |
|
| 91 | + return call_user_func_array([$this->repo, $name], $arguments); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - return call_user_func_array([$this->repo, $name], $arguments); |
|
| 95 | - } |
|
| 94 | + return call_user_func_array([$this->repo, $name], $arguments); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Set cache config based on the called method. |
|
| 99 | - * |
|
| 100 | - * @param string $name |
|
| 101 | - * @return void |
|
| 102 | - */ |
|
| 103 | - private function setCacheConfig($name) |
|
| 104 | - { |
|
| 105 | - $config = \CoreConfig::getConfig(); |
|
| 106 | - $cacheConfig = array_key_exists($this->cacheTag, $config['cacheConfig']) ? $config['cacheConfig'][$this->cacheTag] : false; |
|
| 107 | - $this->cacheConfig = false; |
|
| 97 | + /** |
|
| 98 | + * Set cache config based on the called method. |
|
| 99 | + * |
|
| 100 | + * @param string $name |
|
| 101 | + * @return void |
|
| 102 | + */ |
|
| 103 | + private function setCacheConfig($name) |
|
| 104 | + { |
|
| 105 | + $config = \CoreConfig::getConfig(); |
|
| 106 | + $cacheConfig = array_key_exists($this->cacheTag, $config['cacheConfig']) ? $config['cacheConfig'][$this->cacheTag] : false; |
|
| 107 | + $this->cacheConfig = false; |
|
| 108 | 108 | |
| 109 | - if ($cacheConfig && in_array($name, $cacheConfig['cache'])) |
|
| 110 | - { |
|
| 111 | - $this->cacheConfig = 'cache'; |
|
| 112 | - } |
|
| 113 | - else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
| 114 | - { |
|
| 115 | - $this->cacheConfig = $cacheConfig['clear'][$name]; |
|
| 116 | - } |
|
| 117 | - } |
|
| 109 | + if ($cacheConfig && in_array($name, $cacheConfig['cache'])) |
|
| 110 | + { |
|
| 111 | + $this->cacheConfig = 'cache'; |
|
| 112 | + } |
|
| 113 | + else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
| 114 | + { |
|
| 115 | + $this->cacheConfig = $cacheConfig['clear'][$name]; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | 118 | } |
| 119 | 119 | \ No newline at end of file |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | if ($this->cacheConfig && $this->cacheConfig == 'cache') |
| 65 | 65 | { |
| 66 | 66 | $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
| 67 | - $cacheKey = $name . $page . \Session::get('locale') . serialize($arguments); |
|
| 67 | + $cacheKey = $name.$page.\Session::get('locale').serialize($arguments); |
|
| 68 | 68 | return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
| 69 | 69 | return call_user_func_array([$this->repo, $name], $arguments); |
| 70 | 70 | }); |
@@ -68,8 +68,7 @@ discard block |
||
| 68 | 68 | return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
| 69 | 69 | return call_user_func_array([$this->repo, $name], $arguments); |
| 70 | 70 | }); |
| 71 | - } |
|
| 72 | - else if ($this->cacheConfig) |
|
| 71 | + } else if ($this->cacheConfig) |
|
| 73 | 72 | { |
| 74 | 73 | $this->cache->tags($this->cacheConfig)->flush(); |
| 75 | 74 | return call_user_func_array([$this->repo, $name], $arguments); |
@@ -93,8 +92,7 @@ discard block |
||
| 93 | 92 | if ($cacheConfig && in_array($name, $cacheConfig['cache'])) |
| 94 | 93 | { |
| 95 | 94 | $this->cacheConfig = 'cache'; |
| 96 | - } |
|
| 97 | - else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
| 95 | + } else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
| 98 | 96 | { |
| 99 | 97 | $this->cacheConfig = $cacheConfig['clear'][$name]; |
| 100 | 98 | } |
@@ -2,51 +2,51 @@ |
||
| 2 | 2 | |
| 3 | 3 | trait Translatable |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * Create a new model instance that is existing. |
|
| 7 | - * |
|
| 8 | - * @param array $attributes |
|
| 9 | - * @param string|null $connection |
|
| 10 | - * @return static |
|
| 11 | - */ |
|
| 12 | - public function newFromBuilder($attributes = [], $connection = null) |
|
| 13 | - { |
|
| 14 | - $model = parent::newFromBuilder($attributes, $connection); |
|
| 5 | + /** |
|
| 6 | + * Create a new model instance that is existing. |
|
| 7 | + * |
|
| 8 | + * @param array $attributes |
|
| 9 | + * @param string|null $connection |
|
| 10 | + * @return static |
|
| 11 | + */ |
|
| 12 | + public function newFromBuilder($attributes = [], $connection = null) |
|
| 13 | + { |
|
| 14 | + $model = parent::newFromBuilder($attributes, $connection); |
|
| 15 | 15 | |
| 16 | - foreach ($model->attributes AS $key => $value) |
|
| 17 | - { |
|
| 18 | - if (isset($this->translatable) && in_array($key, $this->translatable)) |
|
| 19 | - { |
|
| 20 | - $model->$key = $this->getTranslatedAttribute($key, $value); |
|
| 21 | - } |
|
| 22 | - } |
|
| 16 | + foreach ($model->attributes AS $key => $value) |
|
| 17 | + { |
|
| 18 | + if (isset($this->translatable) && in_array($key, $this->translatable)) |
|
| 19 | + { |
|
| 20 | + $model->$key = $this->getTranslatedAttribute($key, $value); |
|
| 21 | + } |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - return $model; |
|
| 25 | - } |
|
| 24 | + return $model; |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Returns a translatable model attribute based on the application's locale settings. |
|
| 29 | - * |
|
| 30 | - * @param $key |
|
| 31 | - * @param $values |
|
| 32 | - * @return string |
|
| 33 | - */ |
|
| 34 | - protected function getTranslatedAttribute($key, $values) |
|
| 35 | - { |
|
| 36 | - $values = json_decode($values); |
|
| 37 | - $primaryLocale = \Session::get('locale'); |
|
| 38 | - $fallbackLocale = 'en'; |
|
| 27 | + /** |
|
| 28 | + * Returns a translatable model attribute based on the application's locale settings. |
|
| 29 | + * |
|
| 30 | + * @param $key |
|
| 31 | + * @param $values |
|
| 32 | + * @return string |
|
| 33 | + */ |
|
| 34 | + protected function getTranslatedAttribute($key, $values) |
|
| 35 | + { |
|
| 36 | + $values = json_decode($values); |
|
| 37 | + $primaryLocale = \Session::get('locale'); |
|
| 38 | + $fallbackLocale = 'en'; |
|
| 39 | 39 | |
| 40 | - if ($primaryLocale == 'all') |
|
| 41 | - { |
|
| 42 | - return $values; |
|
| 43 | - } |
|
| 40 | + if ($primaryLocale == 'all') |
|
| 41 | + { |
|
| 42 | + return $values; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - if ( ! $primaryLocale || ! is_object($values) || ! property_exists($values, $primaryLocale)) |
|
| 46 | - { |
|
| 47 | - return $values ? isset($values->$fallbackLocale) ? $values->$fallbackLocale : $values : ''; |
|
| 48 | - } |
|
| 45 | + if ( ! $primaryLocale || ! is_object($values) || ! property_exists($values, $primaryLocale)) |
|
| 46 | + { |
|
| 47 | + return $values ? isset($values->$fallbackLocale) ? $values->$fallbackLocale : $values : ''; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - return $primaryLocale == 'all' ? $values : $values->$primaryLocale; |
|
| 51 | - } |
|
| 50 | + return $primaryLocale == 'all' ? $values : $values->$primaryLocale; |
|
| 51 | + } |
|
| 52 | 52 | } |
| 53 | 53 | \ No newline at end of file |
@@ -4,39 +4,39 @@ |
||
| 4 | 4 | |
| 5 | 5 | abstract class AbstractRepositoryContainer implements RepositoryContainerInterface |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Construct the repository class name based on |
|
| 9 | - * the method name called, search in the |
|
| 10 | - * given namespaces for the class and |
|
| 11 | - * return an instance. |
|
| 12 | - * |
|
| 13 | - * @param string $name the called method name |
|
| 14 | - * @param array $arguments the method arguments |
|
| 15 | - * @return object |
|
| 16 | - */ |
|
| 17 | - public function __call($name, $arguments) |
|
| 18 | - { |
|
| 19 | - foreach ($this->getRepoNameSpace() as $repoNameSpace) |
|
| 20 | - { |
|
| 21 | - $class = rtrim($repoNameSpace, '\\') . '\\' . ucfirst(str_singular($name)) . 'Repository'; |
|
| 22 | - if (class_exists($class)) |
|
| 23 | - { |
|
| 24 | - \App::singleton($class, function ($app) use ($class) { |
|
| 7 | + /** |
|
| 8 | + * Construct the repository class name based on |
|
| 9 | + * the method name called, search in the |
|
| 10 | + * given namespaces for the class and |
|
| 11 | + * return an instance. |
|
| 12 | + * |
|
| 13 | + * @param string $name the called method name |
|
| 14 | + * @param array $arguments the method arguments |
|
| 15 | + * @return object |
|
| 16 | + */ |
|
| 17 | + public function __call($name, $arguments) |
|
| 18 | + { |
|
| 19 | + foreach ($this->getRepoNameSpace() as $repoNameSpace) |
|
| 20 | + { |
|
| 21 | + $class = rtrim($repoNameSpace, '\\') . '\\' . ucfirst(str_singular($name)) . 'Repository'; |
|
| 22 | + if (class_exists($class)) |
|
| 23 | + { |
|
| 24 | + \App::singleton($class, function ($app) use ($class) { |
|
| 25 | 25 | |
| 26 | - return new \App\Modules\Core\Decorators\CachingDecorator(new $class, $app['cache.store']); |
|
| 27 | - }); |
|
| 26 | + return new \App\Modules\Core\Decorators\CachingDecorator(new $class, $app['cache.store']); |
|
| 27 | + }); |
|
| 28 | 28 | |
| 29 | - return \App::make($class); |
|
| 30 | - } |
|
| 31 | - } |
|
| 32 | - } |
|
| 29 | + return \App::make($class); |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Abstract methods that return the necessary |
|
| 36 | - * information (repositories namespaces) |
|
| 37 | - * needed to preform the previous actions. |
|
| 38 | - * |
|
| 39 | - * @return array |
|
| 40 | - */ |
|
| 41 | - abstract protected function getRepoNameSpace(); |
|
| 34 | + /** |
|
| 35 | + * Abstract methods that return the necessary |
|
| 36 | + * information (repositories namespaces) |
|
| 37 | + * needed to preform the previous actions. |
|
| 38 | + * |
|
| 39 | + * @return array |
|
| 40 | + */ |
|
| 41 | + abstract protected function getRepoNameSpace(); |
|
| 42 | 42 | } |
| 43 | 43 | \ No newline at end of file |
@@ -18,10 +18,10 @@ |
||
| 18 | 18 | { |
| 19 | 19 | foreach ($this->getRepoNameSpace() as $repoNameSpace) |
| 20 | 20 | { |
| 21 | - $class = rtrim($repoNameSpace, '\\') . '\\' . ucfirst(str_singular($name)) . 'Repository'; |
|
| 21 | + $class = rtrim($repoNameSpace, '\\').'\\'.ucfirst(str_singular($name)).'Repository'; |
|
| 22 | 22 | if (class_exists($class)) |
| 23 | 23 | { |
| 24 | - \App::singleton($class, function ($app) use ($class) { |
|
| 24 | + \App::singleton($class, function($app) use ($class) { |
|
| 25 | 25 | |
| 26 | 26 | return new \App\Modules\Core\Decorators\CachingDecorator(new $class, $app['cache.store']); |
| 27 | 27 | }); |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | use App\Modules\Core\AbstractRepositories\AbstractRepositoryContainer; |
| 4 | 4 | |
| 5 | -class Core extends AbstractRepositoryContainer{ |
|
| 5 | +class Core extends AbstractRepositoryContainer { |
|
| 6 | 6 | /** |
| 7 | 7 | * Specify module repositories name space. |
| 8 | 8 | * |
@@ -6,20 +6,20 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | class AssignRelationsSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id; |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Assign the permissions to the admin group. |
|
| 20 | - */ |
|
| 21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['settings'])->each(function ($permission) use ($adminGroupId) { |
|
| 22 | - \DB::table('groups_permissions')->insert( |
|
| 18 | + /** |
|
| 19 | + * Assign the permissions to the admin group. |
|
| 20 | + */ |
|
| 21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['settings'])->each(function ($permission) use ($adminGroupId) { |
|
| 22 | + \DB::table('groups_permissions')->insert( |
|
| 23 | 23 | [ |
| 24 | 24 | 'permission_id' => $permission->id, |
| 25 | 25 | 'group_id' => $adminGroupId, |
@@ -27,6 +27,6 @@ discard block |
||
| 27 | 27 | 'updated_at' => \DB::raw('NOW()') |
| 28 | 28 | ] |
| 29 | 29 | ); |
| 30 | - }); |
|
| 31 | - } |
|
| 30 | + }); |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | /** |
| 19 | 19 | * Assign the permissions to the admin group. |
| 20 | 20 | */ |
| 21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['settings'])->each(function ($permission) use ($adminGroupId) { |
|
| 21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['settings'])->each(function($permission) use ($adminGroupId) { |
|
| 22 | 22 | \DB::table('groups_permissions')->insert( |
| 23 | 23 | [ |
| 24 | 24 | 'permission_id' => $permission->id, |
@@ -6,15 +6,15 @@ |
||
| 6 | 6 | |
| 7 | 7 | class CoreDatabaseSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - $this->call(ClearDataSeeder::class); |
|
| 17 | - $this->call(SettingsTableSeeder::class); |
|
| 18 | - $this->call(AssignRelationsSeeder::class); |
|
| 19 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $this->call(ClearDataSeeder::class); |
|
| 17 | + $this->call(SettingsTableSeeder::class); |
|
| 18 | + $this->call(AssignRelationsSeeder::class); |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -6,15 +6,15 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ClearDataSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - $permissions = \DB::table('permissions')->whereIn('model', ['settings']); |
|
| 17 | - \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
| 18 | - $permissions->delete(); |
|
| 19 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $permissions = \DB::table('permissions')->whereIn('model', ['settings']); |
|
| 17 | + \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
| 18 | + $permissions->delete(); |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -6,76 +6,76 @@ |
||
| 6 | 6 | |
| 7 | 7 | class SettingsTableSeeder 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 settings table. |
|
| 18 | - */ |
|
| 19 | - \DB::table('permissions')->insert( |
|
| 20 | - [ |
|
| 21 | - /** |
|
| 22 | - * Settings model permissions. |
|
| 23 | - */ |
|
| 24 | - [ |
|
| 25 | - 'name' => 'save', |
|
| 26 | - 'model' => 'settings', |
|
| 27 | - 'created_at' => \DB::raw('NOW()'), |
|
| 28 | - 'updated_at' => \DB::raw('NOW()') |
|
| 29 | - ], |
|
| 30 | - [ |
|
| 31 | - 'name' => 'find', |
|
| 32 | - 'model' => 'settings', |
|
| 33 | - 'created_at' => \DB::raw('NOW()'), |
|
| 34 | - 'updated_at' => \DB::raw('NOW()') |
|
| 35 | - ], |
|
| 36 | - [ |
|
| 37 | - 'name' => 'search', |
|
| 38 | - 'model' => 'settings', |
|
| 39 | - 'created_at' => \DB::raw('NOW()'), |
|
| 40 | - 'updated_at' => \DB::raw('NOW()') |
|
| 41 | - ], |
|
| 42 | - [ |
|
| 43 | - 'name' => 'list', |
|
| 44 | - 'model' => 'settings', |
|
| 45 | - 'created_at' => \DB::raw('NOW()'), |
|
| 46 | - 'updated_at' => \DB::raw('NOW()') |
|
| 47 | - ], |
|
| 48 | - [ |
|
| 49 | - 'name' => 'findby', |
|
| 50 | - 'model' => 'settings', |
|
| 51 | - 'created_at' => \DB::raw('NOW()'), |
|
| 52 | - 'updated_at' => \DB::raw('NOW()') |
|
| 53 | - ], |
|
| 54 | - [ |
|
| 55 | - 'name' => 'first', |
|
| 56 | - 'model' => 'settings', |
|
| 57 | - 'created_at' => \DB::raw('NOW()'), |
|
| 58 | - 'updated_at' => \DB::raw('NOW()') |
|
| 59 | - ], |
|
| 60 | - [ |
|
| 61 | - 'name' => 'paginate', |
|
| 62 | - 'model' => 'settings', |
|
| 63 | - 'created_at' => \DB::raw('NOW()'), |
|
| 64 | - 'updated_at' => \DB::raw('NOW()') |
|
| 65 | - ], |
|
| 66 | - [ |
|
| 67 | - 'name' => 'paginateby', |
|
| 68 | - 'model' => 'settings', |
|
| 69 | - 'created_at' => \DB::raw('NOW()'), |
|
| 70 | - 'updated_at' => \DB::raw('NOW()') |
|
| 71 | - ], |
|
| 72 | - [ |
|
| 73 | - 'name' => 'saveMany', |
|
| 74 | - 'model' => 'settings', |
|
| 75 | - 'created_at' => \DB::raw('NOW()'), |
|
| 76 | - 'updated_at' => \DB::raw('NOW()') |
|
| 77 | - ] |
|
| 78 | - ] |
|
| 79 | - ); |
|
| 80 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + /** |
|
| 17 | + * Insert the permissions related to settings table. |
|
| 18 | + */ |
|
| 19 | + \DB::table('permissions')->insert( |
|
| 20 | + [ |
|
| 21 | + /** |
|
| 22 | + * Settings model permissions. |
|
| 23 | + */ |
|
| 24 | + [ |
|
| 25 | + 'name' => 'save', |
|
| 26 | + 'model' => 'settings', |
|
| 27 | + 'created_at' => \DB::raw('NOW()'), |
|
| 28 | + 'updated_at' => \DB::raw('NOW()') |
|
| 29 | + ], |
|
| 30 | + [ |
|
| 31 | + 'name' => 'find', |
|
| 32 | + 'model' => 'settings', |
|
| 33 | + 'created_at' => \DB::raw('NOW()'), |
|
| 34 | + 'updated_at' => \DB::raw('NOW()') |
|
| 35 | + ], |
|
| 36 | + [ |
|
| 37 | + 'name' => 'search', |
|
| 38 | + 'model' => 'settings', |
|
| 39 | + 'created_at' => \DB::raw('NOW()'), |
|
| 40 | + 'updated_at' => \DB::raw('NOW()') |
|
| 41 | + ], |
|
| 42 | + [ |
|
| 43 | + 'name' => 'list', |
|
| 44 | + 'model' => 'settings', |
|
| 45 | + 'created_at' => \DB::raw('NOW()'), |
|
| 46 | + 'updated_at' => \DB::raw('NOW()') |
|
| 47 | + ], |
|
| 48 | + [ |
|
| 49 | + 'name' => 'findby', |
|
| 50 | + 'model' => 'settings', |
|
| 51 | + 'created_at' => \DB::raw('NOW()'), |
|
| 52 | + 'updated_at' => \DB::raw('NOW()') |
|
| 53 | + ], |
|
| 54 | + [ |
|
| 55 | + 'name' => 'first', |
|
| 56 | + 'model' => 'settings', |
|
| 57 | + 'created_at' => \DB::raw('NOW()'), |
|
| 58 | + 'updated_at' => \DB::raw('NOW()') |
|
| 59 | + ], |
|
| 60 | + [ |
|
| 61 | + 'name' => 'paginate', |
|
| 62 | + 'model' => 'settings', |
|
| 63 | + 'created_at' => \DB::raw('NOW()'), |
|
| 64 | + 'updated_at' => \DB::raw('NOW()') |
|
| 65 | + ], |
|
| 66 | + [ |
|
| 67 | + 'name' => 'paginateby', |
|
| 68 | + 'model' => 'settings', |
|
| 69 | + 'created_at' => \DB::raw('NOW()'), |
|
| 70 | + 'updated_at' => \DB::raw('NOW()') |
|
| 71 | + ], |
|
| 72 | + [ |
|
| 73 | + 'name' => 'saveMany', |
|
| 74 | + 'model' => 'settings', |
|
| 75 | + 'created_at' => \DB::raw('NOW()'), |
|
| 76 | + 'updated_at' => \DB::raw('NOW()') |
|
| 77 | + ] |
|
| 78 | + ] |
|
| 79 | + ); |
|
| 80 | + } |
|
| 81 | 81 | } |