Completed
Push — master ( 4b6f70...bf5864 )
by Sherif
02:04
created
src/Modules/Core/Console/Commands/Stubs/Module/DummyModel.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,16 +8,16 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Core/Console/Commands/Stubs/Module/Database/Seeds/DummyTableSeeder.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -6,64 +6,64 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/ApiSkeletonServiceProvider.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -6,41 +6,41 @@
 block discarded – undo
6 6
 
7 7
 class ApiSkeletonServiceProvider extends ServiceProvider
8 8
 {
9
-    /**
10
-     * Perform post-registration booting of services.
11
-     *
12
-     * @return void
13
-     */
14
-    public function boot()
15
-    {
16
-        $this->publishes([
17
-            __DIR__.'/Modules'                               => app_path('Modules'),
18
-            __DIR__.'/Modules/Core/Resources/Assets'         => base_path('public/doc/assets'),
19
-            __DIR__.'/../lang'                               => base_path('resources/lang'),
20
-            __DIR__.'/../files/Handler.php'                  => app_path('Exceptions/Handler.php'),
21
-            __DIR__.'/../files/AuthServiceProvider.php'      => app_path('Providers/AuthServiceProvider.php'),
22
-            __DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'),
23
-            __DIR__.'/../files/Kernel.php'                   => app_path('Console/Kernel.php'),
24
-            __DIR__.'/../files/HttpKernel.php'               => app_path('Http/Kernel.php'),
25
-            __DIR__.'/../files/channels.php'                 => base_path('routes/channels.php'),
26
-            __DIR__.'/../files/Jenkinsfile'                  => base_path('/Jenkinsfile'),
27
-            __DIR__.'/../files/phpcs.xml'                    => base_path('/phpcs.xml'),
28
-            __DIR__.'/../files/docker'                       => base_path('/docker'),
29
-            __DIR__.'/../files/.dockerignore'                => base_path('/.dockerignore'),
30
-        ]);
9
+	/**
10
+	 * Perform post-registration booting of services.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function boot()
15
+	{
16
+		$this->publishes([
17
+			__DIR__.'/Modules'                               => app_path('Modules'),
18
+			__DIR__.'/Modules/Core/Resources/Assets'         => base_path('public/doc/assets'),
19
+			__DIR__.'/../lang'                               => base_path('resources/lang'),
20
+			__DIR__.'/../files/Handler.php'                  => app_path('Exceptions/Handler.php'),
21
+			__DIR__.'/../files/AuthServiceProvider.php'      => app_path('Providers/AuthServiceProvider.php'),
22
+			__DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'),
23
+			__DIR__.'/../files/Kernel.php'                   => app_path('Console/Kernel.php'),
24
+			__DIR__.'/../files/HttpKernel.php'               => app_path('Http/Kernel.php'),
25
+			__DIR__.'/../files/channels.php'                 => base_path('routes/channels.php'),
26
+			__DIR__.'/../files/Jenkinsfile'                  => base_path('/Jenkinsfile'),
27
+			__DIR__.'/../files/phpcs.xml'                    => base_path('/phpcs.xml'),
28
+			__DIR__.'/../files/docker'                       => base_path('/docker'),
29
+			__DIR__.'/../files/.dockerignore'                => base_path('/.dockerignore'),
30
+		]);
31 31
 
32
-        $this->publishes([
33
-            __DIR__.'/../files/auth.php' => config_path('auth.php'),
34
-        ], 'config');
35
-    }
32
+		$this->publishes([
33
+			__DIR__.'/../files/auth.php' => config_path('auth.php'),
34
+		], 'config');
35
+	}
36 36
 
37
-    /**
38
-     * Register any package services.
39
-     *
40
-     * @return void
41
-     */
42
-    public function register()
43
-    {
44
-        //
45
-    }
37
+	/**
38
+	 * Register any package services.
39
+	 *
40
+	 * @return void
41
+	 */
42
+	public function register()
43
+	{
44
+		//
45
+	}
46 46
 }
Please login to merge, or discard this patch.
src/Modules/Notifications/Services/NotificationService.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
      *
67 67
      * @param  collection $users
68 68
      * @param  string     $notification
69
-     * @param  Variadic   $notificationData
69
+     * @param  Variadic[]   $notificationData
70 70
      * @return void
71 71
      */
72 72
     public function notify($users, $notification, ...$notificationData)
Please login to merge, or discard this patch.
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -7,72 +7,72 @@
 block discarded – undo
7 7
 
8 8
 class NotificationService extends BaseService
9 9
 {
10
-    /**
11
-     * Init new object.
12
-     *
13
-     * @param   NotificationRepository $repo
14
-     * @return  void
15
-     */
16
-    public function __construct(NotificationRepository $repo)
17
-    {
18
-        parent::__construct($repo);
19
-    }
10
+	/**
11
+	 * Init new object.
12
+	 *
13
+	 * @param   NotificationRepository $repo
14
+	 * @return  void
15
+	 */
16
+	public function __construct(NotificationRepository $repo)
17
+	{
18
+		parent::__construct($repo);
19
+	}
20 20
 
21
-    /**
22
-     * Retrieve all notifications of the logged in user.
23
-     *
24
-     * @param  integer $perPage
25
-     * @return Collection
26
-     */
27
-    public function my($perPage)
28
-    {
29
-        return $this->repo->my($perPage);
30
-    }
21
+	/**
22
+	 * Retrieve all notifications of the logged in user.
23
+	 *
24
+	 * @param  integer $perPage
25
+	 * @return Collection
26
+	 */
27
+	public function my($perPage)
28
+	{
29
+		return $this->repo->my($perPage);
30
+	}
31 31
 
32
-    /**
33
-     * Retrieve unread notifications of the logged in user.
34
-     *
35
-     * @param  integer $perPage
36
-     * @return Collection
37
-     */
38
-    public function unread($perPage)
39
-    {
40
-        return $this->repo->unread($perPage);
41
-    }
32
+	/**
33
+	 * Retrieve unread notifications of the logged in user.
34
+	 *
35
+	 * @param  integer $perPage
36
+	 * @return Collection
37
+	 */
38
+	public function unread($perPage)
39
+	{
40
+		return $this->repo->unread($perPage);
41
+	}
42 42
 
43
-    /**
44
-     * Mark the notification as read.
45
-     *
46
-     * @param  integer  $id
47
-     * @return object
48
-     */
49
-    public function markAsRead($id)
50
-    {
51
-        return $this->repo->markAsRead($id);
52
-    }
43
+	/**
44
+	 * Mark the notification as read.
45
+	 *
46
+	 * @param  integer  $id
47
+	 * @return object
48
+	 */
49
+	public function markAsRead($id)
50
+	{
51
+		return $this->repo->markAsRead($id);
52
+	}
53 53
 
54
-    /**
55
-     * Mark all notifications as read.
56
-     *
57
-     * @return void
58
-     */
59
-    public function markAllAsRead()
60
-    {
61
-        return $this->repo->markAllAsRead();
62
-    }
54
+	/**
55
+	 * Mark all notifications as read.
56
+	 *
57
+	 * @return void
58
+	 */
59
+	public function markAllAsRead()
60
+	{
61
+		return $this->repo->markAllAsRead();
62
+	}
63 63
 
64
-    /**
65
-     * Notify th given user with the given notification.
66
-     *
67
-     * @param  collection $users
68
-     * @param  string     $notification
69
-     * @param  Variadic   $notificationData
70
-     * @return void
71
-     */
72
-    public function notify($users, $notification, ...$notificationData)
73
-    {
74
-        $users = is_array($users) ? $this->userRepo->findBy(['id' => ['op' => 'in', 'val' => $users]]) : $users;
75
-        $notification = 'App\Modules\Notifications\Notifications\\'.$notification;
76
-        \Notification::send($users, new $notification(...$notificationData));
77
-    }
64
+	/**
65
+	 * Notify th given user with the given notification.
66
+	 *
67
+	 * @param  collection $users
68
+	 * @param  string     $notification
69
+	 * @param  Variadic   $notificationData
70
+	 * @return void
71
+	 */
72
+	public function notify($users, $notification, ...$notificationData)
73
+	{
74
+		$users = is_array($users) ? $this->userRepo->findBy(['id' => ['op' => 'in', 'val' => $users]]) : $users;
75
+		$notification = 'App\Modules\Notifications\Notifications\\'.$notification;
76
+		\Notification::send($users, new $notification(...$notificationData));
77
+	}
78 78
 }
Please login to merge, or discard this patch.
Modules/PushNotificationDevices/Services/PushNotificationDeviceService.php 2 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -3,9 +3,6 @@
 block discarded – undo
3 3
 namespace App\Modules\PushNotificationDevices\Services;
4 4
 
5 5
 use App\Modules\Core\BaseClasses\BaseService;
6
-use LaravelFCM\Message\OptionsBuilder;
7
-use LaravelFCM\Message\PayloadDataBuilder;
8
-use LaravelFCM\Message\PayloadNotificationBuilder;
9 6
 use App\Modules\PushNotificationDevices\Repositories\PushNotificationDeviceRepository;
10 7
 
11 8
 class PushNotificationDeviceService extends BaseService
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -10,38 +10,38 @@
 block discarded – undo
10 10
 
11 11
 class PushNotificationDeviceService extends BaseService
12 12
 {
13
-    /**
14
-     * Init new object.
15
-     *
16
-     * @param   PushNotificationDeviceRepository $repo
17
-     * @return  void
18
-     */
19
-    public function __construct(PushNotificationDeviceRepository $repo)
20
-    {
21
-        parent::__construct($repo);
22
-    }
13
+	/**
14
+	 * Init new object.
15
+	 *
16
+	 * @param   PushNotificationDeviceRepository $repo
17
+	 * @return  void
18
+	 */
19
+	public function __construct(PushNotificationDeviceRepository $repo)
20
+	{
21
+		parent::__construct($repo);
22
+	}
23 23
 
24
-    /**
25
-     * Register the given device to the logged in user.
26
-     *
27
-     * @param  array $data
28
-     * @return void
29
-     */
30
-    public function registerDevice($data)
31
-    {
32
-        $data['access_token'] = \Auth::user()->token();
33
-        $data['user_id']      = \Auth::id();
34
-        $device               = $this->repo->first([
35
-            'and' => [
36
-                'device_token' => $data['device_token'],
37
-                'user_id' => $data['user_id']
38
-                ]
39
-            ]);
24
+	/**
25
+	 * Register the given device to the logged in user.
26
+	 *
27
+	 * @param  array $data
28
+	 * @return void
29
+	 */
30
+	public function registerDevice($data)
31
+	{
32
+		$data['access_token'] = \Auth::user()->token();
33
+		$data['user_id']      = \Auth::id();
34
+		$device               = $this->repo->first([
35
+			'and' => [
36
+				'device_token' => $data['device_token'],
37
+				'user_id' => $data['user_id']
38
+				]
39
+			]);
40 40
 
41
-        if ($device) {
42
-            $data['id'] = $device->id;
43
-        }
41
+		if ($device) {
42
+			$data['id'] = $device->id;
43
+		}
44 44
 
45
-        return $this->repo->save($data);
46
-    }
45
+		return $this->repo->save($data);
46
+	}
47 47
 }
Please login to merge, or discard this patch.
src/Modules/Reporting/Repositories/ReportRepository.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -7,45 +7,45 @@
 block discarded – undo
7 7
 
8 8
 class ReportRepository extends BaseRepository
9 9
 {
10
-    /**
11
-     * Init new object.
12
-     *
13
-     * @param   Report $model
14
-     * @return  void
15
-     */
16
-    public function __construct(Report $model)
17
-    {
18
-        parent::__construct($model);
19
-    }
10
+	/**
11
+	 * Init new object.
12
+	 *
13
+	 * @param   Report $model
14
+	 * @return  void
15
+	 */
16
+	public function __construct(Report $model)
17
+	{
18
+		parent::__construct($model);
19
+	}
20 20
 
21
-    /**
22
-     * Render the given report db view based on the given
23
-     * condition.
24
-     *
25
-     * @param  mixed   $report
26
-     * @param  array   $conditions
27
-     * @param  integer $perPage
28
-     * @return object
29
-     */
30
-    public function renderReport($report, $conditions = [], $perPage = 0)
31
-    {
32
-        $report = ! filter_var($report, FILTER_VALIDATE_INT) ? $report : $this->find($report);
33
-        /**
34
-         * Fetch data from the report based on the given conditions.
35
-         */
36
-        $report = \DB::table($report->view_name);
37
-        unset($conditions['page']);
38
-        if (count($conditions)) {
39
-            $conditions = $this->constructConditions($conditions, $this->model);
40
-            $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
41
-        }
42
-        /**
43
-         * Paginate or all data.
44
-         */
45
-        if ($perPage) {
46
-            return $report->paginate($perPage);
47
-        } else {
48
-            return $report->get();
49
-        }
50
-    }
21
+	/**
22
+	 * Render the given report db view based on the given
23
+	 * condition.
24
+	 *
25
+	 * @param  mixed   $report
26
+	 * @param  array   $conditions
27
+	 * @param  integer $perPage
28
+	 * @return object
29
+	 */
30
+	public function renderReport($report, $conditions = [], $perPage = 0)
31
+	{
32
+		$report = ! filter_var($report, FILTER_VALIDATE_INT) ? $report : $this->find($report);
33
+		/**
34
+		 * Fetch data from the report based on the given conditions.
35
+		 */
36
+		$report = \DB::table($report->view_name);
37
+		unset($conditions['page']);
38
+		if (count($conditions)) {
39
+			$conditions = $this->constructConditions($conditions, $this->model);
40
+			$report->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
41
+		}
42
+		/**
43
+		 * Paginate or all data.
44
+		 */
45
+		if ($perPage) {
46
+			return $report->paginate($perPage);
47
+		} else {
48
+			return $report->get();
49
+		}
50
+	}
51 51
 }
Please login to merge, or discard this patch.
src/Modules/Users/Http/Requests/Register.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,27 +6,27 @@
 block discarded – undo
6 6
 
7 7
 class Register 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
-            'name'     => 'nullable|string',
28
-            'email'    => 'required|email|unique:users,email',
29
-            'password' => 'required|min:6'
30
-        ];
31
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'name'     => 'nullable|string',
28
+			'email'    => 'required|email|unique:users,email',
29
+			'password' => 'required|min:6'
30
+		];
31
+	}
32 32
 }
Please login to merge, or discard this patch.
src/Modules/Users/Http/Requests/AssignRoles.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -6,26 +6,26 @@
 block discarded – undo
6 6
 
7 7
 class AssignRoles 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
-            'role_ids' => 'required|array',
28
-            'role_ids.*' => 'required|exists:roles,id'
29
-        ];
30
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'role_ids' => 'required|array',
28
+			'role_ids.*' => 'required|exists:roles,id'
29
+		];
30
+	}
31 31
 }
Please login to merge, or discard this patch.
src/Modules/Users/AclUser.php 1 patch
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -12,112 +12,112 @@
 block discarded – undo
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', 'blocked', 'confirmed'];
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', 'blocked', 'confirmed'];
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
 }
Please login to merge, or discard this patch.