@@ -6,51 +6,51 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ModuleServiceProvider extends ServiceProvider |
| 8 | 8 | { |
| 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'); |
|
| 18 | - |
|
| 19 | - $this->loadMigrationsFrom(module_path('core', 'Database/Migrations', 'app')); |
|
| 20 | - $this->loadFactoriesFrom(module_path('core', 'Database/Factories', 'app')); |
|
| 21 | - if (!$this->app->configurationIsCached()) { |
|
| 22 | - $this->loadConfigsFrom(module_path('core', 'Config', 'app')); |
|
| 23 | - } |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Register the module services. |
|
| 28 | - * |
|
| 29 | - * @return void |
|
| 30 | - */ |
|
| 31 | - public function register() |
|
| 32 | - { |
|
| 33 | - //Bind Core Facade to the Service Container |
|
| 34 | - $this->app->singleton('Core', function () { |
|
| 35 | - return new \App\Modules\Core\Core; |
|
| 36 | - }); |
|
| 37 | - |
|
| 38 | - //Bind Errors Facade to the Service Container |
|
| 39 | - $this->app->singleton('Errors', function () { |
|
| 40 | - return new \App\Modules\Core\Errors\Errors; |
|
| 41 | - }); |
|
| 42 | - |
|
| 43 | - //Bind Media Facade to the Service Container |
|
| 44 | - $this->app->singleton('Media', function () { |
|
| 45 | - return new \App\Modules\Core\Utl\Media; |
|
| 46 | - }); |
|
| 47 | - |
|
| 48 | - //Bind ApiConsumer Facade to the Service Container |
|
| 49 | - $this->app->singleton('ApiConsumer', function () { |
|
| 50 | - $app = app(); |
|
| 51 | - return new \App\Modules\Core\Utl\ApiConsumer($app, $app['request'], $app['router']); |
|
| 52 | - }); |
|
| 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'); |
|
| 18 | + |
|
| 19 | + $this->loadMigrationsFrom(module_path('core', 'Database/Migrations', 'app')); |
|
| 20 | + $this->loadFactoriesFrom(module_path('core', 'Database/Factories', 'app')); |
|
| 21 | + if (!$this->app->configurationIsCached()) { |
|
| 22 | + $this->loadConfigsFrom(module_path('core', 'Config', 'app')); |
|
| 23 | + } |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Register the module services. |
|
| 28 | + * |
|
| 29 | + * @return void |
|
| 30 | + */ |
|
| 31 | + public function register() |
|
| 32 | + { |
|
| 33 | + //Bind Core Facade to the Service Container |
|
| 34 | + $this->app->singleton('Core', function () { |
|
| 35 | + return new \App\Modules\Core\Core; |
|
| 36 | + }); |
|
| 37 | + |
|
| 38 | + //Bind Errors Facade to the Service Container |
|
| 39 | + $this->app->singleton('Errors', function () { |
|
| 40 | + return new \App\Modules\Core\Errors\Errors; |
|
| 41 | + }); |
|
| 42 | + |
|
| 43 | + //Bind Media Facade to the Service Container |
|
| 44 | + $this->app->singleton('Media', function () { |
|
| 45 | + return new \App\Modules\Core\Utl\Media; |
|
| 46 | + }); |
|
| 47 | + |
|
| 48 | + //Bind ApiConsumer Facade to the Service Container |
|
| 49 | + $this->app->singleton('ApiConsumer', function () { |
|
| 50 | + $app = app(); |
|
| 51 | + return new \App\Modules\Core\Utl\ApiConsumer($app, $app['request'], $app['router']); |
|
| 52 | + }); |
|
| 53 | 53 | |
| 54 | - $this->app->register(RouteServiceProvider::class); |
|
| 55 | - } |
|
| 54 | + $this->app->register(RouteServiceProvider::class); |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | $this->loadMigrationsFrom(module_path('core', 'Database/Migrations', 'app')); |
| 20 | 20 | $this->loadFactoriesFrom(module_path('core', 'Database/Factories', 'app')); |
| 21 | - if (!$this->app->configurationIsCached()) { |
|
| 21 | + if ( ! $this->app->configurationIsCached()) { |
|
| 22 | 22 | $this->loadConfigsFrom(module_path('core', 'Config', 'app')); |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -31,22 +31,22 @@ discard block |
||
| 31 | 31 | public function register() |
| 32 | 32 | { |
| 33 | 33 | //Bind Core Facade to the Service Container |
| 34 | - $this->app->singleton('Core', function () { |
|
| 34 | + $this->app->singleton('Core', function() { |
|
| 35 | 35 | return new \App\Modules\Core\Core; |
| 36 | 36 | }); |
| 37 | 37 | |
| 38 | 38 | //Bind Errors Facade to the Service Container |
| 39 | - $this->app->singleton('Errors', function () { |
|
| 39 | + $this->app->singleton('Errors', function() { |
|
| 40 | 40 | return new \App\Modules\Core\Errors\Errors; |
| 41 | 41 | }); |
| 42 | 42 | |
| 43 | 43 | //Bind Media Facade to the Service Container |
| 44 | - $this->app->singleton('Media', function () { |
|
| 44 | + $this->app->singleton('Media', function() { |
|
| 45 | 45 | return new \App\Modules\Core\Utl\Media; |
| 46 | 46 | }); |
| 47 | 47 | |
| 48 | 48 | //Bind ApiConsumer Facade to the Service Container |
| 49 | - $this->app->singleton('ApiConsumer', function () { |
|
| 49 | + $this->app->singleton('ApiConsumer', function() { |
|
| 50 | 50 | $app = app(); |
| 51 | 51 | return new \App\Modules\Core\Utl\ApiConsumer($app, $app['request'], $app['router']); |
| 52 | 52 | }); |
@@ -6,30 +6,30 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ModuleServiceProvider extends ServiceProvider |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Bootstrap the module services. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function boot() |
|
| 15 | - { |
|
| 16 | - $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'DummyModuleSlug'); |
|
| 17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'DummyModuleSlug'); |
|
| 9 | + /** |
|
| 10 | + * Bootstrap the module services. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function boot() |
|
| 15 | + { |
|
| 16 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'DummyModuleSlug'); |
|
| 17 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'DummyModuleSlug'); |
|
| 18 | 18 | |
| 19 | - $this->loadMigrationsFrom(module_path('DummyModuleSlug', 'Database/Migrations', 'app')); |
|
| 20 | - $this->loadFactoriesFrom(module_path('DummyModuleSlug', 'Database/Factories', 'app')); |
|
| 21 | - if (!$this->app->configurationIsCached()) { |
|
| 22 | - $this->loadConfigsFrom(module_path('DummyModuleSlug', 'Config', 'app')); |
|
| 23 | - } |
|
| 24 | - } |
|
| 19 | + $this->loadMigrationsFrom(module_path('DummyModuleSlug', 'Database/Migrations', 'app')); |
|
| 20 | + $this->loadFactoriesFrom(module_path('DummyModuleSlug', 'Database/Factories', 'app')); |
|
| 21 | + if (!$this->app->configurationIsCached()) { |
|
| 22 | + $this->loadConfigsFrom(module_path('DummyModuleSlug', 'Config', 'app')); |
|
| 23 | + } |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Register the module services. |
|
| 28 | - * |
|
| 29 | - * @return void |
|
| 30 | - */ |
|
| 31 | - public function register() |
|
| 32 | - { |
|
| 33 | - $this->app->register(RouteServiceProvider::class); |
|
| 34 | - } |
|
| 26 | + /** |
|
| 27 | + * Register the module services. |
|
| 28 | + * |
|
| 29 | + * @return void |
|
| 30 | + */ |
|
| 31 | + public function register() |
|
| 32 | + { |
|
| 33 | + $this->app->register(RouteServiceProvider::class); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | |
| 19 | 19 | $this->loadMigrationsFrom(module_path('DummyModuleSlug', 'Database/Migrations', 'app')); |
| 20 | 20 | $this->loadFactoriesFrom(module_path('DummyModuleSlug', 'Database/Factories', 'app')); |
| 21 | - if (!$this->app->configurationIsCached()) { |
|
| 21 | + if ( ! $this->app->configurationIsCached()) { |
|
| 22 | 22 | $this->loadConfigsFrom(module_path('DummyModuleSlug', 'Config', 'app')); |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -11,5 +11,5 @@ |
||
| 11 | 11 | | |
| 12 | 12 | */ |
| 13 | 13 | if (\App::environment('local')) { |
| 14 | - Route::get('/docs', 'ApiDocumentController@index'); |
|
| 14 | + Route::get('/docs', 'ApiDocumentController@index'); |
|
| 15 | 15 | } |
@@ -6,30 +6,30 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ModuleServiceProvider extends ServiceProvider |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Bootstrap the module services. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function boot() |
|
| 15 | - { |
|
| 16 | - $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'permissions'); |
|
| 17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'permissions'); |
|
| 9 | + /** |
|
| 10 | + * Bootstrap the module services. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function boot() |
|
| 15 | + { |
|
| 16 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'permissions'); |
|
| 17 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'permissions'); |
|
| 18 | 18 | |
| 19 | - $this->loadMigrationsFrom(module_path('permissions', 'Database/Migrations', 'app')); |
|
| 20 | - $this->loadFactoriesFrom(module_path('permissions', 'Database/Factories', 'app')); |
|
| 21 | - if (!$this->app->configurationIsCached()) { |
|
| 22 | - $this->loadConfigsFrom(module_path('permissions', 'Config', 'app')); |
|
| 23 | - } |
|
| 24 | - } |
|
| 19 | + $this->loadMigrationsFrom(module_path('permissions', 'Database/Migrations', 'app')); |
|
| 20 | + $this->loadFactoriesFrom(module_path('permissions', 'Database/Factories', 'app')); |
|
| 21 | + if (!$this->app->configurationIsCached()) { |
|
| 22 | + $this->loadConfigsFrom(module_path('permissions', 'Config', 'app')); |
|
| 23 | + } |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Register the module services. |
|
| 28 | - * |
|
| 29 | - * @return void |
|
| 30 | - */ |
|
| 31 | - public function register() |
|
| 32 | - { |
|
| 33 | - $this->app->register(RouteServiceProvider::class); |
|
| 34 | - } |
|
| 26 | + /** |
|
| 27 | + * Register the module services. |
|
| 28 | + * |
|
| 29 | + * @return void |
|
| 30 | + */ |
|
| 31 | + public function register() |
|
| 32 | + { |
|
| 33 | + $this->app->register(RouteServiceProvider::class); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | |
| 19 | 19 | $this->loadMigrationsFrom(module_path('permissions', 'Database/Migrations', 'app')); |
| 20 | 20 | $this->loadFactoriesFrom(module_path('permissions', 'Database/Factories', 'app')); |
| 21 | - if (!$this->app->configurationIsCached()) { |
|
| 21 | + if ( ! $this->app->configurationIsCached()) { |
|
| 22 | 22 | $this->loadConfigsFrom(module_path('permissions', 'Config', 'app')); |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -6,30 +6,30 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ModuleServiceProvider extends ServiceProvider |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Bootstrap the module services. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function boot() |
|
| 15 | - { |
|
| 16 | - $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'users'); |
|
| 17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'users'); |
|
| 9 | + /** |
|
| 10 | + * Bootstrap the module services. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function boot() |
|
| 15 | + { |
|
| 16 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'users'); |
|
| 17 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'users'); |
|
| 18 | 18 | |
| 19 | - $this->loadMigrationsFrom(module_path('users', 'Database/Migrations', 'app')); |
|
| 20 | - $this->loadFactoriesFrom(module_path('users', 'Database/Factories', 'app')); |
|
| 21 | - if (!$this->app->configurationIsCached()) { |
|
| 22 | - $this->loadConfigsFrom(module_path('users', 'Config', 'app')); |
|
| 23 | - } |
|
| 24 | - } |
|
| 19 | + $this->loadMigrationsFrom(module_path('users', 'Database/Migrations', 'app')); |
|
| 20 | + $this->loadFactoriesFrom(module_path('users', 'Database/Factories', 'app')); |
|
| 21 | + if (!$this->app->configurationIsCached()) { |
|
| 22 | + $this->loadConfigsFrom(module_path('users', 'Config', 'app')); |
|
| 23 | + } |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Register the module services. |
|
| 28 | - * |
|
| 29 | - * @return void |
|
| 30 | - */ |
|
| 31 | - public function register() |
|
| 32 | - { |
|
| 33 | - $this->app->register(RouteServiceProvider::class); |
|
| 34 | - } |
|
| 26 | + /** |
|
| 27 | + * Register the module services. |
|
| 28 | + * |
|
| 29 | + * @return void |
|
| 30 | + */ |
|
| 31 | + public function register() |
|
| 32 | + { |
|
| 33 | + $this->app->register(RouteServiceProvider::class); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | |
| 19 | 19 | $this->loadMigrationsFrom(module_path('users', 'Database/Migrations', 'app')); |
| 20 | 20 | $this->loadFactoriesFrom(module_path('users', 'Database/Factories', 'app')); |
| 21 | - if (!$this->app->configurationIsCached()) { |
|
| 21 | + if ( ! $this->app->configurationIsCached()) { |
|
| 22 | 22 | $this->loadConfigsFrom(module_path('users', 'Config', 'app')); |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -9,16 +9,16 @@ |
||
| 9 | 9 | class Report extends Model |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - use SoftDeletes; |
|
| 13 | - protected $table = 'reports'; |
|
| 14 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 15 | - protected $hidden = ['deleted_at']; |
|
| 16 | - protected $guarded = ['id']; |
|
| 17 | - public $fillable = ['report_name', 'view_name']; |
|
| 12 | + use SoftDeletes; |
|
| 13 | + protected $table = 'reports'; |
|
| 14 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 15 | + protected $hidden = ['deleted_at']; |
|
| 16 | + protected $guarded = ['id']; |
|
| 17 | + public $fillable = ['report_name', 'view_name']; |
|
| 18 | 18 | |
| 19 | - public static function boot() |
|
| 20 | - { |
|
| 21 | - parent::boot(); |
|
| 22 | - Report::observe(ReportObserver::class); |
|
| 23 | - } |
|
| 19 | + public static function boot() |
|
| 20 | + { |
|
| 21 | + parent::boot(); |
|
| 22 | + Report::observe(ReportObserver::class); |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -5,29 +5,29 @@ |
||
| 5 | 5 | |
| 6 | 6 | class Reports extends Migration |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Run the migrations. |
|
| 10 | - * |
|
| 11 | - * @return void |
|
| 12 | - */ |
|
| 13 | - public function up() |
|
| 14 | - { |
|
| 15 | - Schema::create('reports', function (Blueprint $table) { |
|
| 16 | - increments('id'); |
|
| 17 | - $table->string('report_name', 100); |
|
| 18 | - $table->string('view_name', 100); |
|
| 19 | - $table->softDeletes(); |
|
| 20 | - $table->timestamps(); |
|
| 21 | - }); |
|
| 22 | - } |
|
| 8 | + /** |
|
| 9 | + * Run the migrations. |
|
| 10 | + * |
|
| 11 | + * @return void |
|
| 12 | + */ |
|
| 13 | + public function up() |
|
| 14 | + { |
|
| 15 | + Schema::create('reports', function (Blueprint $table) { |
|
| 16 | + increments('id'); |
|
| 17 | + $table->string('report_name', 100); |
|
| 18 | + $table->string('view_name', 100); |
|
| 19 | + $table->softDeletes(); |
|
| 20 | + $table->timestamps(); |
|
| 21 | + }); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Reverse the migrations. |
|
| 26 | - * |
|
| 27 | - * @return void |
|
| 28 | - */ |
|
| 29 | - public function down() |
|
| 30 | - { |
|
| 31 | - Schema::dropIfExists('reports'); |
|
| 32 | - } |
|
| 24 | + /** |
|
| 25 | + * Reverse the migrations. |
|
| 26 | + * |
|
| 27 | + * @return void |
|
| 28 | + */ |
|
| 29 | + public function down() |
|
| 30 | + { |
|
| 31 | + Schema::dropIfExists('reports'); |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('reports', function (Blueprint $table) { |
|
| 15 | + Schema::create('reports', function(Blueprint $table) { |
|
| 16 | 16 | increments('id'); |
| 17 | 17 | $table->string('report_name', 100); |
| 18 | 18 | $table->string('view_name', 100); |
@@ -12,112 +12,112 @@ |
||
| 12 | 12 | |
| 13 | 13 | class AclUser extends User |
| 14 | 14 | { |
| 15 | - use SoftDeletes, HasApiTokens; |
|
| 16 | - protected $table = 'users'; |
|
| 17 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 18 | - protected $hidden = ['password', 'remember_token', 'deleted_at']; |
|
| 19 | - protected $guarded = ['id']; |
|
| 20 | - public $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone']; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Encrypt the password attribute before |
|
| 24 | - * saving it in the storage. |
|
| 25 | - * |
|
| 26 | - * @param string $value |
|
| 27 | - */ |
|
| 28 | - public function setPasswordAttribute($value) |
|
| 29 | - { |
|
| 30 | - $this->attributes['password'] = \Hash::make($value); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Get the entity's notifications. |
|
| 35 | - */ |
|
| 36 | - public function notifications() |
|
| 37 | - { |
|
| 38 | - return $this->morphMany(Notification::class, 'notifiable')->orderBy('created_at', 'desc'); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Get the entity's read notifications. |
|
| 43 | - */ |
|
| 44 | - public function readNotifications() |
|
| 45 | - { |
|
| 46 | - return $this->notifications()->whereNotNull('read_at'); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Get the entity's unread notifications. |
|
| 51 | - */ |
|
| 52 | - public function unreadNotifications() |
|
| 53 | - { |
|
| 54 | - return $this->notifications()->whereNull('read_at'); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - public function roles() |
|
| 58 | - { |
|
| 59 | - return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id')->whereNull('role_user.deleted_at')->withTimestamps(); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - public function oauthClients() |
|
| 63 | - { |
|
| 64 | - return $this->hasMany(OauthClient::class, 'user_id'); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - public function setProfilePictureAttribute($value) { |
|
| 68 | - $this->attributes['profile_picture'] = \Media::uploadImageBas64($value, 'users/profile_pictures'); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Return fcm device tokens that will be used in sending fcm notifications. |
|
| 73 | - * |
|
| 74 | - * @return array |
|
| 75 | - */ |
|
| 76 | - public function routeNotificationForFCM() |
|
| 77 | - { |
|
| 78 | - $devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]); |
|
| 79 | - $tokens = []; |
|
| 80 | - |
|
| 81 | - foreach ($devices as $device) { |
|
| 82 | - if (\Core::oauthClients()->accessTokenExpiredOrRevoked($device->access_token)) { |
|
| 83 | - $device->forceDelete(); |
|
| 84 | - continue; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $tokens[] = $device->device_token; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - return $tokens; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * The channels the user receives notification broadcasts on. |
|
| 95 | - * |
|
| 96 | - * @return string |
|
| 97 | - */ |
|
| 98 | - public function receivesBroadcastNotificationsOn() |
|
| 99 | - { |
|
| 100 | - return 'users.'.$this->id; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Custom password validation. |
|
| 105 | - * |
|
| 106 | - * @param string $password |
|
| 107 | - * @return boolean |
|
| 108 | - */ |
|
| 109 | - public function validateForPassportPasswordGrant($password) |
|
| 110 | - { |
|
| 111 | - if ($password == config('user.social_pass')) { |
|
| 112 | - return true; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - return \Hash::check($password, $this->password); |
|
| 116 | - } |
|
| 15 | + use SoftDeletes, HasApiTokens; |
|
| 16 | + protected $table = 'users'; |
|
| 17 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 18 | + protected $hidden = ['password', 'remember_token', 'deleted_at']; |
|
| 19 | + protected $guarded = ['id']; |
|
| 20 | + public $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone']; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Encrypt the password attribute before |
|
| 24 | + * saving it in the storage. |
|
| 25 | + * |
|
| 26 | + * @param string $value |
|
| 27 | + */ |
|
| 28 | + public function setPasswordAttribute($value) |
|
| 29 | + { |
|
| 30 | + $this->attributes['password'] = \Hash::make($value); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Get the entity's notifications. |
|
| 35 | + */ |
|
| 36 | + public function notifications() |
|
| 37 | + { |
|
| 38 | + return $this->morphMany(Notification::class, 'notifiable')->orderBy('created_at', 'desc'); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Get the entity's read notifications. |
|
| 43 | + */ |
|
| 44 | + public function readNotifications() |
|
| 45 | + { |
|
| 46 | + return $this->notifications()->whereNotNull('read_at'); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Get the entity's unread notifications. |
|
| 51 | + */ |
|
| 52 | + public function unreadNotifications() |
|
| 53 | + { |
|
| 54 | + return $this->notifications()->whereNull('read_at'); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + public function roles() |
|
| 58 | + { |
|
| 59 | + return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id')->whereNull('role_user.deleted_at')->withTimestamps(); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + public function oauthClients() |
|
| 63 | + { |
|
| 64 | + return $this->hasMany(OauthClient::class, 'user_id'); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + public function setProfilePictureAttribute($value) { |
|
| 68 | + $this->attributes['profile_picture'] = \Media::uploadImageBas64($value, 'users/profile_pictures'); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Return fcm device tokens that will be used in sending fcm notifications. |
|
| 73 | + * |
|
| 74 | + * @return array |
|
| 75 | + */ |
|
| 76 | + public function routeNotificationForFCM() |
|
| 77 | + { |
|
| 78 | + $devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]); |
|
| 79 | + $tokens = []; |
|
| 80 | + |
|
| 81 | + foreach ($devices as $device) { |
|
| 82 | + if (\Core::oauthClients()->accessTokenExpiredOrRevoked($device->access_token)) { |
|
| 83 | + $device->forceDelete(); |
|
| 84 | + continue; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $tokens[] = $device->device_token; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + return $tokens; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * The channels the user receives notification broadcasts on. |
|
| 95 | + * |
|
| 96 | + * @return string |
|
| 97 | + */ |
|
| 98 | + public function receivesBroadcastNotificationsOn() |
|
| 99 | + { |
|
| 100 | + return 'users.'.$this->id; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Custom password validation. |
|
| 105 | + * |
|
| 106 | + * @param string $password |
|
| 107 | + * @return boolean |
|
| 108 | + */ |
|
| 109 | + public function validateForPassportPasswordGrant($password) |
|
| 110 | + { |
|
| 111 | + if ($password == config('user.social_pass')) { |
|
| 112 | + return true; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + return \Hash::check($password, $this->password); |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - public static function boot() |
|
| 119 | - { |
|
| 120 | - parent::boot(); |
|
| 121 | - AclUser::observe(AclUserObserver::class); |
|
| 122 | - } |
|
| 118 | + public static function boot() |
|
| 119 | + { |
|
| 120 | + parent::boot(); |
|
| 121 | + AclUser::observe(AclUserObserver::class); |
|
| 122 | + } |
|
| 123 | 123 | } |
@@ -5,37 +5,37 @@ |
||
| 5 | 5 | |
| 6 | 6 | class Users extends Migration |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Run the migrations. |
|
| 10 | - * |
|
| 11 | - * @return void |
|
| 12 | - */ |
|
| 13 | - public function up() |
|
| 14 | - { |
|
| 15 | - Schema::create('users', function (Blueprint $table) { |
|
| 16 | - increments('id'); |
|
| 17 | - $table->string('profile_picture', 150)->nullable(); |
|
| 18 | - $table->string('name', 100)->nullable(); |
|
| 19 | - $table->string('email')->unique(); |
|
| 20 | - $table->string('password', 60)->nullable(); |
|
| 21 | - $table->boolean('blocked')->default(0); |
|
| 22 | - $table->boolean('confirmed')->default(0); |
|
| 23 | - $table->string('confirmation_code')->nullable(); |
|
| 24 | - $table->string('locale', 2)->default('en'); |
|
| 25 | - $table->string('timezone', 50)->default('Africa/Cairo'); |
|
| 26 | - $table->softDeletes(); |
|
| 27 | - $table->rememberToken(); |
|
| 28 | - $table->timestamps(); |
|
| 29 | - }); |
|
| 30 | - } |
|
| 8 | + /** |
|
| 9 | + * Run the migrations. |
|
| 10 | + * |
|
| 11 | + * @return void |
|
| 12 | + */ |
|
| 13 | + public function up() |
|
| 14 | + { |
|
| 15 | + Schema::create('users', function (Blueprint $table) { |
|
| 16 | + increments('id'); |
|
| 17 | + $table->string('profile_picture', 150)->nullable(); |
|
| 18 | + $table->string('name', 100)->nullable(); |
|
| 19 | + $table->string('email')->unique(); |
|
| 20 | + $table->string('password', 60)->nullable(); |
|
| 21 | + $table->boolean('blocked')->default(0); |
|
| 22 | + $table->boolean('confirmed')->default(0); |
|
| 23 | + $table->string('confirmation_code')->nullable(); |
|
| 24 | + $table->string('locale', 2)->default('en'); |
|
| 25 | + $table->string('timezone', 50)->default('Africa/Cairo'); |
|
| 26 | + $table->softDeletes(); |
|
| 27 | + $table->rememberToken(); |
|
| 28 | + $table->timestamps(); |
|
| 29 | + }); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Reverse the migrations. |
|
| 34 | - * |
|
| 35 | - * @return void |
|
| 36 | - */ |
|
| 37 | - public function down() |
|
| 38 | - { |
|
| 39 | - Schema::dropIfExists('users'); |
|
| 40 | - } |
|
| 32 | + /** |
|
| 33 | + * Reverse the migrations. |
|
| 34 | + * |
|
| 35 | + * @return void |
|
| 36 | + */ |
|
| 37 | + public function down() |
|
| 38 | + { |
|
| 39 | + Schema::dropIfExists('users'); |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('users', function (Blueprint $table) { |
|
| 15 | + Schema::create('users', function(Blueprint $table) { |
|
| 16 | 16 | increments('id'); |
| 17 | 17 | $table->string('profile_picture', 150)->nullable(); |
| 18 | 18 | $table->string('name', 100)->nullable(); |