@@ -8,16 +8,16 @@ |
||
8 | 8 | |
9 | 9 | class DummyModel extends Model |
10 | 10 | { |
11 | - use SoftDeletes; |
|
12 | - protected $table = 'DummyTableName'; |
|
13 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
14 | - protected $hidden = ['deleted_at']; |
|
15 | - protected $guarded = ['id']; |
|
16 | - protected $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 | + protected $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 | } |
@@ -8,39 +8,39 @@ |
||
8 | 8 | |
9 | 9 | class SetSessions |
10 | 10 | { |
11 | - protected $app; |
|
12 | - protected $session; |
|
11 | + protected $app; |
|
12 | + protected $session; |
|
13 | 13 | |
14 | - /** |
|
15 | - * Init new object. |
|
16 | - * |
|
17 | - * @param App $app |
|
18 | - * @param Session $session |
|
19 | - * |
|
20 | - * @return void |
|
21 | - */ |
|
22 | - public function __construct(App $app, Session $session) |
|
23 | - { |
|
24 | - $this->app = $app; |
|
25 | - $this->session = $session; |
|
26 | - } |
|
14 | + /** |
|
15 | + * Init new object. |
|
16 | + * |
|
17 | + * @param App $app |
|
18 | + * @param Session $session |
|
19 | + * |
|
20 | + * @return void |
|
21 | + */ |
|
22 | + public function __construct(App $app, Session $session) |
|
23 | + { |
|
24 | + $this->app = $app; |
|
25 | + $this->session = $session; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Handle an incoming request. |
|
30 | - * |
|
31 | - * @param \Illuminate\Http\Request $request |
|
32 | - * @param \Closure $next |
|
33 | - * @return mixed |
|
34 | - */ |
|
35 | - public function handle($request, Closure $next) |
|
36 | - { |
|
37 | - $locale = $request->header('locale', 'en'); |
|
38 | - $timeZone = $request->header('time-zone', 0); |
|
28 | + /** |
|
29 | + * Handle an incoming request. |
|
30 | + * |
|
31 | + * @param \Illuminate\Http\Request $request |
|
32 | + * @param \Closure $next |
|
33 | + * @return mixed |
|
34 | + */ |
|
35 | + public function handle($request, Closure $next) |
|
36 | + { |
|
37 | + $locale = $request->header('locale', 'en'); |
|
38 | + $timeZone = $request->header('time-zone', 0); |
|
39 | 39 | |
40 | - $this->session->put('time-zone', $timeZone); |
|
41 | - $this->session->put('locale', $locale); |
|
42 | - $this->app->setLocale($locale); |
|
40 | + $this->session->put('time-zone', $timeZone); |
|
41 | + $this->session->put('locale', $locale); |
|
42 | + $this->app->setLocale($locale); |
|
43 | 43 | |
44 | - return $next($request); |
|
45 | - } |
|
44 | + return $next($request); |
|
45 | + } |
|
46 | 46 | } |
@@ -10,21 +10,21 @@ |
||
10 | 10 | class Permission extends Model |
11 | 11 | { |
12 | 12 | |
13 | - use SoftDeletes; |
|
14 | - protected $table = 'permissions'; |
|
15 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
16 | - protected $hidden = ['deleted_at']; |
|
17 | - protected $guarded = ['id']; |
|
18 | - protected $fillable = ['name', 'model']; |
|
13 | + use SoftDeletes; |
|
14 | + protected $table = 'permissions'; |
|
15 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
16 | + protected $hidden = ['deleted_at']; |
|
17 | + protected $guarded = ['id']; |
|
18 | + protected $fillable = ['name', 'model']; |
|
19 | 19 | |
20 | - public function roles() |
|
21 | - { |
|
22 | - return $this->belongsToMany(Role::class, 'permission_role', 'permission_id', 'role_id')->whereNull('permission_role.deleted_at')->withTimestamps(); |
|
23 | - } |
|
20 | + public function roles() |
|
21 | + { |
|
22 | + return $this->belongsToMany(Role::class, 'permission_role', 'permission_id', 'role_id')->whereNull('permission_role.deleted_at')->withTimestamps(); |
|
23 | + } |
|
24 | 24 | |
25 | - public static function boot() |
|
26 | - { |
|
27 | - parent::boot(); |
|
28 | - Permission::observe(PermissionObserver::class); |
|
29 | - } |
|
25 | + public static function boot() |
|
26 | + { |
|
27 | + parent::boot(); |
|
28 | + Permission::observe(PermissionObserver::class); |
|
29 | + } |
|
30 | 30 | } |
@@ -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 | - protected $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 | + protected $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 | } |
@@ -6,5 +6,5 @@ |
||
6 | 6 | |
7 | 7 | class Notification extends DatabaseNotification |
8 | 8 | { |
9 | - // |
|
9 | + // |
|
10 | 10 | } |
@@ -12,117 +12,117 @@ |
||
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 | - protected $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone']; |
|
21 | - |
|
22 | - /** |
|
23 | - * Get the profile picture url. |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function getProfilePictureAttribute($value) |
|
27 | - { |
|
28 | - return url(\Storage::url($value)); |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * Encrypt the password attribute before |
|
33 | - * saving it in the storage. |
|
34 | - * |
|
35 | - * @param string $value |
|
36 | - */ |
|
37 | - public function setPasswordAttribute($value) |
|
38 | - { |
|
39 | - $this->attributes['password'] = \Hash::make($value); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Get the entity's notifications. |
|
44 | - */ |
|
45 | - public function notifications() |
|
46 | - { |
|
47 | - return $this->morphMany(Notification::class, 'notifiable')->orderBy('created_at', 'desc'); |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * Get the entity's read notifications. |
|
52 | - */ |
|
53 | - public function readNotifications() |
|
54 | - { |
|
55 | - return $this->notifications()->whereNotNull('read_at'); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Get the entity's unread notifications. |
|
60 | - */ |
|
61 | - public function unreadNotifications() |
|
62 | - { |
|
63 | - return $this->notifications()->whereNull('read_at'); |
|
64 | - } |
|
65 | - |
|
66 | - public function roles() |
|
67 | - { |
|
68 | - return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id')->whereNull('role_user.deleted_at')->withTimestamps(); |
|
69 | - } |
|
70 | - |
|
71 | - public function oauthClients() |
|
72 | - { |
|
73 | - return $this->hasMany(OauthClient::class, 'user_id'); |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Return fcm device tokens that will be used in sending fcm notifications. |
|
78 | - * |
|
79 | - * @return array |
|
80 | - */ |
|
81 | - public function routeNotificationForFCM() |
|
82 | - { |
|
83 | - $devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]); |
|
84 | - $tokens = []; |
|
85 | - |
|
86 | - foreach ($devices as $device) { |
|
87 | - if (\Core::oauthClients()->accessTokenExpiredOrRevoked($device->access_token)) { |
|
88 | - $device->forceDelete(); |
|
89 | - continue; |
|
90 | - } |
|
91 | - |
|
92 | - $tokens[] = $device->device_token; |
|
93 | - } |
|
94 | - |
|
95 | - return $tokens; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * The channels the user receives notification broadcasts on. |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public function receivesBroadcastNotificationsOn() |
|
104 | - { |
|
105 | - return 'users.'.$this->id; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Custom password validation. |
|
110 | - * |
|
111 | - * @param string $password |
|
112 | - * @return boolean |
|
113 | - */ |
|
114 | - public function validateForPassportPasswordGrant($password) |
|
115 | - { |
|
116 | - if ($password == config('skeleton.social_pass')) { |
|
117 | - return true; |
|
118 | - } |
|
119 | - |
|
120 | - return \Hash::check($password, $this->password); |
|
121 | - } |
|
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 | + protected $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone']; |
|
21 | + |
|
22 | + /** |
|
23 | + * Get the profile picture url. |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function getProfilePictureAttribute($value) |
|
27 | + { |
|
28 | + return url(\Storage::url($value)); |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * Encrypt the password attribute before |
|
33 | + * saving it in the storage. |
|
34 | + * |
|
35 | + * @param string $value |
|
36 | + */ |
|
37 | + public function setPasswordAttribute($value) |
|
38 | + { |
|
39 | + $this->attributes['password'] = \Hash::make($value); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Get the entity's notifications. |
|
44 | + */ |
|
45 | + public function notifications() |
|
46 | + { |
|
47 | + return $this->morphMany(Notification::class, 'notifiable')->orderBy('created_at', 'desc'); |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * Get the entity's read notifications. |
|
52 | + */ |
|
53 | + public function readNotifications() |
|
54 | + { |
|
55 | + return $this->notifications()->whereNotNull('read_at'); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Get the entity's unread notifications. |
|
60 | + */ |
|
61 | + public function unreadNotifications() |
|
62 | + { |
|
63 | + return $this->notifications()->whereNull('read_at'); |
|
64 | + } |
|
65 | + |
|
66 | + public function roles() |
|
67 | + { |
|
68 | + return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id')->whereNull('role_user.deleted_at')->withTimestamps(); |
|
69 | + } |
|
70 | + |
|
71 | + public function oauthClients() |
|
72 | + { |
|
73 | + return $this->hasMany(OauthClient::class, 'user_id'); |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Return fcm device tokens that will be used in sending fcm notifications. |
|
78 | + * |
|
79 | + * @return array |
|
80 | + */ |
|
81 | + public function routeNotificationForFCM() |
|
82 | + { |
|
83 | + $devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]); |
|
84 | + $tokens = []; |
|
85 | + |
|
86 | + foreach ($devices as $device) { |
|
87 | + if (\Core::oauthClients()->accessTokenExpiredOrRevoked($device->access_token)) { |
|
88 | + $device->forceDelete(); |
|
89 | + continue; |
|
90 | + } |
|
91 | + |
|
92 | + $tokens[] = $device->device_token; |
|
93 | + } |
|
94 | + |
|
95 | + return $tokens; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * The channels the user receives notification broadcasts on. |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + public function receivesBroadcastNotificationsOn() |
|
104 | + { |
|
105 | + return 'users.'.$this->id; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Custom password validation. |
|
110 | + * |
|
111 | + * @param string $password |
|
112 | + * @return boolean |
|
113 | + */ |
|
114 | + public function validateForPassportPasswordGrant($password) |
|
115 | + { |
|
116 | + if ($password == config('skeleton.social_pass')) { |
|
117 | + return true; |
|
118 | + } |
|
119 | + |
|
120 | + return \Hash::check($password, $this->password); |
|
121 | + } |
|
122 | 122 | |
123 | - public static function boot() |
|
124 | - { |
|
125 | - parent::boot(); |
|
126 | - AclUser::observe(AclUserObserver::class); |
|
127 | - } |
|
123 | + public static function boot() |
|
124 | + { |
|
125 | + parent::boot(); |
|
126 | + AclUser::observe(AclUserObserver::class); |
|
127 | + } |
|
128 | 128 | } |
@@ -6,26 +6,26 @@ |
||
6 | 6 | |
7 | 7 | class Login 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 | - 'email' => 'required|email', |
|
28 | - 'password' => 'required|min:6' |
|
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 | + 'email' => 'required|email', |
|
28 | + 'password' => 'required|min:6' |
|
29 | + ]; |
|
30 | + } |
|
31 | 31 | } |
@@ -8,17 +8,17 @@ |
||
8 | 8 | |
9 | 9 | class OauthClient extends Client |
10 | 10 | { |
11 | - protected $dates = ['created_at', 'updated_at']; |
|
12 | - protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked']; |
|
11 | + protected $dates = ['created_at', 'updated_at']; |
|
12 | + protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked']; |
|
13 | 13 | |
14 | - public function user() |
|
15 | - { |
|
16 | - return $this->belongsTo(AclUser::class); |
|
17 | - } |
|
14 | + public function user() |
|
15 | + { |
|
16 | + return $this->belongsTo(AclUser::class); |
|
17 | + } |
|
18 | 18 | |
19 | - public static function boot() |
|
20 | - { |
|
21 | - parent::boot(); |
|
22 | - OauthClient::observe(OauthClientObserver::class); |
|
23 | - } |
|
19 | + public static function boot() |
|
20 | + { |
|
21 | + parent::boot(); |
|
22 | + OauthClient::observe(OauthClientObserver::class); |
|
23 | + } |
|
24 | 24 | } |
@@ -11,26 +11,26 @@ |
||
11 | 11 | class Role extends Model |
12 | 12 | { |
13 | 13 | |
14 | - use SoftDeletes; |
|
15 | - protected $table = 'roles'; |
|
16 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
17 | - protected $hidden = ['deleted_at']; |
|
18 | - protected $guarded = ['id']; |
|
19 | - protected $fillable = ['name']; |
|
14 | + use SoftDeletes; |
|
15 | + protected $table = 'roles'; |
|
16 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
17 | + protected $hidden = ['deleted_at']; |
|
18 | + protected $guarded = ['id']; |
|
19 | + protected $fillable = ['name']; |
|
20 | 20 | |
21 | - public function users() |
|
22 | - { |
|
23 | - return $this->belongsToMany(AclUser::class, 'role_user', 'role_id', 'user_id')->whereNull('role_user.deleted_at')->withTimestamps(); |
|
24 | - } |
|
21 | + public function users() |
|
22 | + { |
|
23 | + return $this->belongsToMany(AclUser::class, 'role_user', 'role_id', 'user_id')->whereNull('role_user.deleted_at')->withTimestamps(); |
|
24 | + } |
|
25 | 25 | |
26 | - public function permissions() |
|
27 | - { |
|
28 | - return $this->belongsToMany(Permission::class, 'permission_role', 'role_id', 'permission_id')->whereNull('permission_role.deleted_at')->withTimestamps(); |
|
29 | - } |
|
26 | + public function permissions() |
|
27 | + { |
|
28 | + return $this->belongsToMany(Permission::class, 'permission_role', 'role_id', 'permission_id')->whereNull('permission_role.deleted_at')->withTimestamps(); |
|
29 | + } |
|
30 | 30 | |
31 | - public static function boot() |
|
32 | - { |
|
33 | - parent::boot(); |
|
34 | - Role::observe(RoleObserver::class); |
|
35 | - } |
|
31 | + public static function boot() |
|
32 | + { |
|
33 | + parent::boot(); |
|
34 | + Role::observe(RoleObserver::class); |
|
35 | + } |
|
36 | 36 | } |