Completed
Push — master ( ec2395...0dfd17 )
by Sherif
02:09
created
Database/Seeds/PushNotificationDevicesDatabaseSeeder.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 PushNotificationDevicesDatabaseSeeder extends Seeder
8 8
 {
9
-    /**
10
-     * Run the database seeds.
11
-     *
12
-     * @return void
13
-     */
14
-    public function run()
15
-    {
16
-        $this->call(ClearDataSeeder::class);
17
-        $this->call(PushNotificationDevicesTableSeeder::class);
18
-        $this->call(AssignRelationsSeeder::class);
19
-    }
9
+	/**
10
+	 * Run the database seeds.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function run()
15
+	{
16
+		$this->call(ClearDataSeeder::class);
17
+		$this->call(PushNotificationDevicesTableSeeder::class);
18
+		$this->call(AssignRelationsSeeder::class);
19
+	}
20 20
 }
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('groups_permissions')->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('groups_permissions')->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   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -5,31 +5,31 @@
 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->integer('user_id');
19
-            $table->text('access_token')->nullable();
20
-            $table->unique(array('device_token', 'user_id'));
21
-            $table->softDeletes();
22
-            $table->timestamps();
23
-        });
24
-    }
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->integer('user_id');
19
+			$table->text('access_token')->nullable();
20
+			$table->unique(array('device_token', 'user_id'));
21
+			$table->softDeletes();
22
+			$table->timestamps();
23
+		});
24
+	}
25 25
 
26
-    /**
27
-     * Reverse the migrations.
28
-     *
29
-     * @return void
30
-     */
31
-    public function down()
32
-    {
33
-        Schema::dropIfExists('push_notifications_devices');
34
-    }
26
+	/**
27
+	 * Reverse the migrations.
28
+	 *
29
+	 * @return void
30
+	 */
31
+	public function down()
32
+	{
33
+		Schema::dropIfExists('push_notifications_devices');
34
+	}
35 35
 }
Please login to merge, or discard this patch.
Modules/PushNotificationDevices/Http/Resources/PushNotificationDevice.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,25 +7,25 @@
 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
-        if (! $this->resource) {
19
-            return [];
20
-        }
10
+	/**
11
+	 * Transform the resource into an array.
12
+	 *
13
+	 * @param Request $request
14
+	 * @return array
15
+	 */
16
+	public function toArray($request)
17
+	{
18
+		if (! $this->resource) {
19
+			return [];
20
+		}
21 21
 
22
-        return [
23
-            'id' => $this->id,
24
-            'device_token' => $this->device_token,
25
-            'access_token' => $this->access_token,
26
-            'user' => new UserResource($this->whenLoaded('user')),
27
-            'created_at' => $this->created_at,
28
-            'updated_at' => $this->updated_at,
29
-        ];
30
-    }
22
+		return [
23
+			'id' => $this->id,
24
+			'device_token' => $this->device_token,
25
+			'access_token' => $this->access_token,
26
+			'user' => new UserResource($this->whenLoaded('user')),
27
+			'created_at' => $this->created_at,
28
+			'updated_at' => $this->updated_at,
29
+		];
30
+	}
31 31
 }
Please login to merge, or discard this patch.
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\PushNotificationDevices\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\PushNotificationDevices\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.
PushNotificationDevices/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.
PushNotificationDevices/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/PushNotificationDevices/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/PushNotificationDevices/PushNotificationDevice.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -6,48 +6,48 @@
 block discarded – undo
6 6
 class PushNotificationDevice extends Model
7 7
 {
8 8
 
9
-    use SoftDeletes;
10
-    protected $table    = 'push_notifications_devices';
11
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
12
-    protected $hidden   = ['deleted_at', 'access_token'];
13
-    protected $guarded  = ['id'];
14
-    protected $fillable = ['device_token', 'user_id', 'access_token'];
15
-    public $searchable  = ['device_token'];
16
-
17
-    public function getCreatedAtAttribute($value)
18
-    {
19
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
20
-    }
21
-
22
-    public function getUpdatedAtAttribute($value)
23
-    {
24
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
25
-    }
26
-
27
-    public function getDeletedAtAttribute($value)
28
-    {
29
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
30
-    }
9
+	use SoftDeletes;
10
+	protected $table    = 'push_notifications_devices';
11
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
12
+	protected $hidden   = ['deleted_at', 'access_token'];
13
+	protected $guarded  = ['id'];
14
+	protected $fillable = ['device_token', 'user_id', 'access_token'];
15
+	public $searchable  = ['device_token'];
16
+
17
+	public function getCreatedAtAttribute($value)
18
+	{
19
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
20
+	}
21
+
22
+	public function getUpdatedAtAttribute($value)
23
+	{
24
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
25
+	}
26
+
27
+	public function getDeletedAtAttribute($value)
28
+	{
29
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
30
+	}
31 31
     
32
-    public function user()
33
-    {
34
-        return $this->belongsTo('App\Modules\Users\AclUser');
35
-    }
36
-
37
-    /**
38
-     * Encrypt the access_token attribute before
39
-     * saving it in the storage.
40
-     *
41
-     * @param string $value
42
-     */
43
-    public function setLoginTokenAttribute($value)
44
-    {
45
-        $this->attributes['access_token'] = encrypt($value);
46
-    }
47
-
48
-    public static function boot()
49
-    {
50
-        parent::boot();
51
-        PushNotificationDevice::observe(\App::make('App\Modules\PushNotificationDevices\ModelObservers\PushNotificationDeviceObserver'));
52
-    }
32
+	public function user()
33
+	{
34
+		return $this->belongsTo('App\Modules\Users\AclUser');
35
+	}
36
+
37
+	/**
38
+	 * Encrypt the access_token attribute before
39
+	 * saving it in the storage.
40
+	 *
41
+	 * @param string $value
42
+	 */
43
+	public function setLoginTokenAttribute($value)
44
+	{
45
+		$this->attributes['access_token'] = encrypt($value);
46
+	}
47
+
48
+	public static function boot()
49
+	{
50
+		parent::boot();
51
+		PushNotificationDevice::observe(\App::make('App\Modules\PushNotificationDevices\ModelObservers\PushNotificationDeviceObserver'));
52
+	}
53 53
 }
Please login to merge, or discard this patch.