Completed
Push — master ( b819b4...8115f1 )
by Sherif
14:17
created
Database/Migrations/2016_01_24_111942_push_notification_devices.php 2 patches
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
-            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
+			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.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
      */
13 13
     public function up()
14 14
     {
15
-        Schema::create('push_notification_devices', function (Blueprint $table) {
15
+        Schema::create('push_notification_devices', function(Blueprint $table) {
16 16
             increments('id');
17 17
             $table->string('device_token');
18 18
             $table->unsignedInteger('user_id');
Please login to merge, or discard this patch.
src/Modules/PushNotificationDevices/Routes/api.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
15 15
 
16 16
 Route::group(['prefix' => 'push/notification/devices'], function () {
17 17
         
18
-    Route::get('/', 'PushNotificationDeviceController@index');
19
-    Route::get('{id}', 'PushNotificationDeviceController@show');
20
-    Route::post('/', 'PushNotificationDeviceController@store');
21
-    Route::patch('{id}', 'PushNotificationDeviceController@update');
22
-    Route::delete('{id}', 'PushNotificationDeviceController@destroy');
23
-    Route::patch('restore/{id}', 'PushNotificationDeviceController@restore');
24
-    Route::post('register/device', 'PushNotificationDeviceController@registerDevice');
18
+	Route::get('/', 'PushNotificationDeviceController@index');
19
+	Route::get('{id}', 'PushNotificationDeviceController@show');
20
+	Route::post('/', 'PushNotificationDeviceController@store');
21
+	Route::patch('{id}', 'PushNotificationDeviceController@update');
22
+	Route::delete('{id}', 'PushNotificationDeviceController@destroy');
23
+	Route::patch('restore/{id}', 'PushNotificationDeviceController@restore');
24
+	Route::post('register/device', 'PushNotificationDeviceController@registerDevice');
25 25
 });
Please login to merge, or discard this patch.
src/Modules/OauthClients/OauthClient.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,17 +8,17 @@
 block discarded – undo
8 8
 
9 9
 class OauthClient extends Client
10 10
 {
11
-    protected $dates = ['created_at', 'updated_at'];
12
-    public $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked'];
11
+	protected $dates = ['created_at', 'updated_at'];
12
+	public $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
 }
Please login to merge, or discard this patch.
Migrations/2016_06_01_000005_create_oauth_personal_access_clients_table.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -6,29 +6,29 @@
 block discarded – undo
6 6
 
7 7
 class CreateOauthPersonalAccessClientsTable extends Migration
8 8
 {
9
-    /**
10
-     * Run the migrations.
11
-     *
12
-     * @return void
13
-     */
14
-    public function up()
15
-    {
16
-        Schema::create('oauth_personal_access_clients', function (Blueprint $table) {
17
-            increments('id');
18
-            $table->unsignedInteger('client_id');
19
-            $table->timestamps();
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('oauth_personal_access_clients', function (Blueprint $table) {
17
+			increments('id');
18
+			$table->unsignedInteger('client_id');
19
+			$table->timestamps();
20 20
             
21
-            $table->foreign('client_id')->references('id')->on('oauth_clients');
22
-        });
23
-    }
21
+			$table->foreign('client_id')->references('id')->on('oauth_clients');
22
+		});
23
+	}
24 24
 
25
-    /**
26
-     * Reverse the migrations.
27
-     *
28
-     * @return void
29
-     */
30
-    public function down()
31
-    {
32
-        Schema::drop('oauth_personal_access_clients');
33
-    }
25
+	/**
26
+	 * Reverse the migrations.
27
+	 *
28
+	 * @return void
29
+	 */
30
+	public function down()
31
+	{
32
+		Schema::drop('oauth_personal_access_clients');
33
+	}
34 34
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('oauth_personal_access_clients', function (Blueprint $table) {
16
+        Schema::create('oauth_personal_access_clients', function(Blueprint $table) {
17 17
             increments('id');
18 18
             $table->unsignedInteger('client_id');
19 19
             $table->timestamps();
Please login to merge, or discard this patch.
Database/Migrations/2016_06_01_000001_create_oauth_clients_table.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -6,35 +6,35 @@
 block discarded – undo
6 6
 
7 7
 class CreateOauthClientsTable extends Migration
8 8
 {
9
-    /**
10
-     * Run the migrations.
11
-     *
12
-     * @return void
13
-     */
14
-    public function up()
15
-    {
16
-        Schema::create('oauth_clients', function (Blueprint $table) {
17
-            increments('id');
18
-            $table->unsignedInteger('user_id')->nullable();
19
-            $table->string('name');
20
-            $table->string('secret', 100);
21
-            $table->text('redirect');
22
-            $table->boolean('personal_access_client')->default(0);
23
-            $table->boolean('password_client')->default(0);
24
-            $table->boolean('revoked')->default(0);
25
-            $table->timestamps();
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('oauth_clients', function (Blueprint $table) {
17
+			increments('id');
18
+			$table->unsignedInteger('user_id')->nullable();
19
+			$table->string('name');
20
+			$table->string('secret', 100);
21
+			$table->text('redirect');
22
+			$table->boolean('personal_access_client')->default(0);
23
+			$table->boolean('password_client')->default(0);
24
+			$table->boolean('revoked')->default(0);
25
+			$table->timestamps();
26 26
 
27
-            $table->foreign('user_id')->references('id')->on('users');
28
-        });
29
-    }
27
+			$table->foreign('user_id')->references('id')->on('users');
28
+		});
29
+	}
30 30
 
31
-    /**
32
-     * Reverse the migrations.
33
-     *
34
-     * @return void
35
-     */
36
-    public function down()
37
-    {
38
-        Schema::drop('oauth_clients');
39
-    }
31
+	/**
32
+	 * Reverse the migrations.
33
+	 *
34
+	 * @return void
35
+	 */
36
+	public function down()
37
+	{
38
+		Schema::drop('oauth_clients');
39
+	}
40 40
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('oauth_clients', function (Blueprint $table) {
16
+        Schema::create('oauth_clients', function(Blueprint $table) {
17 17
             increments('id');
18 18
             $table->unsignedInteger('user_id')->nullable();
19 19
             $table->string('name');
Please login to merge, or discard this patch.
src/Modules/OauthClients/Routes/api.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@
 block discarded – undo
13 13
 
14 14
 Route::group(['prefix' => 'oauth/clients'], function () {
15 15
 
16
-    Route::get('/', 'OauthClientController@index');
17
-    Route::get('{id}', 'OauthClientController@show');
18
-    Route::post('/', 'OauthClientController@store');
19
-    Route::patch('{id}', 'OauthClientController@update');
20
-    Route::delete('{id}', 'OauthClientController@destroy');
21
-    Route::patch('revoke/{id}', 'OauthClientController@revoke');
22
-    Route::patch('unrevoke/{id}', 'OauthClientController@unRevoke');
16
+	Route::get('/', 'OauthClientController@index');
17
+	Route::get('{id}', 'OauthClientController@show');
18
+	Route::post('/', 'OauthClientController@store');
19
+	Route::patch('{id}', 'OauthClientController@update');
20
+	Route::delete('{id}', 'OauthClientController@destroy');
21
+	Route::patch('revoke/{id}', 'OauthClientController@revoke');
22
+	Route::patch('unrevoke/{id}', 'OauthClientController@unRevoke');
23 23
 });
Please login to merge, or discard this patch.
src/Modules/Core/Http/Middleware/SetSessions.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -8,40 +8,40 @@
 block discarded – undo
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('Accept-Language', 'en');
38
-        $locale = $locale == 'ar' || $locale == 'all' ? $locale : 'en';
39
-        $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('Accept-Language', 'en');
38
+		$locale = $locale == 'ar' || $locale == 'all' ? $locale : 'en';
39
+		$timeZone = $request->header('time-zone', 0);
40 40
 
41
-        $this->session->put('time-zone', $timeZone);
42
-        $this->session->put('locale', $locale);
43
-        $this->app->setLocale($locale);
41
+		$this->session->put('time-zone', $timeZone);
42
+		$this->session->put('locale', $locale);
43
+		$this->app->setLocale($locale);
44 44
 
45
-        return $next($request);
46
-    }
45
+		return $next($request);
46
+	}
47 47
 }
Please login to merge, or discard this patch.
src/Modules/Core/Http/Middleware/SetRelations.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -8,39 +8,39 @@
 block discarded – undo
8 8
 
9 9
 class SetRelations
10 10
 {
11
-    protected $arr;
12
-    protected $route;
11
+	protected $arr;
12
+	protected $route;
13 13
     
14
-    /**
15
-     * Init new object.
16
-     *
17
-     * @param   Route  $route
18
-     * @param   Arr    $arr
19
-     *
20
-     * @return  void
21
-     */
22
-    public function __construct(Route $route, Arr $arr)
23
-    {
24
-        $this->arr = $arr;
25
-        $this->route = $route;
26
-    }
14
+	/**
15
+	 * Init new object.
16
+	 *
17
+	 * @param   Route  $route
18
+	 * @param   Arr    $arr
19
+	 *
20
+	 * @return  void
21
+	 */
22
+	public function __construct(Route $route, Arr $arr)
23
+	{
24
+		$this->arr = $arr;
25
+		$this->route = $route;
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
-        $routeActions       = explode('@', $this->route->currentRouteAction());
38
-        $modelName          = explode('\\', $routeActions[0]);
39
-        $modelName          = lcfirst(str_replace('Controller', '', end($modelName)));
40
-        $route              = explode('@', $this->route->currentRouteAction())[1];
41
-        $relations          = $this->arr->get(config('core.relations'), $modelName, false);
42
-        $request->relations = $relations && isset($relations[$route]) ? $relations[$route] : [];
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
+		$routeActions       = explode('@', $this->route->currentRouteAction());
38
+		$modelName          = explode('\\', $routeActions[0]);
39
+		$modelName          = lcfirst(str_replace('Controller', '', end($modelName)));
40
+		$route              = explode('@', $this->route->currentRouteAction())[1];
41
+		$relations          = $this->arr->get(config('core.relations'), $modelName, false);
42
+		$request->relations = $relations && isset($relations[$route]) ? $relations[$route] : [];
43 43
 
44
-        return $next($request);
45
-    }
44
+		return $next($request);
45
+	}
46 46
 }
Please login to merge, or discard this patch.
src/Modules/Core/Http/Middleware/CheckPermissions.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -11,68 +11,68 @@
 block discarded – undo
11 11
 
12 12
 class CheckPermissions
13 13
 {
14
-    protected $route;
15
-    protected $auth;
16
-    protected $authMiddleware;
17
-    protected $userService;
18
-    protected $arr;
14
+	protected $route;
15
+	protected $auth;
16
+	protected $authMiddleware;
17
+	protected $userService;
18
+	protected $arr;
19 19
     
20
-    /**
21
-     * Init new object.
22
-     *
23
-     * @param   Route          $route
24
-     * @param   Auth           $auth
25
-     * @param   AuthMiddleware $authMiddleware
26
-     * @param   UserService    $userService
27
-     * @param   Arr            $arr
28
-     *
29
-     * @return  void
30
-     */
31
-    public function __construct(Route $route, Auth $auth, AuthMiddleware $authMiddleware, UserService $userService, Arr $arr)
32
-    {
33
-        $this->route = $route;
34
-        $this->auth = $auth;
35
-        $this->authMiddleware = $authMiddleware;
36
-        $this->userService = $userService;
37
-        $this->arr = $arr;
38
-    }
20
+	/**
21
+	 * Init new object.
22
+	 *
23
+	 * @param   Route          $route
24
+	 * @param   Auth           $auth
25
+	 * @param   AuthMiddleware $authMiddleware
26
+	 * @param   UserService    $userService
27
+	 * @param   Arr            $arr
28
+	 *
29
+	 * @return  void
30
+	 */
31
+	public function __construct(Route $route, Auth $auth, AuthMiddleware $authMiddleware, UserService $userService, Arr $arr)
32
+	{
33
+		$this->route = $route;
34
+		$this->auth = $auth;
35
+		$this->authMiddleware = $authMiddleware;
36
+		$this->userService = $userService;
37
+		$this->arr = $arr;
38
+	}
39 39
 
40
-    /**
41
-     * Handle an incoming request.
42
-     *
43
-     * @param  \Illuminate\Http\Request  $request
44
-     * @param  \Closure  $next
45
-     * @return mixed
46
-     */
47
-    public function handle($request, Closure $next)
48
-    {
49
-        $routeActions        = explode('@', $this->route->currentRouteAction());
50
-        $reflectionClass     = new \ReflectionClass($routeActions[0]);
51
-        $classProperties     = $reflectionClass->getDefaultProperties();
52
-        $skipPermissionCheck = $this->arr->get($classProperties, 'skipPermissionCheck', []);
53
-        $skipLoginCheck      = $this->arr->get($classProperties, 'skipLoginCheck', []);
54
-        $modelName           = explode('\\', $routeActions[0]);
55
-        $modelName           = lcfirst(str_replace('Controller', '', end($modelName)));
56
-        $permission          = $routeActions[1];
40
+	/**
41
+	 * Handle an incoming request.
42
+	 *
43
+	 * @param  \Illuminate\Http\Request  $request
44
+	 * @param  \Closure  $next
45
+	 * @return mixed
46
+	 */
47
+	public function handle($request, Closure $next)
48
+	{
49
+		$routeActions        = explode('@', $this->route->currentRouteAction());
50
+		$reflectionClass     = new \ReflectionClass($routeActions[0]);
51
+		$classProperties     = $reflectionClass->getDefaultProperties();
52
+		$skipPermissionCheck = $this->arr->get($classProperties, 'skipPermissionCheck', []);
53
+		$skipLoginCheck      = $this->arr->get($classProperties, 'skipLoginCheck', []);
54
+		$modelName           = explode('\\', $routeActions[0]);
55
+		$modelName           = lcfirst(str_replace('Controller', '', end($modelName)));
56
+		$permission          = $routeActions[1];
57 57
 
58
-        $this->auth->shouldUse('api');
59
-        if (! in_array($permission, $skipLoginCheck)) {
60
-            $this->authMiddleware->handle($request, function ($request) use ($modelName, $skipPermissionCheck, $permission) {
61
-                $user             = $this->auth->user();
62
-                $isPasswordClient = $user->token()->client->password_client;
58
+		$this->auth->shouldUse('api');
59
+		if (! in_array($permission, $skipLoginCheck)) {
60
+			$this->authMiddleware->handle($request, function ($request) use ($modelName, $skipPermissionCheck, $permission) {
61
+				$user             = $this->auth->user();
62
+				$isPasswordClient = $user->token()->client->password_client;
63 63
     
64
-                if ($user->blocked) {
65
-                    \Errors::userIsBlocked();
66
-                }
64
+				if ($user->blocked) {
65
+					\Errors::userIsBlocked();
66
+				}
67 67
     
68
-                if ($isPasswordClient && (in_array($permission, $skipPermissionCheck) || $this->userService->can($permission, $modelName))) {
69
-                } elseif (! $isPasswordClient && $user->tokenCan($modelName.'-'.$permission)) {
70
-                } else {
71
-                    \Errors::noPermissions();
72
-                }
73
-            });
74
-        }
68
+				if ($isPasswordClient && (in_array($permission, $skipPermissionCheck) || $this->userService->can($permission, $modelName))) {
69
+				} elseif (! $isPasswordClient && $user->tokenCan($modelName.'-'.$permission)) {
70
+				} else {
71
+					\Errors::noPermissions();
72
+				}
73
+			});
74
+		}
75 75
 
76
-        return $next($request);
77
-    }
76
+		return $next($request);
77
+	}
78 78
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
         $permission          = $routeActions[1];
57 57
 
58 58
         $this->auth->shouldUse('api');
59
-        if (! in_array($permission, $skipLoginCheck)) {
60
-            $this->authMiddleware->handle($request, function ($request) use ($modelName, $skipPermissionCheck, $permission) {
59
+        if ( ! in_array($permission, $skipLoginCheck)) {
60
+            $this->authMiddleware->handle($request, function($request) use ($modelName, $skipPermissionCheck, $permission) {
61 61
                 $user             = $this->auth->user();
62 62
                 $isPasswordClient = $user->token()->client->password_client;
63 63
     
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
                 }
67 67
     
68 68
                 if ($isPasswordClient && (in_array($permission, $skipPermissionCheck) || $this->userService->can($permission, $modelName))) {
69
-                } elseif (! $isPasswordClient && $user->tokenCan($modelName.'-'.$permission)) {
69
+                } elseif ( ! $isPasswordClient && $user->tokenCan($modelName.'-'.$permission)) {
70 70
                 } else {
71 71
                     \Errors::noPermissions();
72 72
                 }
Please login to merge, or discard this patch.