Completed
Push — master ( cf2713...aee5ae )
by Sherif
02:07
created
src/Modules/Users/Database/Seeds/ClearDataSeeder.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@
 block discarded – undo
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', ['user']);
17
-        \DB::table('permission_role')->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', ['user']);
17
+		\DB::table('permission_role')->whereIn('permission_id', $permissions->pluck('id'))->delete();
18
+		$permissions->delete();
19
+	}
20 20
 }
Please login to merge, or discard this patch.
src/Modules/Users/AclUser.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -10,133 +10,133 @@
 block discarded – undo
10 10
 class AclUser extends User
11 11
 {
12 12
 
13
-    use SoftDeletes, HasApiTokens;
14
-    protected $table    = 'users';
15
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
16
-    protected $hidden   = ['password', 'remember_token', 'deleted_at'];
17
-    protected $guarded  = ['id'];
18
-    protected $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone'];
19
-    public $searchable  = ['name', 'email'];
13
+	use SoftDeletes, HasApiTokens;
14
+	protected $table    = 'users';
15
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
16
+	protected $hidden   = ['password', 'remember_token', 'deleted_at'];
17
+	protected $guarded  = ['id'];
18
+	protected $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone'];
19
+	public $searchable  = ['name', 'email'];
20 20
     
21
-    public function getCreatedAtAttribute($value)
22
-    {
23
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
24
-    }
25
-
26
-    public function getUpdatedAtAttribute($value)
27
-    {
28
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
29
-    }
30
-
31
-    public function getDeletedAtAttribute($value)
32
-    {
33
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
34
-    }
35
-
36
-    /**
37
-     * Get the profile picture url.
38
-     * @return string
39
-     */
40
-    public function getProfilePictureAttribute($value)
41
-    {
42
-        return url(\Storage::url($value));
43
-    }
44
-
45
-    /**
46
-     * Encrypt the password attribute before
47
-     * saving it in the storage.
48
-     *
49
-     * @param string $value
50
-     */
51
-    public function setPasswordAttribute($value)
52
-    {
53
-        $this->attributes['password'] = \Hash::make($value);
54
-    }
55
-
56
-    /**
57
-     * Get the entity's notifications.
58
-     */
59
-    public function notifications()
60
-    {
61
-        return $this->morphMany(Notification::class, 'notifiable')->orderBy('created_at', 'desc');
62
-    }
63
-
64
-    /**
65
-     * Get the entity's read notifications.
66
-     */
67
-    public function readNotifications()
68
-    {
69
-        return $this->notifications()->whereNotNull('read_at');
70
-    }
71
-
72
-    /**
73
-     * Get the entity's unread notifications.
74
-     */
75
-    public function unreadNotifications()
76
-    {
77
-        return $this->notifications()->whereNull('read_at');
78
-    }
79
-
80
-    public function roles()
81
-    {
82
-        return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id')->whereNull('role_user.deleted_at')->withTimestamps();
83
-    }
84
-
85
-    public function oauthClients()
86
-    {
87
-        return $this->hasMany(OauthClient::class, 'user_id');
88
-    }
89
-
90
-    /**
91
-     * Return fcm device tokens that will be used in sending fcm notifications.
92
-     *
93
-     * @return array
94
-     */
95
-    public function routeNotificationForFCM()
96
-    {
97
-        $devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]);
98
-        $tokens  = [];
99
-
100
-        foreach ($devices as $device) {
101
-            if (\Core::oauthClients()->accessTokenExpiredOrRevoked($device->access_token)) {
102
-                $device->forceDelete();
103
-                continue;
104
-            }
105
-
106
-            $tokens[] = $device->device_token;
107
-        }
108
-
109
-        return $tokens;
110
-    }
111
-
112
-    /**
113
-     * The channels the user receives notification broadcasts on.
114
-     *
115
-     * @return string
116
-     */
117
-    public function receivesBroadcastNotificationsOn()
118
-    {
119
-        return 'users.'.$this->id;
120
-    }
121
-
122
-    /**
123
-     * Custom password validation.
124
-     *
125
-     * @param  string $password
126
-     * @return boolean
127
-     */
128
-    public function validateForPassportPasswordGrant($password)
129
-    {
130
-        if ($password == config('skeleton.social_pass')) {
131
-            return true;
132
-        }
133
-
134
-        return \Hash::check($password, $this->password);
135
-    }
21
+	public function getCreatedAtAttribute($value)
22
+	{
23
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
24
+	}
25
+
26
+	public function getUpdatedAtAttribute($value)
27
+	{
28
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
29
+	}
30
+
31
+	public function getDeletedAtAttribute($value)
32
+	{
33
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
34
+	}
35
+
36
+	/**
37
+	 * Get the profile picture url.
38
+	 * @return string
39
+	 */
40
+	public function getProfilePictureAttribute($value)
41
+	{
42
+		return url(\Storage::url($value));
43
+	}
44
+
45
+	/**
46
+	 * Encrypt the password attribute before
47
+	 * saving it in the storage.
48
+	 *
49
+	 * @param string $value
50
+	 */
51
+	public function setPasswordAttribute($value)
52
+	{
53
+		$this->attributes['password'] = \Hash::make($value);
54
+	}
55
+
56
+	/**
57
+	 * Get the entity's notifications.
58
+	 */
59
+	public function notifications()
60
+	{
61
+		return $this->morphMany(Notification::class, 'notifiable')->orderBy('created_at', 'desc');
62
+	}
63
+
64
+	/**
65
+	 * Get the entity's read notifications.
66
+	 */
67
+	public function readNotifications()
68
+	{
69
+		return $this->notifications()->whereNotNull('read_at');
70
+	}
71
+
72
+	/**
73
+	 * Get the entity's unread notifications.
74
+	 */
75
+	public function unreadNotifications()
76
+	{
77
+		return $this->notifications()->whereNull('read_at');
78
+	}
79
+
80
+	public function roles()
81
+	{
82
+		return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id')->whereNull('role_user.deleted_at')->withTimestamps();
83
+	}
84
+
85
+	public function oauthClients()
86
+	{
87
+		return $this->hasMany(OauthClient::class, 'user_id');
88
+	}
89
+
90
+	/**
91
+	 * Return fcm device tokens that will be used in sending fcm notifications.
92
+	 *
93
+	 * @return array
94
+	 */
95
+	public function routeNotificationForFCM()
96
+	{
97
+		$devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]);
98
+		$tokens  = [];
99
+
100
+		foreach ($devices as $device) {
101
+			if (\Core::oauthClients()->accessTokenExpiredOrRevoked($device->access_token)) {
102
+				$device->forceDelete();
103
+				continue;
104
+			}
105
+
106
+			$tokens[] = $device->device_token;
107
+		}
108
+
109
+		return $tokens;
110
+	}
111
+
112
+	/**
113
+	 * The channels the user receives notification broadcasts on.
114
+	 *
115
+	 * @return string
116
+	 */
117
+	public function receivesBroadcastNotificationsOn()
118
+	{
119
+		return 'users.'.$this->id;
120
+	}
121
+
122
+	/**
123
+	 * Custom password validation.
124
+	 *
125
+	 * @param  string $password
126
+	 * @return boolean
127
+	 */
128
+	public function validateForPassportPasswordGrant($password)
129
+	{
130
+		if ($password == config('skeleton.social_pass')) {
131
+			return true;
132
+		}
133
+
134
+		return \Hash::check($password, $this->password);
135
+	}
136 136
     
137
-    public static function boot()
138
-    {
139
-        parent::boot();
140
-        AclUser::observe(\App::make('App\Modules\Users\ModelObservers\AclUserObserver'));
141
-    }
137
+	public static function boot()
138
+	{
139
+		parent::boot();
140
+		AclUser::observe(\App::make('App\Modules\Users\ModelObservers\AclUserObserver'));
141
+	}
142 142
 }
Please login to merge, or discard this patch.
src/Modules/Users/Proxy/LoginProxy.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -5,64 +5,64 @@
 block discarded – undo
5 5
 
6 6
 class LoginProxy
7 7
 {
8
-    /**
9
-     * Attempt to create an access token using user credentials.
10
-     *
11
-     * @param  string  $email
12
-     * @param  string  $password
13
-     * @return array
14
-     */
15
-    public function login($email, $password)
16
-    {
17
-        return $this->proxy('password', [
18
-            'username' => $email,
19
-            'password' => $password
20
-        ]);
21
-    }
8
+	/**
9
+	 * Attempt to create an access token using user credentials.
10
+	 *
11
+	 * @param  string  $email
12
+	 * @param  string  $password
13
+	 * @return array
14
+	 */
15
+	public function login($email, $password)
16
+	{
17
+		return $this->proxy('password', [
18
+			'username' => $email,
19
+			'password' => $password
20
+		]);
21
+	}
22 22
 
23
-    /**
24
-     * Attempt to refresh the access token using the given refresh token.
25
-     *
26
-     * @param  string $refreshToken
27
-     * @return array
28
-     */
29
-    public function refreshToken($refreshToken)
30
-    {
31
-        return $this->proxy('refresh_token', [
32
-            'refresh_token' => $refreshToken
33
-        ]);
34
-    }
23
+	/**
24
+	 * Attempt to refresh the access token using the given refresh token.
25
+	 *
26
+	 * @param  string $refreshToken
27
+	 * @return array
28
+	 */
29
+	public function refreshToken($refreshToken)
30
+	{
31
+		return $this->proxy('refresh_token', [
32
+			'refresh_token' => $refreshToken
33
+		]);
34
+	}
35 35
 
36
-    /**
37
-     * Proxy a request to the OAuth server.
38
-     *
39
-     * @param string $grantType what type of grant type should be proxied
40
-     * @param array
41
-     */
42
-    public function proxy($grantType, array $data = [])
43
-    {
44
-        $data = array_merge($data, [
45
-            'client_id'     => config('skeleton.passport_client_id'),
46
-            'client_secret' => config('skeleton.passport_client_secret'),
47
-            'grant_type'    => $grantType
48
-        ]);
36
+	/**
37
+	 * Proxy a request to the OAuth server.
38
+	 *
39
+	 * @param string $grantType what type of grant type should be proxied
40
+	 * @param array
41
+	 */
42
+	public function proxy($grantType, array $data = [])
43
+	{
44
+		$data = array_merge($data, [
45
+			'client_id'     => config('skeleton.passport_client_id'),
46
+			'client_secret' => config('skeleton.passport_client_secret'),
47
+			'grant_type'    => $grantType
48
+		]);
49 49
 
50
-        $response = \ApiConsumer::post('/oauth/token', $data);
50
+		$response = \ApiConsumer::post('/oauth/token', $data);
51 51
 
52
-        if (! $response->isSuccessful()) {
53
-            if ($grantType == 'refresh_token') {
54
-                \ErrorHandler::invalidRefreshToken();
55
-            }
52
+		if (! $response->isSuccessful()) {
53
+			if ($grantType == 'refresh_token') {
54
+				\ErrorHandler::invalidRefreshToken();
55
+			}
56 56
 
57
-            \ErrorHandler::loginFailed();
58
-        }
57
+			\ErrorHandler::loginFailed();
58
+		}
59 59
 
60
-        $data = json_decode($response->getContent());
60
+		$data = json_decode($response->getContent());
61 61
 
62
-        return [
63
-            'access_token'  => $data->access_token,
64
-            'refresh_token' => $data->refresh_token,
65
-            'expires_in'    => $data->expires_in
66
-        ];
67
-    }
62
+		return [
63
+			'access_token'  => $data->access_token,
64
+			'refresh_token' => $data->refresh_token,
65
+			'expires_in'    => $data->expires_in
66
+		];
67
+	}
68 68
 }
Please login to merge, or discard this patch.
Modules/PushNotificationDevices/Database/Seeds/AssignRelationsSeeder.php 2 patches
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 AssignRelationsSeeder extends Seeder
8 8
 {
9
-    /**
10
-     * Run the database seeds.
11
-     *
12
-     * @return void
13
-     */
14
-    public function run()
15
-    {
16
-        $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id;
9
+	/**
10
+	 * Run the database seeds.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function run()
15
+	{
16
+		$adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id;
17 17
 
18
-        /**
19
-         * Assign the permissions to the admin role.
20
-         */
21
-        \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['pushNotificationDevice'])->each(function ($permission) use ($adminRoleId) {
22
-            \DB::table('permission_role')->insert(
23
-                [
24
-                'permission_id' => $permission->id,
25
-                'role_id'      => $adminRoleId,
26
-                'created_at'    => \DB::raw('NOW()'),
27
-                'updated_at'    => \DB::raw('NOW()')
28
-                ]
29
-            );
30
-        });
31
-    }
18
+		/**
19
+		 * Assign the permissions to the admin role.
20
+		 */
21
+		\DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['pushNotificationDevice'])->each(function ($permission) use ($adminRoleId) {
22
+			\DB::table('permission_role')->insert(
23
+				[
24
+				'permission_id' => $permission->id,
25
+				'role_id'      => $adminRoleId,
26
+				'created_at'    => \DB::raw('NOW()'),
27
+				'updated_at'    => \DB::raw('NOW()')
28
+				]
29
+			);
30
+		});
31
+	}
32 32
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
         /**
19 19
          * Assign the permissions to the admin role.
20 20
          */
21
-        \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['pushNotificationDevice'])->each(function ($permission) use ($adminRoleId) {
21
+        \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['pushNotificationDevice'])->each(function($permission) use ($adminRoleId) {
22 22
             \DB::table('permission_role')->insert(
23 23
                 [
24 24
                 'permission_id' => $permission->id,
Please login to merge, or discard this patch.
src/Modules/PushNotificationDevices/Database/Seeds/ClearDataSeeder.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@
 block discarded – undo
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', ['pushNotificationDevice']);
17
-        \DB::table('permission_role')->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', ['pushNotificationDevice']);
17
+		\DB::table('permission_role')->whereIn('permission_id', $permissions->pluck('id'))->delete();
18
+		$permissions->delete();
19
+	}
20 20
 }
Please login to merge, or discard this patch.
Database/Migrations/2016_01_24_111942_push_notification_devices.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -5,33 +5,33 @@
 block discarded – undo
5 5
 
6 6
 class PushNotificationDevices extends Migration
7 7
 {
8
-    /**
9
-     * Run the migrations.
10
-     *
11
-     * @return void
12
-     */
13
-    public function up()
14
-    {
15
-        Schema::create('push_notification_devices', function (Blueprint $table) {
16
-            $table->increments('id');
17
-            $table->string('device_token');
18
-            $table->unsignedInteger('user_id');
19
-            $table->text('access_token')->nullable();
20
-            $table->unique(array('device_token', 'user_id'));
21
-            $table->softDeletes();
22
-            $table->timestamps();
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('push_notification_devices', function (Blueprint $table) {
16
+			$table->increments('id');
17
+			$table->string('device_token');
18
+			$table->unsignedInteger('user_id');
19
+			$table->text('access_token')->nullable();
20
+			$table->unique(array('device_token', 'user_id'));
21
+			$table->softDeletes();
22
+			$table->timestamps();
23 23
             
24
-            $table->foreign('user_id')->references('id')->on('users');
25
-        });
26
-    }
24
+			$table->foreign('user_id')->references('id')->on('users');
25
+		});
26
+	}
27 27
 
28
-    /**
29
-     * Reverse the migrations.
30
-     *
31
-     * @return void
32
-     */
33
-    public function down()
34
-    {
35
-        Schema::dropIfExists('push_notification_devices');
36
-    }
28
+	/**
29
+	 * Reverse the migrations.
30
+	 *
31
+	 * @return void
32
+	 */
33
+	public function down()
34
+	{
35
+		Schema::dropIfExists('push_notification_devices');
36
+	}
37 37
 }
Please login to merge, or discard this patch.
Http/Controllers/PushNotificationDeviceController.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -10,61 +10,61 @@
 block discarded – undo
10 10
 
11 11
 class PushNotificationDeviceController extends BaseApiController
12 12
 {
13
-    /**
14
-     * Path of the model resource
15
-     *
16
-     * @var string
17
-     */
18
-    protected $modelResource = 'App\Modules\PushNotificationDevices\Http\Resources\PushNotificationDevice';
13
+	/**
14
+	 * Path of the model resource
15
+	 *
16
+	 * @var string
17
+	 */
18
+	protected $modelResource = 'App\Modules\PushNotificationDevices\Http\Resources\PushNotificationDevice';
19 19
 
20
-    /**
21
-     * List of all route actions that the base api controller
22
-     * will skip permissions check for them.
23
-     * @var array
24
-     */
25
-    protected $skipPermissionCheck = ['registerDevice'];
20
+	/**
21
+	 * List of all route actions that the base api controller
22
+	 * will skip permissions check for them.
23
+	 * @var array
24
+	 */
25
+	protected $skipPermissionCheck = ['registerDevice'];
26 26
 
27
-    /**
28
-     * Init new object.
29
-     *
30
-     * @param   PushNotificationDeviceService $service
31
-     * @return  void
32
-     */
33
-    public function __construct(PushNotificationDeviceService $service)
34
-    {
35
-        parent::__construct($service);
36
-    }
27
+	/**
28
+	 * Init new object.
29
+	 *
30
+	 * @param   PushNotificationDeviceService $service
31
+	 * @return  void
32
+	 */
33
+	public function __construct(PushNotificationDeviceService $service)
34
+	{
35
+		parent::__construct($service);
36
+	}
37 37
 
38
-    /**
39
-     * Insert the given model to storage.
40
-     *
41
-     * @param InsertPushNotificationDevice $request
42
-     * @return \Illuminate\Http\Response
43
-     */
44
-    public function insert(InsertPushNotificationDevice $request)
45
-    {
46
-        return new $this->modelResource($this->service->save($request->all()));
47
-    }
38
+	/**
39
+	 * Insert the given model to storage.
40
+	 *
41
+	 * @param InsertPushNotificationDevice $request
42
+	 * @return \Illuminate\Http\Response
43
+	 */
44
+	public function insert(InsertPushNotificationDevice $request)
45
+	{
46
+		return new $this->modelResource($this->service->save($request->all()));
47
+	}
48 48
 
49
-    /**
50
-     * Update the given model to storage.
51
-     *
52
-     * @param UpdatePushNotificationDevice $request
53
-     * @return \Illuminate\Http\Response
54
-     */
55
-    public function update(UpdatePushNotificationDevice $request)
56
-    {
57
-        return new $this->modelResource($this->service->save($request->all()));
58
-    }
49
+	/**
50
+	 * Update the given model to storage.
51
+	 *
52
+	 * @param UpdatePushNotificationDevice $request
53
+	 * @return \Illuminate\Http\Response
54
+	 */
55
+	public function update(UpdatePushNotificationDevice $request)
56
+	{
57
+		return new $this->modelResource($this->service->save($request->all()));
58
+	}
59 59
 
60
-    /**
61
-     * Register the given device to the logged in user.
62
-     *
63
-     * @param RegisterDevice $request
64
-     * @return \Illuminate\Http\Response
65
-     */
66
-    public function registerDevice(RegisterDevice $request)
67
-    {
68
-        return new $this->modelResource($this->service->registerDevice($request->all()));
69
-    }
60
+	/**
61
+	 * Register the given device to the logged in user.
62
+	 *
63
+	 * @param RegisterDevice $request
64
+	 * @return \Illuminate\Http\Response
65
+	 */
66
+	public function registerDevice(RegisterDevice $request)
67
+	{
68
+		return new $this->modelResource($this->service->registerDevice($request->all()));
69
+	}
70 70
 }
Please login to merge, or discard this patch.
src/Modules/PushNotificationDevices/PushNotificationDevice.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -7,48 +7,48 @@
 block discarded – undo
7 7
 class PushNotificationDevice extends Model
8 8
 {
9 9
 
10
-    use SoftDeletes;
11
-    protected $table    = 'push_notification_devices';
12
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
13
-    protected $hidden   = ['deleted_at', 'access_token'];
14
-    protected $guarded  = ['id'];
15
-    protected $fillable = ['device_token', 'user_id', 'access_token'];
16
-    public $searchable  = ['device_token'];
17
-
18
-    public function getCreatedAtAttribute($value)
19
-    {
20
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
21
-    }
22
-
23
-    public function getUpdatedAtAttribute($value)
24
-    {
25
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
26
-    }
27
-
28
-    public function getDeletedAtAttribute($value)
29
-    {
30
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
31
-    }
10
+	use SoftDeletes;
11
+	protected $table    = 'push_notification_devices';
12
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
13
+	protected $hidden   = ['deleted_at', 'access_token'];
14
+	protected $guarded  = ['id'];
15
+	protected $fillable = ['device_token', 'user_id', 'access_token'];
16
+	public $searchable  = ['device_token'];
17
+
18
+	public function getCreatedAtAttribute($value)
19
+	{
20
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
21
+	}
22
+
23
+	public function getUpdatedAtAttribute($value)
24
+	{
25
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
26
+	}
27
+
28
+	public function getDeletedAtAttribute($value)
29
+	{
30
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
31
+	}
32 32
     
33
-    public function user()
34
-    {
35
-        return $this->belongsTo(AclUser::class);
36
-    }
37
-
38
-    /**
39
-     * Encrypt the access_token attribute before
40
-     * saving it in the storage.
41
-     *
42
-     * @param string $value
43
-     */
44
-    public function setLoginTokenAttribute($value)
45
-    {
46
-        $this->attributes['access_token'] = encrypt($value);
47
-    }
48
-
49
-    public static function boot()
50
-    {
51
-        parent::boot();
52
-        PushNotificationDevice::observe(\App::make('App\Modules\PushNotificationDevices\ModelObservers\PushNotificationDeviceObserver'));
53
-    }
33
+	public function user()
34
+	{
35
+		return $this->belongsTo(AclUser::class);
36
+	}
37
+
38
+	/**
39
+	 * Encrypt the access_token attribute before
40
+	 * saving it in the storage.
41
+	 *
42
+	 * @param string $value
43
+	 */
44
+	public function setLoginTokenAttribute($value)
45
+	{
46
+		$this->attributes['access_token'] = encrypt($value);
47
+	}
48
+
49
+	public static function boot()
50
+	{
51
+		parent::boot();
52
+		PushNotificationDevice::observe(\App::make('App\Modules\PushNotificationDevices\ModelObservers\PushNotificationDeviceObserver'));
53
+	}
54 54
 }
Please login to merge, or discard this patch.
Modules/PushNotificationDevices/Services/PushNotificationDeviceService.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -8,63 +8,63 @@
 block discarded – undo
8 8
 
9 9
 class PushNotificationDeviceService extends BaseService
10 10
 {
11
-    /**
12
-     * Init new object.
13
-     *
14
-     * @param   PushNotificationDeviceRepository $repo
15
-     * @return  void
16
-     */
17
-    public function __construct(PushNotificationDeviceRepository $repo)
18
-    {
19
-        parent::__construct($repo);
20
-    }
11
+	/**
12
+	 * Init new object.
13
+	 *
14
+	 * @param   PushNotificationDeviceRepository $repo
15
+	 * @return  void
16
+	 */
17
+	public function __construct(PushNotificationDeviceRepository $repo)
18
+	{
19
+		parent::__construct($repo);
20
+	}
21 21
 
22
-    /**
23
-     * Register the given device to the logged in user.
24
-     *
25
-     * @param  array $data
26
-     * @return void
27
-     */
28
-    public function registerDevice($data)
29
-    {
30
-        $data['access_token'] = \Auth::user()->token();
31
-        $data['user_id']      = \Auth::id();
32
-        $device               = $this->repo->first([
33
-            'and' => [
34
-                'device_token' => $data['device_token'], 
35
-                'user_id' => $data['user_id']
36
-                ]
37
-            ]);
22
+	/**
23
+	 * Register the given device to the logged in user.
24
+	 *
25
+	 * @param  array $data
26
+	 * @return void
27
+	 */
28
+	public function registerDevice($data)
29
+	{
30
+		$data['access_token'] = \Auth::user()->token();
31
+		$data['user_id']      = \Auth::id();
32
+		$device               = $this->repo->first([
33
+			'and' => [
34
+				'device_token' => $data['device_token'], 
35
+				'user_id' => $data['user_id']
36
+				]
37
+			]);
38 38
 
39
-        if ($device) {
40
-            $data['id'] = $device->id;
41
-        }
39
+		if ($device) {
40
+			$data['id'] = $device->id;
41
+		}
42 42
 
43
-        return $this->repo->save($data);
44
-    }
43
+		return $this->repo->save($data);
44
+	}
45 45
 
46
-    /**
47
-     * Generate the given message data.
48
-     *
49
-     * @param  string $title
50
-     * @param  string $message
51
-     * @param  array  $data
52
-     * @return void
53
-     */
54
-    public function generateMessageData($title, $message, $data = [])
55
-    {
56
-        $optionBuilder       = new OptionsBuilder();
57
-        $notificationBuilder = new PayloadNotificationBuilder($title);
58
-        $dataBuilder         = new PayloadDataBuilder();
46
+	/**
47
+	 * Generate the given message data.
48
+	 *
49
+	 * @param  string $title
50
+	 * @param  string $message
51
+	 * @param  array  $data
52
+	 * @return void
53
+	 */
54
+	public function generateMessageData($title, $message, $data = [])
55
+	{
56
+		$optionBuilder       = new OptionsBuilder();
57
+		$notificationBuilder = new PayloadNotificationBuilder($title);
58
+		$dataBuilder         = new PayloadDataBuilder();
59 59
 
60
-        $optionBuilder->setTimeToLive(60 * 20);
61
-        $notificationBuilder->setBody($message);
62
-        $dataBuilder->addData($data);
60
+		$optionBuilder->setTimeToLive(60 * 20);
61
+		$notificationBuilder->setBody($message);
62
+		$dataBuilder->addData($data);
63 63
 
64
-        $options             = $optionBuilder->build();
65
-        $notification        = $notificationBuilder->build();
66
-        $data                = $dataBuilder->build();
64
+		$options             = $optionBuilder->build();
65
+		$notification        = $notificationBuilder->build();
66
+		$data                = $dataBuilder->build();
67 67
 
68
-        return compact('options', 'notification', 'data');
69
-    }
68
+		return compact('options', 'notification', 'data');
69
+	}
70 70
 }
Please login to merge, or discard this patch.