Completed
Push — master ( eb2586...ec2395 )
by Sherif
01:59
created
src/Modules/Notifications/Repositories/NotificationRepository.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -5,73 +5,73 @@
 block discarded – undo
5 5
 
6 6
 class NotificationRepository extends BaseRepository
7 7
 {
8
-    /**
9
-     * Init new object.
10
-     *
11
-     * @param   Notification $model
12
-     * @return  void
13
-     */
14
-    public function __construct(Notification $model)
15
-    {
16
-        parent::__construct($model);
17
-    }
8
+	/**
9
+	 * Init new object.
10
+	 *
11
+	 * @param   Notification $model
12
+	 * @return  void
13
+	 */
14
+	public function __construct(Notification $model)
15
+	{
16
+		parent::__construct($model);
17
+	}
18 18
 
19
-    /**
20
-     * Retrieve all notifications of the logged in user.
21
-     *
22
-     * @param  integer $perPage
23
-     * @return Collection
24
-     */
25
-    public function all($perPage)
26
-    {
27
-        return \Auth::user()->notifications()->paginate($perPage);
28
-    }
19
+	/**
20
+	 * Retrieve all notifications of the logged in user.
21
+	 *
22
+	 * @param  integer $perPage
23
+	 * @return Collection
24
+	 */
25
+	public function all($perPage)
26
+	{
27
+		return \Auth::user()->notifications()->paginate($perPage);
28
+	}
29 29
 
30
-    /**
31
-     * Retrieve unread notifications of the logged in user.
32
-     *
33
-     * @param  integer $perPage
34
-     * @return Collection
35
-     */
36
-    public function unread($perPage)
37
-    {
38
-        return \Auth::user()->unreadNotifications()->paginate($perPage);
39
-    }
30
+	/**
31
+	 * Retrieve unread notifications of the logged in user.
32
+	 *
33
+	 * @param  integer $perPage
34
+	 * @return Collection
35
+	 */
36
+	public function unread($perPage)
37
+	{
38
+		return \Auth::user()->unreadNotifications()->paginate($perPage);
39
+	}
40 40
 
41
-    /**
42
-     * Mark the notification as read.
43
-     *
44
-     * @param  integer  $id
45
-     * @return object
46
-     */
47
-    public function markAsRead($id)
48
-    {
49
-        if ($notification = \Auth::user()->unreadNotifications()->where('id', $id)->first()) {
50
-            $notification->markAsRead();
51
-        }
52
-    }
41
+	/**
42
+	 * Mark the notification as read.
43
+	 *
44
+	 * @param  integer  $id
45
+	 * @return object
46
+	 */
47
+	public function markAsRead($id)
48
+	{
49
+		if ($notification = \Auth::user()->unreadNotifications()->where('id', $id)->first()) {
50
+			$notification->markAsRead();
51
+		}
52
+	}
53 53
 
54
-    /**
55
-     * Mark all notifications as read.
56
-     *
57
-     * @return void
58
-     */
59
-    public function markAllAsRead()
60
-    {
61
-        \Auth::user()->unreadNotifications()->update(['read_at' => now()]);
62
-    }
54
+	/**
55
+	 * Mark all notifications as read.
56
+	 *
57
+	 * @return void
58
+	 */
59
+	public function markAllAsRead()
60
+	{
61
+		\Auth::user()->unreadNotifications()->update(['read_at' => now()]);
62
+	}
63 63
 
64
-    /**
65
-     * Notify th given user with the given notification.
66
-     *
67
-     * @param  collection $users
68
-     * @param  string     $notification
69
-     * @param  object     $notificationData
70
-     * @return void
71
-     */
72
-    public function notify($users, $notification, $notificationData = false)
73
-    {
74
-        $notification = 'App\Modules\Notifications\Notifications\\'.$notification;
75
-        \Notification::send($users, new $notification($notificationData));
76
-    }
64
+	/**
65
+	 * Notify th given user with the given notification.
66
+	 *
67
+	 * @param  collection $users
68
+	 * @param  string     $notification
69
+	 * @param  object     $notificationData
70
+	 * @return void
71
+	 */
72
+	public function notify($users, $notification, $notificationData = false)
73
+	{
74
+		$notification = 'App\Modules\Notifications\Notifications\\'.$notification;
75
+		\Notification::send($users, new $notification($notificationData));
76
+	}
77 77
 }
Please login to merge, or discard this patch.
src/Modules/Notifications/Http/Resources/Notification.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -6,21 +6,21 @@
 block discarded – undo
6 6
 
7 7
 class Notification extends JsonResource
8 8
 {
9
-    /**
10
-     * Transform the resource into an array.
11
-     *
12
-     * @param Request $request
13
-     * @return array
14
-     */
15
-    public function toArray($request)
16
-    {
17
-        return [
18
-            'id' => $this->id,
19
-            'type' => $this->type,
20
-            'data' => $this->data,
21
-            'read_at' => $this->read_at,
22
-            'created_at' => $this->created_at,
23
-            'updated_at' => $this->updated_at,
24
-        ];
25
-    }
9
+	/**
10
+	 * Transform the resource into an array.
11
+	 *
12
+	 * @param Request $request
13
+	 * @return array
14
+	 */
15
+	public function toArray($request)
16
+	{
17
+		return [
18
+			'id' => $this->id,
19
+			'type' => $this->type,
20
+			'data' => $this->data,
21
+			'read_at' => $this->read_at,
22
+			'created_at' => $this->created_at,
23
+			'updated_at' => $this->updated_at,
24
+		];
25
+	}
26 26
 }
Please login to merge, or discard this patch.
src/Modules/Notifications/Http/Resources/PushNotificationDevice.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,21 +7,21 @@
 block discarded – undo
7 7
 
8 8
 class PushNotificationDevice extends JsonResource
9 9
 {
10
-    /**
11
-     * Transform the resource into an array.
12
-     *
13
-     * @param Request $request
14
-     * @return array
15
-     */
16
-    public function toArray($request)
17
-    {
18
-        return [
19
-            'id' => $this->id,
20
-            'device_token' => $this->device_token,
21
-            'access_token' => $this->access_token,
22
-            'user' => new UserResource($this->whenLoaded('user')),
23
-            'created_at' => $this->created_at,
24
-            'updated_at' => $this->updated_at,
25
-        ];
26
-    }
10
+	/**
11
+	 * Transform the resource into an array.
12
+	 *
13
+	 * @param Request $request
14
+	 * @return array
15
+	 */
16
+	public function toArray($request)
17
+	{
18
+		return [
19
+			'id' => $this->id,
20
+			'device_token' => $this->device_token,
21
+			'access_token' => $this->access_token,
22
+			'user' => new UserResource($this->whenLoaded('user')),
23
+			'created_at' => $this->created_at,
24
+			'updated_at' => $this->updated_at,
25
+		];
26
+	}
27 27
 }
Please login to merge, or discard this patch.
Modules/Notifications/Http/Controllers/PushNotificationDeviceController.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -11,55 +11,55 @@
 block discarded – undo
11 11
 
12 12
 class PushNotificationDeviceController extends BaseApiController
13 13
 {
14
-    /**
15
-     * List of all route actions that the base api controller
16
-     * will skip permissions check for them.
17
-     * @var array
18
-     */
19
-    protected $skipPermissionCheck = ['registerDevice'];
14
+	/**
15
+	 * List of all route actions that the base api controller
16
+	 * will skip permissions check for them.
17
+	 * @var array
18
+	 */
19
+	protected $skipPermissionCheck = ['registerDevice'];
20 20
 
21
-    /**
22
-     * Init new object.
23
-     *
24
-     * @param   PushNotificationDeviceRepository $repo
25
-     * @param   CoreConfig                       $config
26
-     * @return  void
27
-     */
28
-    public function __construct(PushNotificationDeviceRepository $repo, CoreConfig $config)
29
-    {
30
-        parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\PushNotificationDevice');
31
-    }
21
+	/**
22
+	 * Init new object.
23
+	 *
24
+	 * @param   PushNotificationDeviceRepository $repo
25
+	 * @param   CoreConfig                       $config
26
+	 * @return  void
27
+	 */
28
+	public function __construct(PushNotificationDeviceRepository $repo, CoreConfig $config)
29
+	{
30
+		parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\PushNotificationDevice');
31
+	}
32 32
 
33
-    /**
34
-     * Insert the given model to storage.
35
-     *
36
-     * @param InsertPushNotificationDevice $request
37
-     * @return \Illuminate\Http\Response
38
-     */
39
-    public function insert(InsertPushNotificationDevice $request)
40
-    {
41
-        return new $this->modelResource($this->repo->save($request->all()));
42
-    }
33
+	/**
34
+	 * Insert the given model to storage.
35
+	 *
36
+	 * @param InsertPushNotificationDevice $request
37
+	 * @return \Illuminate\Http\Response
38
+	 */
39
+	public function insert(InsertPushNotificationDevice $request)
40
+	{
41
+		return new $this->modelResource($this->repo->save($request->all()));
42
+	}
43 43
 
44
-    /**
45
-     * Update the given model to storage.
46
-     *
47
-     * @param UpdatePushNotificationDevice $request
48
-     * @return \Illuminate\Http\Response
49
-     */
50
-    public function update(UpdatePushNotificationDevice $request)
51
-    {
52
-        return new $this->modelResource($this->repo->save($request->all()));
53
-    }
44
+	/**
45
+	 * Update the given model to storage.
46
+	 *
47
+	 * @param UpdatePushNotificationDevice $request
48
+	 * @return \Illuminate\Http\Response
49
+	 */
50
+	public function update(UpdatePushNotificationDevice $request)
51
+	{
52
+		return new $this->modelResource($this->repo->save($request->all()));
53
+	}
54 54
 
55
-    /**
56
-     * Register the given device to the logged in user.
57
-     *
58
-     * @param RegisterDevice $request
59
-     * @return \Illuminate\Http\Response
60
-     */
61
-    public function registerDevice(RegisterDevice $request)
62
-    {
63
-        return new $this->modelResource($this->repo->registerDevice($request->all()));
64
-    }
55
+	/**
56
+	 * Register the given device to the logged in user.
57
+	 *
58
+	 * @param RegisterDevice $request
59
+	 * @return \Illuminate\Http\Response
60
+	 */
61
+	public function registerDevice(RegisterDevice $request)
62
+	{
63
+		return new $this->modelResource($this->repo->registerDevice($request->all()));
64
+	}
65 65
 }
Please login to merge, or discard this patch.
src/Modules/Notifications/Http/Controllers/NotificationController.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -10,65 +10,65 @@
 block discarded – undo
10 10
 
11 11
 class NotificationController extends BaseApiController
12 12
 {
13
-    /**
14
-     * List of all route actions that the base api controller
15
-     * will skip permissions check for them.
16
-     * @var array
17
-     */
18
-    protected $skipPermissionCheck = ['markAsRead', 'markAllAsRead', 'index', 'unread'];
13
+	/**
14
+	 * List of all route actions that the base api controller
15
+	 * will skip permissions check for them.
16
+	 * @var array
17
+	 */
18
+	protected $skipPermissionCheck = ['markAsRead', 'markAllAsRead', 'index', 'unread'];
19 19
 
20
-    /**
21
-     * Init new object.
22
-     *
23
-     * @param   NotificationRepository $repo
24
-     * @param   CoreConfig             $config
25
-     * @return  void
26
-     */
27
-    public function __construct(NotificationRepository $repo, CoreConfig $config)
28
-    {
29
-        parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\Notification');
30
-    }
20
+	/**
21
+	 * Init new object.
22
+	 *
23
+	 * @param   NotificationRepository $repo
24
+	 * @param   CoreConfig             $config
25
+	 * @return  void
26
+	 */
27
+	public function __construct(NotificationRepository $repo, CoreConfig $config)
28
+	{
29
+		parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\Notification');
30
+	}
31 31
 
32
-    /**
33
-     * Retrieve all notifications of the logged in user.
34
-     *
35
-     * @param Request $request
36
-     * @return \Illuminate\Http\Response
37
-     */
38
-    public function index(Request $request)
39
-    {
40
-        return $this->modelResource::collection($this->repo->all($request->query('perPage')));
41
-    }
32
+	/**
33
+	 * Retrieve all notifications of the logged in user.
34
+	 *
35
+	 * @param Request $request
36
+	 * @return \Illuminate\Http\Response
37
+	 */
38
+	public function index(Request $request)
39
+	{
40
+		return $this->modelResource::collection($this->repo->all($request->query('perPage')));
41
+	}
42 42
 
43
-    /**
44
-     * Retrieve unread notifications of the logged in user.
45
-     *
46
-     * @param Request $request
47
-     * @return \Illuminate\Http\Response
48
-     */
49
-    public function unread(Request $request)
50
-    {
51
-        return $this->modelResource::collection($this->repo->unread($request->query('perPage')));
52
-    }
43
+	/**
44
+	 * Retrieve unread notifications of the logged in user.
45
+	 *
46
+	 * @param Request $request
47
+	 * @return \Illuminate\Http\Response
48
+	 */
49
+	public function unread(Request $request)
50
+	{
51
+		return $this->modelResource::collection($this->repo->unread($request->query('perPage')));
52
+	}
53 53
 
54
-    /**
55
-     * Mark the notification as read.
56
-     *
57
-     * @param  integer  $id Id of the notification.
58
-     * @return \Illuminate\Http\Response
59
-     */
60
-    public function markAsRead($id)
61
-    {
62
-        return new GeneralResource($this->repo->markAsRead($id));
63
-    }
54
+	/**
55
+	 * Mark the notification as read.
56
+	 *
57
+	 * @param  integer  $id Id of the notification.
58
+	 * @return \Illuminate\Http\Response
59
+	 */
60
+	public function markAsRead($id)
61
+	{
62
+		return new GeneralResource($this->repo->markAsRead($id));
63
+	}
64 64
 
65
-    /**
66
-     * Mark all notifications as read.
67
-     *
68
-     * @return \Illuminate\Http\Response
69
-     */
70
-    public function markAllAsRead()
71
-    {
72
-        return new GeneralResource($this->repo->markAllAsRead());
73
-    }
65
+	/**
66
+	 * Mark all notifications as read.
67
+	 *
68
+	 * @return \Illuminate\Http\Response
69
+	 */
70
+	public function markAllAsRead()
71
+	{
72
+		return new GeneralResource($this->repo->markAllAsRead());
73
+	}
74 74
 }
Please login to merge, or discard this patch.
Modules/Notifications/Http/Requests/InsertPushNotificationDevice copy.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 InsertPushNotificationDevice 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
-            'device_token' => 'required|string|max:255',
28
-            'user_id'      => 'required|exists:users,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
+			'device_token' => 'required|string|max:255',
28
+			'user_id'      => 'required|exists:users,id'
29
+		];
30
+	}
31 31
 }
Please login to merge, or discard this patch.
src/Modules/Notifications/Http/Requests/UpdatePushNotificationDevice.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 UpdatePushNotificationDevice 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
-            'id'           => 'required|exists:push_notification_devices,id',
28
-            'device_token' => 'required|string|max:255',
29
-            'user_id'      => 'required|exists:users,id'
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
+			'id'           => 'required|exists:push_notification_devices,id',
28
+			'device_token' => 'required|string|max:255',
29
+			'user_id'      => 'required|exists:users,id'
30
+		];
31
+	}
32 32
 }
Please login to merge, or discard this patch.
src/Modules/Notifications/Http/Requests/RegisterDevice.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,25 +6,25 @@
 block discarded – undo
6 6
 
7 7
 class RegisterDevice 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
-            'device_token' => 'required|string|max:255'
28
-        ];
29
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'device_token' => 'required|string|max:255'
28
+		];
29
+	}
30 30
 }
Please login to merge, or discard this patch.
src/Modules/Notifications/Routes/api.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -13,23 +13,23 @@
 block discarded – undo
13 13
 
14 14
 Route::group(['prefix' => 'notifications'], function () {
15 15
 
16
-    Route::group(['prefix' => 'notifications'], function () {
16
+	Route::group(['prefix' => 'notifications'], function () {
17 17
 
18
-        Route::get('/', 'NotificationController@index');
19
-        Route::get('unread', 'NotificationController@unread');
20
-        Route::get('read/{id}', 'NotificationController@markAsRead');
21
-        Route::get('read/all', 'NotificationController@markAllAsRead');
22
-    });
18
+		Route::get('/', 'NotificationController@index');
19
+		Route::get('unread', 'NotificationController@unread');
20
+		Route::get('read/{id}', 'NotificationController@markAsRead');
21
+		Route::get('read/all', 'NotificationController@markAllAsRead');
22
+	});
23 23
 
24
-    Route::group(['prefix' => 'push_notification_devices'], function () {
24
+	Route::group(['prefix' => 'push_notification_devices'], function () {
25 25
         
26
-        Route::get('/', 'PushNotificationDeviceController@index');
27
-        Route::get('/{id}', 'PushNotificationDeviceController@find');
28
-        Route::post('/', 'PushNotificationDeviceController@insert');
29
-        Route::put('/', 'PushNotificationDeviceController@update');
30
-        Route::delete('/{id}', 'PushNotificationDeviceController@delete');
31
-        Route::get('list/deleted', 'PushNotificationDeviceController@deleted');
32
-        Route::patch('restore/{id}', 'PushNotificationDeviceController@restore');
33
-        Route::post('register/device', 'PushNotificationDeviceController@registerDevice');
34
-    });
26
+		Route::get('/', 'PushNotificationDeviceController@index');
27
+		Route::get('/{id}', 'PushNotificationDeviceController@find');
28
+		Route::post('/', 'PushNotificationDeviceController@insert');
29
+		Route::put('/', 'PushNotificationDeviceController@update');
30
+		Route::delete('/{id}', 'PushNotificationDeviceController@delete');
31
+		Route::get('list/deleted', 'PushNotificationDeviceController@deleted');
32
+		Route::patch('restore/{id}', 'PushNotificationDeviceController@restore');
33
+		Route::post('register/device', 'PushNotificationDeviceController@registerDevice');
34
+	});
35 35
 });
Please login to merge, or discard this patch.