Completed
Push — master ( 503ff2...5d1103 )
by Sherif
03:04
created
src/Modules/V1/Notifications/PushNotificationDevice.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -5,36 +5,36 @@
 block discarded – undo
5 5
 
6 6
 class Notification extends Model{
7 7
 
8
-    use SoftDeletes;
9
-    protected $table    = 'push_notifications_devices';
10
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
-    protected $hidden   = ['deleted_at'];
12
-    protected $guarded  = ['id'];
13
-    protected $fillable = ['device_token', 'device_type', 'user_id', 'active'];
8
+	use SoftDeletes;
9
+	protected $table    = 'push_notifications_devices';
10
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
+	protected $hidden   = ['deleted_at'];
12
+	protected $guarded  = ['id'];
13
+	protected $fillable = ['device_token', 'device_type', 'user_id', 'active'];
14 14
 
15
-    public function getCreatedAtAttribute($value)
16
-    {
17
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
18
-    }
15
+	public function getCreatedAtAttribute($value)
16
+	{
17
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
18
+	}
19 19
 
20
-    public function getUpdatedAtAttribute($value)
21
-    {
22
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
23
-    }
20
+	public function getUpdatedAtAttribute($value)
21
+	{
22
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
23
+	}
24 24
 
25
-    public function getDeletedAtAttribute($value)
26
-    {
27
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
28
-    }
25
+	public function getDeletedAtAttribute($value)
26
+	{
27
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
28
+	}
29 29
     
30
-    public function user()
31
-    {
32
-        return $this->belongsTo('App\Modules\V1\Acl\AclUser');
33
-    }
30
+	public function user()
31
+	{
32
+		return $this->belongsTo('App\Modules\V1\Acl\AclUser');
33
+	}
34 34
 
35
-    public static function boot()
36
-    {
37
-        parent::boot();
38
-        parent::observe(\App::make('App\Modules\V1\Notifications\ModelObservers\PushNotificationDeviceObserver'));
39
-    }
35
+	public static function boot()
36
+	{
37
+		parent::boot();
38
+		parent::observe(\App::make('App\Modules\V1\Notifications\ModelObservers\PushNotificationDeviceObserver'));
39
+	}
40 40
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 use Illuminate\Database\Eloquent\Model;
4 4
 use Illuminate\Database\Eloquent\SoftDeletes;
5 5
 
6
-class Notification extends Model{
6
+class Notification extends Model {
7 7
 
8 8
     use SoftDeletes;
9 9
     protected $table    = 'notifications';
Please login to merge, or discard this patch.
Modules/V1/Notifications/Repositories/PushNotificationDeviceRepository.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -14,21 +14,21 @@  discard block
 block discarded – undo
14 14
   return 'App\Modules\V1\Notifications\PushNotificationDevice';
15 15
  }
16 16
 
17
-    /**
18
-     * Set the notification notified to all.
19
-     *
20
-     * @param  array  $users_ids
21
-     * @param  string $messageText
22
-     * @return void
23
-     */
24
-    public function broadcast($users_ids, $messageText)
25
-    {
17
+	/**
18
+	 * Set the notification notified to all.
19
+	 *
20
+	 * @param  array  $users_ids
21
+	 * @param  string $messageText
22
+	 * @return void
23
+	 */
24
+	public function broadcast($users_ids, $messageText)
25
+	{
26 26
 		$devicesArray = [];
27 27
 		$devices      = \Core::notifications()->model->whereIn('user_id', $users_ids);
28
-    	foreach ($devices as $device) 
29
-    	{
30
-    		$devicesArray[$device->deivce_type] = \PushNotification::Device($device->device_token, array('badge' => 5));
31
-    	}
28
+		foreach ($devices as $device) 
29
+		{
30
+			$devicesArray[$device->deivce_type] = \PushNotification::Device($device->device_token, array('badge' => 5));
31
+		}
32 32
     	
33 33
 		$androidDevices = \PushNotification::DeviceCollection($devicesArray['ios']);
34 34
 		$iosDevices     = \PushNotification::DeviceCollection($devicesArray['android']);
@@ -36,36 +36,36 @@  discard block
 block discarded – undo
36 36
 
37 37
 		$this->push('android', $androidDevices, $message);
38 38
 		$this->push('ios', $iosDevices, $message);
39
-    }
39
+	}
40 40
 
41 41
 
42 42
  	/**
43
-     * Set the notification notified to true.
44
-     *
45
-     * @param  string    $type
46
-     * @param  colletion $devices
47
-     * @param  string    $message
48
-     * @return object
49
-     */
50
-    public function push($type, $devices, $message)
51
-    {
43
+ 	 * Set the notification notified to true.
44
+ 	 *
45
+ 	 * @param  string    $type
46
+ 	 * @param  colletion $devices
47
+ 	 * @param  string    $message
48
+ 	 * @return object
49
+ 	 */
50
+	public function push($type, $devices, $message)
51
+	{
52 52
 		$collection = \PushNotification::app($type)->to($devices)->send($message);
53
-    	foreach ($collection->pushManager as $push) 
54
-    	{
55
-    		$response[] = $push->getAdapter()->getResponse();
56
-    	}
57
-    	dd($response);
58
-    }
53
+		foreach ($collection->pushManager as $push) 
54
+		{
55
+			$response[] = $push->getAdapter()->getResponse();
56
+		}
57
+		dd($response);
58
+	}
59 59
 
60
-    /**
61
-     * Construct the notification message.
62
-     *
63
-     * @param  string $messageText
64
-     * @param  array  $options
65
-     * @return object
66
-     */
67
-    protected function constructMessage($messageText, $options = [])
68
-    {
69
-    	$message = \PushNotification::Message($messageText, $options);
70
-    }
60
+	/**
61
+	 * Construct the notification message.
62
+	 *
63
+	 * @param  string $messageText
64
+	 * @param  array  $options
65
+	 * @return object
66
+	 */
67
+	protected function constructMessage($messageText, $options = [])
68
+	{
69
+		$message = \PushNotification::Message($messageText, $options);
70
+	}
71 71
 }
Please login to merge, or discard this patch.
V1/Notifications/Http/Controllers/PushNotificationsDevicesController.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -8,21 +8,21 @@
 block discarded – undo
8 8
 class PushNotificationsDevicesController extends BaseApiController
9 9
 {
10 10
 	/**
11
-     * The name of the model that is used by the base api controller 
12
-     * to preform actions like (add, edit ... etc).
13
-     * @var string
14
-     */
15
-    protected $model            = 'notifications';
11
+	 * The name of the model that is used by the base api controller 
12
+	 * to preform actions like (add, edit ... etc).
13
+	 * @var string
14
+	 */
15
+	protected $model            = 'notifications';
16 16
 
17
-    /**
18
-     * The validations rules used by the base api controller
19
-     * to check before add.
20
-     * @var array
21
-     */
22
-    protected $validationRules  = [
23
-    'device_token'   => 'required|string|max:100',
24
-    'device_type' => 'required|in:androind,ios',
25
-    'user_id'     => 'required|exists:users,id',
26
-    'active'      => 'boolean'
27
-    ];
17
+	/**
18
+	 * The validations rules used by the base api controller
19
+	 * to check before add.
20
+	 * @var array
21
+	 */
22
+	protected $validationRules  = [
23
+	'device_token'   => 'required|string|max:100',
24
+	'device_type' => 'required|in:androind,ios',
25
+	'user_id'     => 'required|exists:users,id',
26
+	'active'      => 'boolean'
27
+	];
28 28
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@
 block discarded – undo
12 12
      * to preform actions like (add, edit ... etc).
13 13
      * @var string
14 14
      */
15
-    protected $model            = 'notifications';
15
+    protected $model = 'notifications';
16 16
 
17 17
     /**
18 18
      * The validations rules used by the base api controller
19 19
      * to check before add.
20 20
      * @var array
21 21
      */
22
-    protected $validationRules  = [
22
+    protected $validationRules = [
23 23
     'device_token'   => 'required|string|max:100',
24 24
     'device_type' => 'required|in:androind,ios',
25 25
     'user_id'     => 'required|exists:users,id',
Please login to merge, or discard this patch.
Modules/V1/Notifications/ModelObservers/PushNotificationDeviceObserver.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -5,44 +5,44 @@
 block discarded – undo
5 5
  */
6 6
 class LogObserver {
7 7
 
8
-    public function saving($model)
9
-    {
10
-        //
11
-    }
12
-
13
-    public function saved($model)
14
-    {
15
-        //
16
-    }
17
-
18
-    public function creating($model)
19
-    {
20
-        //
21
-    }
22
-
23
-    public function created($model)
24
-    {
25
-        //
26
-    }
27
-
28
-    public function updating($model)
29
-    {
30
-        //
31
-    }
32
-
33
-    public function updated($model)
34
-    {
35
-        //
36
-    }
37
-
38
-    public function deleting($model)
39
-    {
40
-        //
41
-    }
42
-
43
-    public function deleted($model)
44
-    {
45
-        //
46
-    }
8
+	public function saving($model)
9
+	{
10
+		//
11
+	}
12
+
13
+	public function saved($model)
14
+	{
15
+		//
16
+	}
17
+
18
+	public function creating($model)
19
+	{
20
+		//
21
+	}
22
+
23
+	public function created($model)
24
+	{
25
+		//
26
+	}
27
+
28
+	public function updating($model)
29
+	{
30
+		//
31
+	}
32
+
33
+	public function updated($model)
34
+	{
35
+		//
36
+	}
37
+
38
+	public function deleting($model)
39
+	{
40
+		//
41
+	}
42
+
43
+	public function deleted($model)
44
+	{
45
+		//
46
+	}
47 47
 
48 48
 }
49 49
\ No newline at end of file
Please login to merge, or discard this patch.
Database/Migrations/2016_01_24_111942_push_notifications_devices.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 			$table->string('view_name',100);
19 19
 			$table->softDeletes();
20 20
 			$table->timestamps();
21
-        });
21
+		});
22 22
 	}
23 23
 
24 24
 	/**
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@
 block discarded – undo
12 12
 	 */
13 13
 	public function up()
14 14
 	{
15
-		Schema::create('push_notifications_devices', function (Blueprint $table) {
15
+		Schema::create('push_notifications_devices', function(Blueprint $table) {
16 16
 			$table->increments('id');
17
-			$table->string('device_token',100);
17
+			$table->string('device_token', 100);
18 18
 			$table->enum('device_type', ['android', 'ios']);
19 19
 			$table->integer('user_id');
20 20
 			$table->boolean('active')->default(1);
Please login to merge, or discard this patch.
Database/Migrations/2016_01_24_123631_initialize_notifications.php 1 patch
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -12,134 +12,134 @@
 block discarded – undo
12 12
 	 */
13 13
 	public function up()
14 14
 	{
15
-        /**
16
-         * Delete previous permissions.
17
-         */
15
+		/**
16
+		 * Delete previous permissions.
17
+		 */
18 18
 		DB::table('permissions')->whereIn('model', ['notifications'])->delete();
19 19
 
20 20
 		/**
21
-         * Insert the permissions related to this module.
22
-         */
23
-        DB::table('permissions')->insert(
24
-        	[
25
-        		/**
26
-        		 * notifications model permissions.
27
-        		 */
28
-	        	[
29
-	        	'name'       => 'find',
30
-	        	'model'      => 'notifications',
31
-	        	'created_at' => \DB::raw('NOW()'),
32
-	        	'updated_at' => \DB::raw('NOW()')
33
-	        	],
34
-	        	[
35
-	        	'name'       => 'search',
36
-	        	'model'      => 'notifications',
37
-	        	'created_at' => \DB::raw('NOW()'),
38
-	        	'updated_at' => \DB::raw('NOW()')
39
-	        	],
40
-	        	[
41
-	        	'name'       => 'list',
42
-	        	'model'      => 'notifications',
43
-	        	'created_at' => \DB::raw('NOW()'),
44
-	        	'updated_at' => \DB::raw('NOW()')
45
-	        	],
46
-	        	[
47
-	        	'name'       => 'findby',
48
-	        	'model'      => 'notifications',
49
-	        	'created_at' => \DB::raw('NOW()'),
50
-	        	'updated_at' => \DB::raw('NOW()')
51
-	        	],
52
-	        	[
53
-	        	'name'       => 'first',
54
-	        	'model'      => 'notifications',
55
-	        	'created_at' => \DB::raw('NOW()'),
56
-	        	'updated_at' => \DB::raw('NOW()')
57
-	        	],
58
-	        	[
59
-	        	'name'       => 'paginate',
60
-	        	'model'      => 'notifications',
61
-	        	'created_at' => \DB::raw('NOW()'),
62
-	        	'updated_at' => \DB::raw('NOW()')
63
-	        	],
64
-	        	[
65
-	        	'name'       => 'paginateby',
66
-	        	'model'      => 'notifications',
67
-	        	'created_at' => \DB::raw('NOW()'),
68
-	        	'updated_at' => \DB::raw('NOW()')
69
-	        	],
70
-	        	[
71
-	        	'name'       => 'notified',
72
-	        	'model'      => 'notifications',
73
-	        	'created_at' => \DB::raw('NOW()'),
74
-	        	'updated_at' => \DB::raw('NOW()')
75
-	        	],
76
-	        	[
77
-	        	'name'       => 'notifyall',
78
-	        	'model'      => 'notifications',
79
-	        	'created_at' => \DB::raw('NOW()'),
80
-	        	'updated_at' => \DB::raw('NOW()')
81
-	        	],
82
-	        	/**
83
-        		 * pushNotificationsDevices model permissions.
84
-        		 */
85
-	        	[
86
-	        	'name'       => 'find',
87
-	        	'model'      => 'pushNotificationsDevices',
88
-	        	'created_at' => \DB::raw('NOW()'),
89
-	        	'updated_at' => \DB::raw('NOW()')
90
-	        	],
91
-	        	[
92
-	        	'name'       => 'search',
93
-	        	'model'      => 'pushNotificationsDevices',
94
-	        	'created_at' => \DB::raw('NOW()'),
95
-	        	'updated_at' => \DB::raw('NOW()')
96
-	        	],
97
-	        	[
98
-	        	'name'       => 'list',
99
-	        	'model'      => 'pushNotificationsDevices',
100
-	        	'created_at' => \DB::raw('NOW()'),
101
-	        	'updated_at' => \DB::raw('NOW()')
102
-	        	],
103
-	        	[
104
-	        	'name'       => 'findby',
105
-	        	'model'      => 'pushNotificationsDevices',
106
-	        	'created_at' => \DB::raw('NOW()'),
107
-	        	'updated_at' => \DB::raw('NOW()')
108
-	        	],
109
-	        	[
110
-	        	'name'       => 'first',
111
-	        	'model'      => 'pushNotificationsDevices',
112
-	        	'created_at' => \DB::raw('NOW()'),
113
-	        	'updated_at' => \DB::raw('NOW()')
114
-	        	],
115
-	        	[
116
-	        	'name'       => 'paginate',
117
-	        	'model'      => 'pushNotificationsDevices',
118
-	        	'created_at' => \DB::raw('NOW()'),
119
-	        	'updated_at' => \DB::raw('NOW()')
120
-	        	],
121
-	        	[
122
-	        	'name'       => 'paginateby',
123
-	        	'model'      => 'pushNotificationsDevices',
124
-	        	'created_at' => \DB::raw('NOW()'),
125
-	        	'updated_at' => \DB::raw('NOW()')
126
-	        	],
127
-	        	[
128
-	        	'name'       => 'save',
129
-	        	'model'      => 'pushNotificationsDevices',
130
-	        	'created_at' => \DB::raw('NOW()'),
131
-	        	'updated_at' => \DB::raw('NOW()')
132
-	        	],
133
-	        	[
134
-	        	'name'       => 'delete',
135
-	        	'model'      => 'pushNotificationsDevices',
136
-	        	'created_at' => \DB::raw('NOW()'),
137
-	        	'updated_at' => \DB::raw('NOW()')
138
-	        	],
139
-        	]
140
-        );
21
+		 * Insert the permissions related to this module.
22
+		 */
23
+		DB::table('permissions')->insert(
24
+			[
25
+				/**
26
+				 * notifications model permissions.
27
+				 */
28
+				[
29
+				'name'       => 'find',
30
+				'model'      => 'notifications',
31
+				'created_at' => \DB::raw('NOW()'),
32
+				'updated_at' => \DB::raw('NOW()')
33
+				],
34
+				[
35
+				'name'       => 'search',
36
+				'model'      => 'notifications',
37
+				'created_at' => \DB::raw('NOW()'),
38
+				'updated_at' => \DB::raw('NOW()')
39
+				],
40
+				[
41
+				'name'       => 'list',
42
+				'model'      => 'notifications',
43
+				'created_at' => \DB::raw('NOW()'),
44
+				'updated_at' => \DB::raw('NOW()')
45
+				],
46
+				[
47
+				'name'       => 'findby',
48
+				'model'      => 'notifications',
49
+				'created_at' => \DB::raw('NOW()'),
50
+				'updated_at' => \DB::raw('NOW()')
51
+				],
52
+				[
53
+				'name'       => 'first',
54
+				'model'      => 'notifications',
55
+				'created_at' => \DB::raw('NOW()'),
56
+				'updated_at' => \DB::raw('NOW()')
57
+				],
58
+				[
59
+				'name'       => 'paginate',
60
+				'model'      => 'notifications',
61
+				'created_at' => \DB::raw('NOW()'),
62
+				'updated_at' => \DB::raw('NOW()')
63
+				],
64
+				[
65
+				'name'       => 'paginateby',
66
+				'model'      => 'notifications',
67
+				'created_at' => \DB::raw('NOW()'),
68
+				'updated_at' => \DB::raw('NOW()')
69
+				],
70
+				[
71
+				'name'       => 'notified',
72
+				'model'      => 'notifications',
73
+				'created_at' => \DB::raw('NOW()'),
74
+				'updated_at' => \DB::raw('NOW()')
75
+				],
76
+				[
77
+				'name'       => 'notifyall',
78
+				'model'      => 'notifications',
79
+				'created_at' => \DB::raw('NOW()'),
80
+				'updated_at' => \DB::raw('NOW()')
81
+				],
82
+				/**
83
+				 * pushNotificationsDevices model permissions.
84
+				 */
85
+				[
86
+				'name'       => 'find',
87
+				'model'      => 'pushNotificationsDevices',
88
+				'created_at' => \DB::raw('NOW()'),
89
+				'updated_at' => \DB::raw('NOW()')
90
+				],
91
+				[
92
+				'name'       => 'search',
93
+				'model'      => 'pushNotificationsDevices',
94
+				'created_at' => \DB::raw('NOW()'),
95
+				'updated_at' => \DB::raw('NOW()')
96
+				],
97
+				[
98
+				'name'       => 'list',
99
+				'model'      => 'pushNotificationsDevices',
100
+				'created_at' => \DB::raw('NOW()'),
101
+				'updated_at' => \DB::raw('NOW()')
102
+				],
103
+				[
104
+				'name'       => 'findby',
105
+				'model'      => 'pushNotificationsDevices',
106
+				'created_at' => \DB::raw('NOW()'),
107
+				'updated_at' => \DB::raw('NOW()')
108
+				],
109
+				[
110
+				'name'       => 'first',
111
+				'model'      => 'pushNotificationsDevices',
112
+				'created_at' => \DB::raw('NOW()'),
113
+				'updated_at' => \DB::raw('NOW()')
114
+				],
115
+				[
116
+				'name'       => 'paginate',
117
+				'model'      => 'pushNotificationsDevices',
118
+				'created_at' => \DB::raw('NOW()'),
119
+				'updated_at' => \DB::raw('NOW()')
120
+				],
121
+				[
122
+				'name'       => 'paginateby',
123
+				'model'      => 'pushNotificationsDevices',
124
+				'created_at' => \DB::raw('NOW()'),
125
+				'updated_at' => \DB::raw('NOW()')
126
+				],
127
+				[
128
+				'name'       => 'save',
129
+				'model'      => 'pushNotificationsDevices',
130
+				'created_at' => \DB::raw('NOW()'),
131
+				'updated_at' => \DB::raw('NOW()')
132
+				],
133
+				[
134
+				'name'       => 'delete',
135
+				'model'      => 'pushNotificationsDevices',
136
+				'created_at' => \DB::raw('NOW()'),
137
+				'updated_at' => \DB::raw('NOW()')
138
+				],
139
+			]
140
+		);
141 141
 
142
-        /**
142
+		/**
143 143
 		 * Assign the permissions to the admin group.
144 144
 		 */
145 145
 		$permissionIds = DB::table('permissions')->whereIn('model', ['notifications'])->select('id')->lists('id');
Please login to merge, or discard this patch.