Completed
Push — master ( acebc9...8b745b )
by Sherif
02:05
created
src/Modules/V1/Acl/AclPermission.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
     
30 30
     public function groups()
31 31
     {
32
-        return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','groups_permissions','permission_id','group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
32
+        return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup', 'groups_permissions', 'permission_id', 'group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
33 33
     }
34 34
 
35 35
     public static function boot()
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -5,37 +5,37 @@
 block discarded – undo
5 5
 
6 6
 class AclPermission extends Model {
7 7
 
8
-    use SoftDeletes;
9
-    protected $table    = 'permissions';
10
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
-    protected $hidden   = ['deleted_at'];
12
-    protected $guarded  = ['id'];
13
-    protected $fillable = ['name', 'model'];
14
-    public $searchable  = ['name', 'model'];
8
+	use SoftDeletes;
9
+	protected $table    = 'permissions';
10
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
+	protected $hidden   = ['deleted_at'];
12
+	protected $guarded  = ['id'];
13
+	protected $fillable = ['name', 'model'];
14
+	public $searchable  = ['name', 'model'];
15 15
 
16
-    public function getCreatedAtAttribute($value)
17
-    {
18
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
19
-    }
16
+	public function getCreatedAtAttribute($value)
17
+	{
18
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
19
+	}
20 20
 
21
-    public function getUpdatedAtAttribute($value)
22
-    {
23
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
24
-    }
21
+	public function getUpdatedAtAttribute($value)
22
+	{
23
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
24
+	}
25 25
 
26
-    public function getDeletedAtAttribute($value)
27
-    {
28
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
29
-    }
26
+	public function getDeletedAtAttribute($value)
27
+	{
28
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
29
+	}
30 30
     
31
-    public function groups()
32
-    {
33
-        return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','groups_permissions','permission_id','group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
34
-    }
31
+	public function groups()
32
+	{
33
+		return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','groups_permissions','permission_id','group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
34
+	}
35 35
 
36
-    public static function boot()
37
-    {
38
-        parent::boot();
39
-        parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclPermissionObserver'));
40
-    }
36
+	public static function boot()
37
+	{
38
+		parent::boot();
39
+		parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclPermissionObserver'));
40
+	}
41 41
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Http/Controllers/PermissionsController.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@
 block discarded – undo
7 7
 
8 8
 class PermissionsController extends BaseApiController
9 9
 {
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 = 'permissions';
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 = 'permissions';
16 16
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Http/Controllers/GroupsController.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@
 block discarded – undo
13 13
      * to preform actions like (add, edit ... etc).
14 14
      * @var string
15 15
      */
16
-    protected $model               = 'groups';
16
+    protected $model = 'groups';
17 17
 
18 18
     /**
19 19
      * The validations rules used by the base api controller
20 20
      * to check before add.
21 21
      * @var array
22 22
      */
23
-    protected $validationRules  = [
23
+    protected $validationRules = [
24 24
     'name' => 'required|string|max:100|unique:groups,name,{id}'
25 25
     ];
26 26
 
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -8,35 +8,35 @@
 block discarded – undo
8 8
 
9 9
 class GroupsController extends BaseApiController
10 10
 {
11
-    /**
12
-     * The name of the model that is used by the base api controller 
13
-     * to preform actions like (add, edit ... etc).
14
-     * @var string
15
-     */
16
-    protected $model               = 'groups';
11
+	/**
12
+	 * The name of the model that is used by the base api controller 
13
+	 * to preform actions like (add, edit ... etc).
14
+	 * @var string
15
+	 */
16
+	protected $model               = 'groups';
17 17
 
18
-    /**
19
-     * The validations rules used by the base api controller
20
-     * to check before add.
21
-     * @var array
22
-     */
23
-    protected $validationRules  = [
24
-    'name' => 'required|string|max:100|unique:groups,name,{id}'
25
-    ];
18
+	/**
19
+	 * The validations rules used by the base api controller
20
+	 * to check before add.
21
+	 * @var array
22
+	 */
23
+	protected $validationRules  = [
24
+	'name' => 'required|string|max:100|unique:groups,name,{id}'
25
+	];
26 26
 
27
-    /**
28
-     * Handle an assign permissions to group request.
29
-     *
30
-     * @param  \Illuminate\Http\Request  $request
31
-     * @return \Illuminate\Http\Response
32
-     */
33
-    public function assignpermissions(Request $request)
34
-    {
35
-        $this->validate($request, [
36
-            'permission_ids' => 'required|exists:permissions,id', 
37
-            'group_id'       => 'required|array|exists:groups,id'
38
-            ]);
27
+	/**
28
+	 * Handle an assign permissions to group request.
29
+	 *
30
+	 * @param  \Illuminate\Http\Request  $request
31
+	 * @return \Illuminate\Http\Response
32
+	 */
33
+	public function assignpermissions(Request $request)
34
+	{
35
+		$this->validate($request, [
36
+			'permission_ids' => 'required|exists:permissions,id', 
37
+			'group_id'       => 'required|array|exists:groups,id'
38
+			]);
39 39
 
40
-        return \Response::json(\Core::groups()->assignPermissions($request->get('group_id'), $request->get('permission_ids')), 200);
41
-    }
40
+		return \Response::json(\Core::groups()->assignPermissions($request->get('group_id'), $request->get('permission_ids')), 200);
41
+	}
42 42
 }
Please login to merge, or discard this patch.
Modules/V1/Acl/Database/Migrations/2015_12_20_124154_password_resets.php 2 patches
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('password_resets', function (Blueprint $table) {
15
+        Schema::create('password_resets', function(Blueprint $table) {
16 16
             $table->string('email')->index();
17 17
             $table->string('token')->index();
18 18
             $table->timestamp('created_at');
Please login to merge, or discard this patch.
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -5,27 +5,27 @@
 block discarded – undo
5 5
 
6 6
 class PasswordResets extends Migration
7 7
 {
8
-    /**
9
-     * Run the migrations.
10
-     *
11
-     * @return void
12
-     */
13
-    public function up()
14
-    {
15
-        Schema::create('password_resets', function (Blueprint $table) {
16
-            $table->string('email')->index();
17
-            $table->string('token')->index();
18
-            $table->timestamp('created_at');
19
-        });
20
-    }
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('password_resets', function (Blueprint $table) {
16
+			$table->string('email')->index();
17
+			$table->string('token')->index();
18
+			$table->timestamp('created_at');
19
+		});
20
+	}
21 21
 
22
-    /**
23
-     * Reverse the migrations.
24
-     *
25
-     * @return void
26
-     */
27
-    public function down()
28
-    {
29
-        Schema::dropIfExists('password_resets');
30
-    }
22
+	/**
23
+	 * Reverse the migrations.
24
+	 *
25
+	 * @return void
26
+	 */
27
+	public function down()
28
+	{
29
+		Schema::dropIfExists('password_resets');
30
+	}
31 31
 }
Please login to merge, or discard this patch.
src/Modules/V1/Core/Core.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 use App\Modules\V1\Core\AbstractRepositories\AbstractRepositoryContainer;
4 4
 
5
-class Core extends AbstractRepositoryContainer{
5
+class Core extends AbstractRepositoryContainer {
6 6
 	/**
7 7
 	 * Specify module repositories name space.
8 8
 	 * 
Please login to merge, or discard this patch.
src/Modules/V1/Core/Utl/Logging.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -2,17 +2,17 @@
 block discarded – undo
2 2
 
3 3
 class Logging
4 4
 {
5
-    public function saveLog($action, $item_name, $item_type, $item_id)
6
-    {
7
-    	if (\Core::logs() && $item_name !== 'Log')
8
-    	{
9
-    		\Core::logs()->save([
10
-	    		'action'      => $action,
11
-	    		'item_name'   => $item_name,
12
-	    		'item_type'   => $item_type,
13
-	    		'item_id'     => $item_id,
14
-	    		'user_id'     => \JWTAuth::parseToken()->authenticate()->id,
15
-	    		], false, false);
16
-    	}
17
-    }
5
+	public function saveLog($action, $item_name, $item_type, $item_id)
6
+	{
7
+		if (\Core::logs() && $item_name !== 'Log')
8
+		{
9
+			\Core::logs()->save([
10
+				'action'      => $action,
11
+				'item_name'   => $item_name,
12
+				'item_type'   => $item_type,
13
+				'item_id'     => $item_id,
14
+				'user_id'     => \JWTAuth::parseToken()->authenticate()->id,
15
+				], false, false);
16
+		}
17
+	}
18 18
 }
19 19
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/V1/Core/Http/Controllers/BaseApiController.php 4 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -170,8 +170,7 @@
 block discarded – undo
170 170
             if ($request->has('id')) 
171 171
             {
172 172
                 $rule = str_replace('{id}', $request->get('id'), $rule);
173
-            }
174
-            else
173
+            } else
175 174
             {
176 175
                 $rule = str_replace(',{id}', '', $rule);
177 176
             }
Please login to merge, or discard this patch.
Indentation   +268 added lines, -268 removed lines patch added patch discarded remove patch
@@ -6,298 +6,298 @@
 block discarded – undo
6 6
 
7 7
 class BaseApiController extends Controller
8 8
 {
9
-    /**
10
-     * The config implementation.
11
-     * 
12
-     * @var array
13
-     */
14
-    protected $config;
9
+	/**
10
+	 * The config implementation.
11
+	 * 
12
+	 * @var array
13
+	 */
14
+	protected $config;
15 15
 
16
-    /**
17
-     * The relations implementation.
18
-     * 
19
-     * @var array
20
-     */
21
-    protected $relations;
16
+	/**
17
+	 * The relations implementation.
18
+	 * 
19
+	 * @var array
20
+	 */
21
+	protected $relations;
22 22
 
23
-    /**
24
-     * The repo implementation.
25
-     * 
26
-     * @var array
27
-     */
28
-    protected $repo;
23
+	/**
24
+	 * The repo implementation.
25
+	 * 
26
+	 * @var array
27
+	 */
28
+	protected $repo;
29 29
 
30
-    public function __construct()
31
-    {        
32
-        $this->config              = \CoreConfig::getConfig();
33
-        $this->model               = property_exists($this, 'model') ? $this->model : false;
34
-        $this->validationRules     = property_exists($this, 'validationRules') ? $this->validationRules : false;
35
-        $this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : [];
36
-        $this->skipLoginCheck      = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : [];
37
-        $this->repo                = call_user_func_array("\Core::{$this->model}", []);
38
-        $route                     = explode('@',\Route::currentRouteAction())[1];
30
+	public function __construct()
31
+	{        
32
+		$this->config              = \CoreConfig::getConfig();
33
+		$this->model               = property_exists($this, 'model') ? $this->model : false;
34
+		$this->validationRules     = property_exists($this, 'validationRules') ? $this->validationRules : false;
35
+		$this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : [];
36
+		$this->skipLoginCheck      = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : [];
37
+		$this->repo                = call_user_func_array("\Core::{$this->model}", []);
38
+		$route                     = explode('@',\Route::currentRouteAction())[1];
39 39
 
40
-        $this->checkPermission($route);
41
-        $this->setRelations($route);
42
-        $this->setSessions();
43
-    }
40
+		$this->checkPermission($route);
41
+		$this->setRelations($route);
42
+		$this->setSessions();
43
+	}
44 44
 
45
-    /**
46
-     * Fetch all records with relations from storage.
47
-     * 
48
-     * @param  string  $sortBy The name of the column to sort by.
49
-     * @param  boolean $desc   Sort ascending or descinding (1: desc, 0: asc).
50
-     * @return \Illuminate\Http\Response
51
-     */
52
-    public function index($sortBy = 'created_at', $desc = 1) 
53
-    {
54
-        if ($this->repo)
55
-        {
56
-            return \Response::json($this->repo->all($this->relations, $sortBy, $desc), 200);
57
-        }
58
-    }
45
+	/**
46
+	 * Fetch all records with relations from storage.
47
+	 * 
48
+	 * @param  string  $sortBy The name of the column to sort by.
49
+	 * @param  boolean $desc   Sort ascending or descinding (1: desc, 0: asc).
50
+	 * @return \Illuminate\Http\Response
51
+	 */
52
+	public function index($sortBy = 'created_at', $desc = 1) 
53
+	{
54
+		if ($this->repo)
55
+		{
56
+			return \Response::json($this->repo->all($this->relations, $sortBy, $desc), 200);
57
+		}
58
+	}
59 59
 
60
-    /**
61
-     * Fetch the single object with relations from storage.
62
-     * 
63
-     * @param  integer $id Id of the requested model.
64
-     * @return \Illuminate\Http\Response
65
-     */
66
-    public function find($id) 
67
-    {
68
-        if ($this->repo) 
69
-        {
70
-            return \Response::json($this->repo->find($id, $this->relations), 200);
71
-        }
72
-    }
60
+	/**
61
+	 * Fetch the single object with relations from storage.
62
+	 * 
63
+	 * @param  integer $id Id of the requested model.
64
+	 * @return \Illuminate\Http\Response
65
+	 */
66
+	public function find($id) 
67
+	{
68
+		if ($this->repo) 
69
+		{
70
+			return \Response::json($this->repo->find($id, $this->relations), 200);
71
+		}
72
+	}
73 73
 
74
-    /**
75
-     * Paginate all records with relations from storage
76
-     * that matche the given query.
77
-     * 
78
-     * @param  string  $query   The search text.
79
-     * @param  integer $perPage Number of rows per page default 15.
80
-     * @param  string  $sortBy  The name of the column to sort by.
81
-     * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
82
-     * @return \Illuminate\Http\Response
83
-     */
84
-    public function search($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) 
85
-    {
86
-        if ($this->repo) 
87
-        {
88
-            return \Response::json($this->repo->search($query, $perPage, $this->relations, $sortBy, $desc), 200);
89
-        }
90
-    }
74
+	/**
75
+	 * Paginate all records with relations from storage
76
+	 * that matche the given query.
77
+	 * 
78
+	 * @param  string  $query   The search text.
79
+	 * @param  integer $perPage Number of rows per page default 15.
80
+	 * @param  string  $sortBy  The name of the column to sort by.
81
+	 * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
82
+	 * @return \Illuminate\Http\Response
83
+	 */
84
+	public function search($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) 
85
+	{
86
+		if ($this->repo) 
87
+		{
88
+			return \Response::json($this->repo->search($query, $perPage, $this->relations, $sortBy, $desc), 200);
89
+		}
90
+	}
91 91
 
92
-    /**
93
-     * Fetch records from the storage based on the given
94
-     * condition.
95
-     * 
96
-     * @param  \Illuminate\Http\Request  $request
97
-     * @param  string  $sortBy The name of the column to sort by.
98
-     * @param  boolean $desc   Sort ascending or descinding (1: desc, 0: asc).
99
-     * @return \Illuminate\Http\Response
100
-     */
101
-    public function findby(Request $request, $sortBy = 'created_at', $desc = 1) 
102
-    {
103
-        if ($this->repo) 
104
-        {
105
-            return \Response::json($this->repo->findBy($request->all(), $this->relations, $sortBy, $desc), 200);
106
-        }
107
-    }
92
+	/**
93
+	 * Fetch records from the storage based on the given
94
+	 * condition.
95
+	 * 
96
+	 * @param  \Illuminate\Http\Request  $request
97
+	 * @param  string  $sortBy The name of the column to sort by.
98
+	 * @param  boolean $desc   Sort ascending or descinding (1: desc, 0: asc).
99
+	 * @return \Illuminate\Http\Response
100
+	 */
101
+	public function findby(Request $request, $sortBy = 'created_at', $desc = 1) 
102
+	{
103
+		if ($this->repo) 
104
+		{
105
+			return \Response::json($this->repo->findBy($request->all(), $this->relations, $sortBy, $desc), 200);
106
+		}
107
+	}
108 108
 
109
-    /**
110
-     * Fetch the first record from the storage based on the given
111
-     * condition.
112
-     * 
113
-     * @param  \Illuminate\Http\Request  $request
114
-     * @return \Illuminate\Http\Response
115
-     */
116
-    public function first(Request $request) 
117
-    {
118
-        if ($this->repo) 
119
-        {
120
-            return \Response::json($this->repo->first($request->all(), $this->relations), 200);
121
-        }
122
-    }
109
+	/**
110
+	 * Fetch the first record from the storage based on the given
111
+	 * condition.
112
+	 * 
113
+	 * @param  \Illuminate\Http\Request  $request
114
+	 * @return \Illuminate\Http\Response
115
+	 */
116
+	public function first(Request $request) 
117
+	{
118
+		if ($this->repo) 
119
+		{
120
+			return \Response::json($this->repo->first($request->all(), $this->relations), 200);
121
+		}
122
+	}
123 123
 
124
-    /**
125
-     * Paginate all records with relations from storage.
126
-     * 
127
-     * @param  integer $perPage Number of rows per page default 15.
128
-     * @param  string  $sortBy  The name of the column to sort by.
129
-     * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
130
-     * @return \Illuminate\Http\Response
131
-     */
132
-    public function paginate($perPage = 15, $sortBy = 'created_at', $desc = 1) 
133
-    {
134
-        if ($this->repo) 
135
-        {
136
-            return \Response::json($this->repo->paginate($perPage, $this->relations, $sortBy, $desc), 200);
137
-        }
138
-    }
124
+	/**
125
+	 * Paginate all records with relations from storage.
126
+	 * 
127
+	 * @param  integer $perPage Number of rows per page default 15.
128
+	 * @param  string  $sortBy  The name of the column to sort by.
129
+	 * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
130
+	 * @return \Illuminate\Http\Response
131
+	 */
132
+	public function paginate($perPage = 15, $sortBy = 'created_at', $desc = 1) 
133
+	{
134
+		if ($this->repo) 
135
+		{
136
+			return \Response::json($this->repo->paginate($perPage, $this->relations, $sortBy, $desc), 200);
137
+		}
138
+	}
139 139
 
140
-    /**
141
-     * Fetch all records with relations based on
142
-     * the given condition from storage in pages.
143
-     * 
144
-     * @param  \Illuminate\Http\Request  $request
145
-     * @param  integer $perPage Number of rows per page default 15.
146
-     * @param  string  $sortBy  The name of the column to sort by.
147
-     * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
148
-     * @return \Illuminate\Http\Response
149
-     */
150
-    public function paginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
151
-    {
152
-        if ($this->repo) 
153
-        {
154
-            return \Response::json($this->repo->paginateBy($request->all(), $perPage, $this->relations, $sortBy, $desc), 200);
155
-        }
156
-    }
140
+	/**
141
+	 * Fetch all records with relations based on
142
+	 * the given condition from storage in pages.
143
+	 * 
144
+	 * @param  \Illuminate\Http\Request  $request
145
+	 * @param  integer $perPage Number of rows per page default 15.
146
+	 * @param  string  $sortBy  The name of the column to sort by.
147
+	 * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
148
+	 * @return \Illuminate\Http\Response
149
+	 */
150
+	public function paginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
151
+	{
152
+		if ($this->repo) 
153
+		{
154
+			return \Response::json($this->repo->paginateBy($request->all(), $perPage, $this->relations, $sortBy, $desc), 200);
155
+		}
156
+	}
157 157
 
158
-    /**
159
-     * Save the given model to storage.
160
-     * 
161
-     * @param  \Illuminate\Http\Request  $request
162
-     * @return \Illuminate\Http\Response
163
-     */
164
-    public function save(Request $request) 
165
-    {
166
-        foreach ($this->validationRules as &$rule) 
167
-        {
168
-            if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) 
169
-            {
170
-                $rule .= ',deleted_at,NULL';
171
-            }
158
+	/**
159
+	 * Save the given model to storage.
160
+	 * 
161
+	 * @param  \Illuminate\Http\Request  $request
162
+	 * @return \Illuminate\Http\Response
163
+	 */
164
+	public function save(Request $request) 
165
+	{
166
+		foreach ($this->validationRules as &$rule) 
167
+		{
168
+			if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) 
169
+			{
170
+				$rule .= ',deleted_at,NULL';
171
+			}
172 172
 
173
-            if ($request->has('id')) 
174
-            {
175
-                $rule = str_replace('{id}', $request->get('id'), $rule);
176
-            }
177
-            else
178
-            {
179
-                $rule = str_replace(',{id}', '', $rule);
180
-            }
181
-        }
173
+			if ($request->has('id')) 
174
+			{
175
+				$rule = str_replace('{id}', $request->get('id'), $rule);
176
+			}
177
+			else
178
+			{
179
+				$rule = str_replace(',{id}', '', $rule);
180
+			}
181
+		}
182 182
         
183
-        $this->validate($request, $this->validationRules);
183
+		$this->validate($request, $this->validationRules);
184 184
 
185
-        if ($this->repo) 
186
-        {
187
-            return \Response::json($this->repo->save($request->all()), 200);
188
-        }
189
-    }
185
+		if ($this->repo) 
186
+		{
187
+			return \Response::json($this->repo->save($request->all()), 200);
188
+		}
189
+	}
190 190
 
191
-    /**
192
-     * Delete by the given id from storage.
193
-     * 
194
-     * @param  integer $id Id of the deleted model.
195
-     * @return \Illuminate\Http\Response
196
-     */
197
-    public function delete($id) 
198
-    {
199
-        if ($this->repo) 
200
-        {
201
-            return \Response::json($this->repo->delete($id), 200);
202
-        }
203
-    }
191
+	/**
192
+	 * Delete by the given id from storage.
193
+	 * 
194
+	 * @param  integer $id Id of the deleted model.
195
+	 * @return \Illuminate\Http\Response
196
+	 */
197
+	public function delete($id) 
198
+	{
199
+		if ($this->repo) 
200
+		{
201
+			return \Response::json($this->repo->delete($id), 200);
202
+		}
203
+	}
204 204
 
205
-    /**
206
-     * Return the deleted models in pages based on the given conditions.
207
-     *
208
-     * @param  \Illuminate\Http\Request  $request
209
-     * @param  integer $perPage Number of rows per page default 15.
210
-     * @param  string  $sortBy  The name of the column to sort by.
211
-     * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
212
-     * @return \Illuminate\Http\Response
213
-     */
214
-    public function deleted(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
215
-    {
216
-        return \Response::json($this->repo->deleted($request->all(), $perPage, $sortBy, $desc), 200);
217
-    }
205
+	/**
206
+	 * Return the deleted models in pages based on the given conditions.
207
+	 *
208
+	 * @param  \Illuminate\Http\Request  $request
209
+	 * @param  integer $perPage Number of rows per page default 15.
210
+	 * @param  string  $sortBy  The name of the column to sort by.
211
+	 * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
212
+	 * @return \Illuminate\Http\Response
213
+	 */
214
+	public function deleted(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
215
+	{
216
+		return \Response::json($this->repo->deleted($request->all(), $perPage, $sortBy, $desc), 200);
217
+	}
218 218
 
219
-    /**
220
-     * Restore the deleted model.
221
-     * 
222
-     * @param  integer $id Id of the restored model.
223
-     * @return \Illuminate\Http\Response
224
-     */
225
-    public function restore($id) 
226
-    {
227
-        if ($this->repo) 
228
-        {
229
-            return \Response::json($this->repo->restore($id), 200);
230
-        }
231
-    }
219
+	/**
220
+	 * Restore the deleted model.
221
+	 * 
222
+	 * @param  integer $id Id of the restored model.
223
+	 * @return \Illuminate\Http\Response
224
+	 */
225
+	public function restore($id) 
226
+	{
227
+		if ($this->repo) 
228
+		{
229
+			return \Response::json($this->repo->restore($id), 200);
230
+		}
231
+	}
232 232
 
233
-    /**
234
-     * Check if the logged in user can do the given permission.
235
-     * 
236
-     * @param  string $permission
237
-     * @return void
238
-     */
239
-    private function checkPermission($permission)
240
-    {
241
-        $permission = $permission !== 'index' ? $permission : 'list';
242
-        if ( ! in_array($permission, $this->skipLoginCheck)) 
243
-        {
244
-            $user = \JWTAuth::parseToken()->authenticate();
245
-            if ($user->blocked)
246
-            {
247
-                \ErrorHandler::userIsBlocked();
248
-            }
233
+	/**
234
+	 * Check if the logged in user can do the given permission.
235
+	 * 
236
+	 * @param  string $permission
237
+	 * @return void
238
+	 */
239
+	private function checkPermission($permission)
240
+	{
241
+		$permission = $permission !== 'index' ? $permission : 'list';
242
+		if ( ! in_array($permission, $this->skipLoginCheck)) 
243
+		{
244
+			$user = \JWTAuth::parseToken()->authenticate();
245
+			if ($user->blocked)
246
+			{
247
+				\ErrorHandler::userIsBlocked();
248
+			}
249 249
             
250
-            if ( ! in_array($permission, $this->skipPermissionCheck) && ! \Core::users()->can($permission, $this->model))
251
-            {
252
-                \ErrorHandler::noPermissions();
253
-            }
254
-        }
255
-    }
250
+			if ( ! in_array($permission, $this->skipPermissionCheck) && ! \Core::users()->can($permission, $this->model))
251
+			{
252
+				\ErrorHandler::noPermissions();
253
+			}
254
+		}
255
+	}
256 256
 
257
-    /**
258
-     * Set sessions based on the given headers in the request.
259
-     * 
260
-     * @return void
261
-     */
262
-    private function setSessions()
263
-    {
264
-        \Session::put('timeZoneDiff', \Request::header('time-zone-diff') ?: 0);
257
+	/**
258
+	 * Set sessions based on the given headers in the request.
259
+	 * 
260
+	 * @return void
261
+	 */
262
+	private function setSessions()
263
+	{
264
+		\Session::put('timeZoneDiff', \Request::header('time-zone-diff') ?: 0);
265 265
 
266
-        $locale = \Request::header('locale');
267
-        switch ($locale) 
268
-        {
269
-            case 'en':
270
-            \App::setLocale('en');
271
-            \Session::put('locale', 'en');
272
-            break;
266
+		$locale = \Request::header('locale');
267
+		switch ($locale) 
268
+		{
269
+			case 'en':
270
+			\App::setLocale('en');
271
+			\Session::put('locale', 'en');
272
+			break;
273 273
 
274
-            case 'ar':
275
-            \App::setLocale('ar');
276
-            \Session::put('locale', 'ar');
277
-            break;
274
+			case 'ar':
275
+			\App::setLocale('ar');
276
+			\Session::put('locale', 'ar');
277
+			break;
278 278
 
279
-            case 'all':
280
-            \App::setLocale('en');
281
-            \Session::put('locale', 'all');
282
-            break;
279
+			case 'all':
280
+			\App::setLocale('en');
281
+			\Session::put('locale', 'all');
282
+			break;
283 283
 
284
-            default:
285
-            \App::setLocale('en');
286
-            \Session::put('locale', 'en');
287
-            break;
288
-        }
289
-    }
284
+			default:
285
+			\App::setLocale('en');
286
+			\Session::put('locale', 'en');
287
+			break;
288
+		}
289
+	}
290 290
 
291
-    /**
292
-     * Set relation based on the called api.
293
-     * 
294
-     * @param  string $route
295
-     * @return void
296
-     */
297
-    private function setRelations($route)
298
-    {
299
-        $route           = $route !== 'index' ? $route : 'list';
300
-        $relations       = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false;
301
-        $this->relations = $relations && $relations[$route] ? $relations[$route] : [];
302
-    }
291
+	/**
292
+	 * Set relation based on the called api.
293
+	 * 
294
+	 * @param  string $route
295
+	 * @return void
296
+	 */
297
+	private function setRelations($route)
298
+	{
299
+		$route           = $route !== 'index' ? $route : 'list';
300
+		$relations       = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false;
301
+		$this->relations = $relations && $relations[$route] ? $relations[$route] : [];
302
+	}
303 303
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
         $this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : [];
36 36
         $this->skipLoginCheck      = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : [];
37 37
         $this->repo                = call_user_func_array("\Core::{$this->model}", []);
38
-        $route                     = explode('@',\Route::currentRouteAction())[1];
38
+        $route                     = explode('@', \Route::currentRouteAction())[1];
39 39
 
40 40
         $this->checkPermission($route);
41 41
         $this->setRelations($route);
Please login to merge, or discard this patch.
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * Fetch all records with relations from storage.
47 47
      * 
48 48
      * @param  string  $sortBy The name of the column to sort by.
49
-     * @param  boolean $desc   Sort ascending or descinding (1: desc, 0: asc).
49
+     * @param  integer $desc   Sort ascending or descinding (1: desc, 0: asc).
50 50
      * @return \Illuminate\Http\Response
51 51
      */
52 52
     public function index($sortBy = 'created_at', $desc = 1) 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      * @param  string  $query   The search text.
79 79
      * @param  integer $perPage Number of rows per page default 15.
80 80
      * @param  string  $sortBy  The name of the column to sort by.
81
-     * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
81
+     * @param  integer $desc    Sort ascending or descinding (1: desc, 0: asc).
82 82
      * @return \Illuminate\Http\Response
83 83
      */
84 84
     public function search($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      * 
96 96
      * @param  \Illuminate\Http\Request  $request
97 97
      * @param  string  $sortBy The name of the column to sort by.
98
-     * @param  boolean $desc   Sort ascending or descinding (1: desc, 0: asc).
98
+     * @param  integer $desc   Sort ascending or descinding (1: desc, 0: asc).
99 99
      * @return \Illuminate\Http\Response
100 100
      */
101 101
     public function findby(Request $request, $sortBy = 'created_at', $desc = 1) 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      * 
127 127
      * @param  integer $perPage Number of rows per page default 15.
128 128
      * @param  string  $sortBy  The name of the column to sort by.
129
-     * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
129
+     * @param  integer $desc    Sort ascending or descinding (1: desc, 0: asc).
130 130
      * @return \Illuminate\Http\Response
131 131
      */
132 132
     public function paginate($perPage = 15, $sortBy = 'created_at', $desc = 1) 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      * @param  \Illuminate\Http\Request  $request
145 145
      * @param  integer $perPage Number of rows per page default 15.
146 146
      * @param  string  $sortBy  The name of the column to sort by.
147
-     * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
147
+     * @param  integer $desc    Sort ascending or descinding (1: desc, 0: asc).
148 148
      * @return \Illuminate\Http\Response
149 149
      */
150 150
     public function paginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
      * @param  \Illuminate\Http\Request  $request
209 209
      * @param  integer $perPage Number of rows per page default 15.
210 210
      * @param  string  $sortBy  The name of the column to sort by.
211
-     * @param  boolean $desc    Sort ascending or descinding (1: desc, 0: asc).
211
+     * @param  integer $desc    Sort ascending or descinding (1: desc, 0: asc).
212 212
      * @return \Illuminate\Http\Response
213 213
      */
214 214
     public function deleted(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
Please login to merge, or discard this patch.
V1/Notifications/Http/Controllers/PushNotificationsDevicesController.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,22 +7,22 @@
 block discarded – undo
7 7
 
8 8
 class PushNotificationsDevicesController extends BaseApiController
9 9
 {
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            = 'pushNotificationDevices';
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            = 'pushNotificationDevices';
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:255',
24
-    'device_type'  => 'required|in:android,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:255',
24
+	'device_type'  => 'required|in:android,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            = 'pushNotificationDevices';
15
+    protected $model = 'pushNotificationDevices';
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:255',
24 24
     'device_type'  => 'required|in:android,ios',
25 25
     'user_id'      => 'required|exists:users,id',
Please login to merge, or discard this patch.
src/Modules/V1/Notifications/PushNotificationDevice.php 2 patches
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 PushNotificationDevice extends Model{
6
+class PushNotificationDevice extends Model {
7 7
 
8 8
     use SoftDeletes;
9 9
     protected $table    = 'push_notifications_devices';
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -5,37 +5,37 @@
 block discarded – undo
5 5
 
6 6
 class PushNotificationDevice 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'];
14
-    public $searchable  = ['device_token', 'device_type'];
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
+	public $searchable  = ['device_token', 'device_type'];
15 15
 
16
-    public function getCreatedAtAttribute($value)
17
-    {
18
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
19
-    }
16
+	public function getCreatedAtAttribute($value)
17
+	{
18
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
19
+	}
20 20
 
21
-    public function getUpdatedAtAttribute($value)
22
-    {
23
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
24
-    }
21
+	public function getUpdatedAtAttribute($value)
22
+	{
23
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
24
+	}
25 25
 
26
-    public function getDeletedAtAttribute($value)
27
-    {
28
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
29
-    }
26
+	public function getDeletedAtAttribute($value)
27
+	{
28
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
29
+	}
30 30
     
31
-    public function user()
32
-    {
33
-        return $this->belongsTo('App\Modules\V1\Acl\AclUser');
34
-    }
31
+	public function user()
32
+	{
33
+		return $this->belongsTo('App\Modules\V1\Acl\AclUser');
34
+	}
35 35
 
36
-    public static function boot()
37
-    {
38
-        parent::boot();
39
-        parent::observe(\App::make('App\Modules\V1\Notifications\ModelObservers\PushNotificationDeviceObserver'));
40
-    }
36
+	public static function boot()
37
+	{
38
+		parent::boot();
39
+		parent::observe(\App::make('App\Modules\V1\Notifications\ModelObservers\PushNotificationDeviceObserver'));
40
+	}
41 41
 }
Please login to merge, or discard this patch.