@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $factory->define(App\Modules\V1\Notifications\PushNotificationDevice::class, function (Faker\Generator $faker) { |
| 4 | - return [ |
|
| 4 | + return [ |
|
| 5 | 5 | 'device_token' => $faker->sha1(), |
| 6 | 6 | 'device_type ' => $faker->randomElement(['android', 'ios']), |
| 7 | 7 | 'user_id' => $faker->randomDigitNotNull(), |
| 8 | 8 | 'active' => $faker->numberBetween(0, 1), |
| 9 | 9 | 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
| 10 | 10 | 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
| 11 | - ]; |
|
| 11 | + ]; |
|
| 12 | 12 | }); |
| 13 | 13 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $factory->define(App\Modules\V1\Notifications\Notification::class, function (Faker\Generator $faker) { |
| 4 | - return [ |
|
| 4 | + return [ |
|
| 5 | 5 | 'key' => $faker->randomElement(['low_stock', 'order_added', 'new_request']), |
| 6 | 6 | 'item_name ' => $faker->randomElement(['User', 'Settings', 'Group']), |
| 7 | 7 | 'item_id' => $faker->randomDigitNotNull(), |
@@ -9,5 +9,5 @@ discard block |
||
| 9 | 9 | 'data' => [], |
| 10 | 10 | 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
| 11 | 11 | 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
| 12 | - ]; |
|
| 12 | + ]; |
|
| 13 | 13 | }); |
| 14 | 14 | \ No newline at end of file |
@@ -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', ['notifications', 'pushNotificationDevices'])->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', ['notifications', 'pushNotificationDevices'])->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 | } |
@@ -5,60 +5,60 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class NotificationObserver { |
| 7 | 7 | |
| 8 | - public function saving($model) |
|
| 9 | - { |
|
| 10 | - // |
|
| 11 | - } |
|
| 8 | + public function saving($model) |
|
| 9 | + { |
|
| 10 | + // |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public function saved($model) |
|
| 14 | - { |
|
| 15 | - // |
|
| 16 | - } |
|
| 13 | + public function saved($model) |
|
| 14 | + { |
|
| 15 | + // |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - public function creating($model) |
|
| 19 | - { |
|
| 20 | - // |
|
| 21 | - } |
|
| 18 | + public function creating($model) |
|
| 19 | + { |
|
| 20 | + // |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Publish the created notification to the redis server |
|
| 25 | - * to broadcast it to all listners. |
|
| 26 | - * |
|
| 27 | - * @param object $model the model beign created. |
|
| 28 | - * @return void |
|
| 29 | - */ |
|
| 30 | - public function created($model) |
|
| 31 | - { |
|
| 32 | - \Redis::publish('notification', json_encode($model->toArray())); |
|
| 33 | - } |
|
| 23 | + /** |
|
| 24 | + * Publish the created notification to the redis server |
|
| 25 | + * to broadcast it to all listners. |
|
| 26 | + * |
|
| 27 | + * @param object $model the model beign created. |
|
| 28 | + * @return void |
|
| 29 | + */ |
|
| 30 | + public function created($model) |
|
| 31 | + { |
|
| 32 | + \Redis::publish('notification', json_encode($model->toArray())); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - public function updating($model) |
|
| 36 | - { |
|
| 37 | - // |
|
| 38 | - } |
|
| 35 | + public function updating($model) |
|
| 36 | + { |
|
| 37 | + // |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public function updated($model) |
|
| 41 | - { |
|
| 42 | - // |
|
| 43 | - } |
|
| 40 | + public function updated($model) |
|
| 41 | + { |
|
| 42 | + // |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function deleting($model) |
|
| 46 | - { |
|
| 47 | - // |
|
| 48 | - } |
|
| 45 | + public function deleting($model) |
|
| 46 | + { |
|
| 47 | + // |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - public function deleted($model) |
|
| 51 | - { |
|
| 52 | - // |
|
| 53 | - } |
|
| 50 | + public function deleted($model) |
|
| 51 | + { |
|
| 52 | + // |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - public function restoring($model) |
|
| 56 | - { |
|
| 57 | - // |
|
| 58 | - } |
|
| 55 | + public function restoring($model) |
|
| 56 | + { |
|
| 57 | + // |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - public function restored($model) |
|
| 61 | - { |
|
| 62 | - // |
|
| 63 | - } |
|
| 60 | + public function restored($model) |
|
| 61 | + { |
|
| 62 | + // |
|
| 63 | + } |
|
| 64 | 64 | } |
| 65 | 65 | \ No newline at end of file |
@@ -5,53 +5,53 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class PushNotificationDeviceObserver { |
| 7 | 7 | |
| 8 | - public function saving($model) |
|
| 9 | - { |
|
| 10 | - // |
|
| 11 | - } |
|
| 12 | - |
|
| 13 | - public function saved($model) |
|
| 14 | - { |
|
| 15 | - // |
|
| 16 | - } |
|
| 17 | - |
|
| 18 | - public function creating($model) |
|
| 19 | - { |
|
| 20 | - // |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - public function created($model) |
|
| 24 | - { |
|
| 25 | - // |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - public function updating($model) |
|
| 29 | - { |
|
| 30 | - // |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public function updated($model) |
|
| 34 | - { |
|
| 35 | - // |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - public function deleting($model) |
|
| 39 | - { |
|
| 40 | - // |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - public function deleted($model) |
|
| 44 | - { |
|
| 45 | - // |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - public function restoring($model) |
|
| 49 | - { |
|
| 50 | - // |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - public function restored($model) |
|
| 54 | - { |
|
| 55 | - // |
|
| 56 | - } |
|
| 8 | + public function saving($model) |
|
| 9 | + { |
|
| 10 | + // |
|
| 11 | + } |
|
| 12 | + |
|
| 13 | + public function saved($model) |
|
| 14 | + { |
|
| 15 | + // |
|
| 16 | + } |
|
| 17 | + |
|
| 18 | + public function creating($model) |
|
| 19 | + { |
|
| 20 | + // |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + public function created($model) |
|
| 24 | + { |
|
| 25 | + // |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + public function updating($model) |
|
| 29 | + { |
|
| 30 | + // |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public function updated($model) |
|
| 34 | + { |
|
| 35 | + // |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + public function deleting($model) |
|
| 39 | + { |
|
| 40 | + // |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + public function deleted($model) |
|
| 44 | + { |
|
| 45 | + // |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + public function restoring($model) |
|
| 49 | + { |
|
| 50 | + // |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + public function restored($model) |
|
| 54 | + { |
|
| 55 | + // |
|
| 56 | + } |
|
| 57 | 57 | } |
| 58 | 58 | \ No newline at end of file |
@@ -2,101 +2,101 @@ |
||
| 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 cacheConfig implementation. |
|
| 35 | - * |
|
| 36 | - * @var array |
|
| 37 | - */ |
|
| 38 | - public $cacheConfig; |
|
| 33 | + /** |
|
| 34 | + * The cacheConfig implementation. |
|
| 35 | + * |
|
| 36 | + * @var array |
|
| 37 | + */ |
|
| 38 | + public $cacheConfig; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Create new CachingDecorator instance. |
|
| 42 | - */ |
|
| 43 | - public function __construct($repo, $cache) |
|
| 44 | - { |
|
| 45 | - $this->repo = $repo; |
|
| 46 | - $this->cache = $cache; |
|
| 47 | - $this->model = $this->repo->model; |
|
| 48 | - $repoName = end(explode('\\', get_class($this->repo))); |
|
| 49 | - $this->cacheTag = str_plural(lcfirst(substr($repoName, 0, strpos($repoName, 'Repository')))); |
|
| 50 | - } |
|
| 40 | + /** |
|
| 41 | + * Create new CachingDecorator instance. |
|
| 42 | + */ |
|
| 43 | + public function __construct($repo, $cache) |
|
| 44 | + { |
|
| 45 | + $this->repo = $repo; |
|
| 46 | + $this->cache = $cache; |
|
| 47 | + $this->model = $this->repo->model; |
|
| 48 | + $repoName = end(explode('\\', get_class($this->repo))); |
|
| 49 | + $this->cacheTag = str_plural(lcfirst(substr($repoName, 0, strpos($repoName, 'Repository')))); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Handle the cache mechanism for the called method |
|
| 54 | - * based the configurations. |
|
| 55 | - * |
|
| 56 | - * @param string $name the called method name |
|
| 57 | - * @param array $arguments the method arguments |
|
| 58 | - * @return object |
|
| 59 | - */ |
|
| 60 | - public function __call($name, $arguments) |
|
| 61 | - { |
|
| 62 | - $this->setCacheConfig($name); |
|
| 52 | + /** |
|
| 53 | + * Handle the cache mechanism for the called method |
|
| 54 | + * based the configurations. |
|
| 55 | + * |
|
| 56 | + * @param string $name the called method name |
|
| 57 | + * @param array $arguments the method arguments |
|
| 58 | + * @return object |
|
| 59 | + */ |
|
| 60 | + public function __call($name, $arguments) |
|
| 61 | + { |
|
| 62 | + $this->setCacheConfig($name); |
|
| 63 | 63 | |
| 64 | - if ($this->cacheConfig && $this->cacheConfig == 'cache') |
|
| 65 | - { |
|
| 66 | - $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
|
| 67 | - $cacheKey = $name . $page . \Session::get('locale') . serialize($arguments); |
|
| 68 | - return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
|
| 69 | - return call_user_func_array([$this->repo, $name], $arguments); |
|
| 70 | - }); |
|
| 71 | - } |
|
| 72 | - else if ($this->cacheConfig) |
|
| 73 | - { |
|
| 74 | - $this->cache->tags($this->cacheConfig)->flush(); |
|
| 75 | - return call_user_func_array([$this->repo, $name], $arguments); |
|
| 76 | - } |
|
| 64 | + if ($this->cacheConfig && $this->cacheConfig == 'cache') |
|
| 65 | + { |
|
| 66 | + $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
|
| 67 | + $cacheKey = $name . $page . \Session::get('locale') . serialize($arguments); |
|
| 68 | + return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
|
| 69 | + return call_user_func_array([$this->repo, $name], $arguments); |
|
| 70 | + }); |
|
| 71 | + } |
|
| 72 | + else if ($this->cacheConfig) |
|
| 73 | + { |
|
| 74 | + $this->cache->tags($this->cacheConfig)->flush(); |
|
| 75 | + return call_user_func_array([$this->repo, $name], $arguments); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - return call_user_func_array([$this->repo, $name], $arguments); |
|
| 79 | - } |
|
| 78 | + return call_user_func_array([$this->repo, $name], $arguments); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Set cache config based on the called method. |
|
| 83 | - * |
|
| 84 | - * @param string $name |
|
| 85 | - * @return void |
|
| 86 | - */ |
|
| 87 | - private function setCacheConfig($name) |
|
| 88 | - { |
|
| 89 | - $config = \CoreConfig::getConfig(); |
|
| 90 | - $cacheConfig = array_key_exists($this->cacheTag, $config['cacheConfig']) ? $config['cacheConfig'][$this->cacheTag] : false; |
|
| 91 | - $this->cacheConfig = false; |
|
| 81 | + /** |
|
| 82 | + * Set cache config based on the called method. |
|
| 83 | + * |
|
| 84 | + * @param string $name |
|
| 85 | + * @return void |
|
| 86 | + */ |
|
| 87 | + private function setCacheConfig($name) |
|
| 88 | + { |
|
| 89 | + $config = \CoreConfig::getConfig(); |
|
| 90 | + $cacheConfig = array_key_exists($this->cacheTag, $config['cacheConfig']) ? $config['cacheConfig'][$this->cacheTag] : false; |
|
| 91 | + $this->cacheConfig = false; |
|
| 92 | 92 | |
| 93 | - if ($cacheConfig && in_array($name, $cacheConfig['cache'])) |
|
| 94 | - { |
|
| 95 | - $this->cacheConfig = 'cache'; |
|
| 96 | - } |
|
| 97 | - else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
| 98 | - { |
|
| 99 | - $this->cacheConfig = $cacheConfig['clear'][$name]; |
|
| 100 | - } |
|
| 101 | - } |
|
| 93 | + if ($cacheConfig && in_array($name, $cacheConfig['cache'])) |
|
| 94 | + { |
|
| 95 | + $this->cacheConfig = 'cache'; |
|
| 96 | + } |
|
| 97 | + else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
| 98 | + { |
|
| 99 | + $this->cacheConfig = $cacheConfig['clear'][$name]; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | } |
| 103 | 103 | \ No newline at end of file |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $factory->define(App\Modules\V1\Core\Settings::class, function (Faker\Generator $faker) { |
| 4 | - return [ |
|
| 4 | + return [ |
|
| 5 | 5 | 'name' => $faker->randomElement(['Company Name', 'Title', 'Header Image']), |
| 6 | 6 | 'value' => $faker->word(), |
| 7 | 7 | 'key' => $faker->word(), |
| 8 | 8 | 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
| 9 | 9 | 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
| 10 | - ]; |
|
| 10 | + ]; |
|
| 11 | 11 | }); |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $factory->define(App\Modules\V1\Core\Log::class, function (Faker\Generator $faker) { |
| 4 | - return [ |
|
| 4 | + return [ |
|
| 5 | 5 | 'action' => $faker->randomElement(['create', 'delete', 'update']), |
| 6 | 6 | 'item_name ' => $faker->randomElement(['User', 'Settings', 'Group']), |
| 7 | 7 | 'item_id' => $faker->randomDigitNotNull(), |
| 8 | 8 | 'user_id' => $faker->randomDigitNotNull(), |
| 9 | 9 | 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
| 10 | 10 | 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
| 11 | - ]; |
|
| 11 | + ]; |
|
| 12 | 12 | }); |
| 13 | 13 | \ No newline at end of file |
@@ -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', 'logs'])->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', 'logs'])->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 | } |