Completed
Push — master ( 2f9ece...c4baa4 )
by Sherif
05:12 queued 45s
created
src/Modules/Core/ErrorHandler.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -2,33 +2,33 @@
 block discarded – undo
2 2
 
3 3
 class ErrorHandler
4 4
 {
5
-    public function unAuthorized()
6
-    {
7
-        return ['status' => 401, 'message' => 'Please login before any action'];
8
-    }
5
+	public function unAuthorized()
6
+	{
7
+		return ['status' => 401, 'message' => 'Please login before any action'];
8
+	}
9 9
 
10
-    public function loginFailed()
11
-    {
12
-        return ['status' => 400, 'message' => 'Wrong mail or password'];
13
-    }
10
+	public function loginFailed()
11
+	{
12
+		return ['status' => 400, 'message' => 'Wrong mail or password'];
13
+	}
14 14
 
15
-    public function noPermissions()
16
-    {
17
-        return ['status' => 401, 'message' => 'No permissions'];
18
-    }
15
+	public function noPermissions()
16
+	{
17
+		return ['status' => 401, 'message' => 'No permissions'];
18
+	}
19 19
 
20
-    public function cannotCreateSetting()
21
-    {
22
-        return ['status' => 400, 'message' => 'Can\'t create setting'];
23
-    }
20
+	public function cannotCreateSetting()
21
+	{
22
+		return ['status' => 400, 'message' => 'Can\'t create setting'];
23
+	}
24 24
 
25
-    public function cannotUpdateSettingKey()
26
-    {
27
-        return ['status' => 400, 'message' => 'Can\'t update setting key'];
28
-    }
25
+	public function cannotUpdateSettingKey()
26
+	{
27
+		return ['status' => 400, 'message' => 'Can\'t update setting key'];
28
+	}
29 29
 
30
-    public function notFound($text)
31
-    {
32
-        return ['status' => 404, 'message' => 'The requested ' . $text . ' not found'];
33
-    }
30
+	public function notFound($text)
31
+	{
32
+		return ['status' => 404, 'message' => 'The requested ' . $text . ' not found'];
33
+	}
34 34
 }
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/Core/Http/Controllers/BaseApiController.php 1 patch
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -9,242 +9,242 @@
 block discarded – undo
9 9
 
10 10
 class BaseApiController extends Controller
11 11
 {
12
-    /**
13
-     * The errorHandler implementation.
14
-     * 
15
-     * @var errorHandler
16
-     */
17
-    protected $errorHandler;
18
-
19
-    /**
20
-     * The config implementation.
21
-     * 
22
-     * @var config
23
-     */
24
-    protected $config;
25
-
26
-    /**
27
-     * The model implementation.
28
-     * 
29
-     * @var model
30
-     */
31
-    protected $model;
32
-
33
-    /**
34
-     * Create new BaseApiController instance.
35
-     * 
36
-     * @param errorHandler
37
-     */
38
-    public function __construct(ErrorHandler $errorHandler, CoreConfig $config)
39
-    {
40
-        \Session::set('timeZoneDiff', \Request::header('time-zone-diff') ?: 0);
41
-        $this->errorHandler        = $errorHandler;
42
-        $this->config              = $config->getConfig();
12
+	/**
13
+	 * The errorHandler implementation.
14
+	 * 
15
+	 * @var errorHandler
16
+	 */
17
+	protected $errorHandler;
18
+
19
+	/**
20
+	 * The config implementation.
21
+	 * 
22
+	 * @var config
23
+	 */
24
+	protected $config;
25
+
26
+	/**
27
+	 * The model implementation.
28
+	 * 
29
+	 * @var model
30
+	 */
31
+	protected $model;
32
+
33
+	/**
34
+	 * Create new BaseApiController instance.
35
+	 * 
36
+	 * @param errorHandler
37
+	 */
38
+	public function __construct(ErrorHandler $errorHandler, CoreConfig $config)
39
+	{
40
+		\Session::set('timeZoneDiff', \Request::header('time-zone-diff') ?: 0);
41
+		$this->errorHandler        = $errorHandler;
42
+		$this->config              = $config->getConfig();
43 43
         
44
-        $this->model               = property_exists($this, 'model') ? $this->model : false;
45
-        $this->validationRules     = property_exists($this, 'validationRules') ? $this->validationRules : false;
46
-        $this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : [];
47
-        $this->skipLoginCheck      = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : [];
44
+		$this->model               = property_exists($this, 'model') ? $this->model : false;
45
+		$this->validationRules     = property_exists($this, 'validationRules') ? $this->validationRules : false;
46
+		$this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : [];
47
+		$this->skipLoginCheck      = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : [];
48 48
         
49
-        $this->relations           = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false;
50
-        $route                     = explode('@',\Route::currentRouteAction())[1];
51
-        $this->checkPermission(explode('_', snake_case($route))[1]);
52
-    }
53
-
54
-    /**
55
-     * Fetch all records with relations from model repository.
56
-     * 
57
-     * @param  string  $sortBy
58
-     * @param  boolean $desc
59
-     * @return \Illuminate\Http\Response
60
-     */
61
-    public function getIndex() 
62
-    {
63
-        if ($this->model)
64
-        {
65
-            $relations = $this->relations && $this->relations['all'] ? $this->relations['all'] : [];
66
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->all($relations), 200);
67
-        }
68
-    }
69
-
70
-    /**
71
-     * Fetch the single object with relations from model repository.
72
-     * 
73
-     * @param  integer $id
74
-     * @return \Illuminate\Http\Response
75
-     */
76
-    public function getFind($id) 
77
-    {
78
-        if ($this->model) 
79
-        {
80
-            $relations = $this->relations && $this->relations['find'] ? $this->relations['find'] : [];
81
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->find($id, $relations), 200);
82
-        }
83
-    }
84
-
85
-    /**
86
-     * Paginate all records with relations from model repository
87
-     * that matche the given query.
88
-     * 
89
-     * @param  string  $query
90
-     * @param  integer $perPage
91
-     * @param  string  $sortBy
92
-     * @param  boolean $desc
93
-     * @return \Illuminate\Http\Response
94
-     */
95
-    public function getSearch($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) 
96
-    {
97
-        if ($this->model) 
98
-        {
99
-            $relations = $this->relations && $this->relations['paginate'] ? $this->relations['paginate'] : [];
100
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->search($query, $perPage, $relations, $sortBy, $desc), 200);
101
-        }
102
-    }
103
-
104
-    /**
105
-     * Fetch records from the storage based on the given
106
-     * condition.
107
-     * 
108
-     * @param  \Illuminate\Http\Request  $request
109
-     * @param  string  $sortBy
110
-     * @param  boolean $desc
111
-     * @return \Illuminate\Http\Response
112
-     */
113
-    public function postFindby(Request $request, $sortBy = 'created_at', $desc = 1) 
114
-    {
115
-        if ($this->model) 
116
-        {
117
-            $relations = $this->relations && $this->relations['findBy'] ? $this->relations['findBy'] : [];
118
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->findBy($request->all(), $relations, $sortBy, $desc), 200);
119
-        }
120
-    }
121
-
122
-    /**
123
-     * Fetch the first record from the storage based on the given
124
-     * condition.
125
-     * 
126
-     * @param  \Illuminate\Http\Request  $request
127
-     * @return \Illuminate\Http\Response
128
-     */
129
-    public function postFirst(Request $request) 
130
-    {
131
-        if ($this->model) 
132
-        {
133
-            $relations = $this->relations && $this->relations['first'] ? $this->relations['first'] : [];
134
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->first($request->all(), $relations), 200);
135
-        }
136
-    }
137
-
138
-    /**
139
-     * Paginate all records with relations from model repository.
140
-     * 
141
-     * @param  integer $perPage
142
-     * @param  string  $sortBy
143
-     * @param  boolean $desc
144
-     * @return \Illuminate\Http\Response
145
-     */
146
-    public function getPaginate($perPage = 15, $sortBy = 'created_at', $desc = 1) 
147
-    {
148
-        if ($this->model) 
149
-        {
150
-            $relations = $this->relations && $this->relations['paginate'] ? $this->relations['paginate'] : [];
151
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginate($perPage, $relations, $sortBy, $desc), 200);
152
-        }
153
-    }
154
-
155
-    /**
156
-     * Fetch all records with relations based on
157
-     * the given condition from storage in pages.
158
-     * 
159
-     * @param  \Illuminate\Http\Request  $request
160
-     * @param  integer $perPage
161
-     * @param  string  $sortBy
162
-     * @param  boolean $desc
163
-     * @return \Illuminate\Http\Response
164
-     */
165
-    public function postPaginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
166
-    {
167
-        if ($this->model) 
168
-        {
169
-            $relations = $this->relations && $this->relations['paginateBy'] ? $this->relations['paginateBy'] : [];
170
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginateBy($request->all(), $perPage, $relations, $sortBy, $desc), 200);
171
-        }
172
-    }
173
-
174
-    /**
175
-     * Save the given model to repository.
176
-     * 
177
-     * @param  \Illuminate\Http\Request  $request
178
-     * @return \Illuminate\Http\Response
179
-     */
180
-    public function postSave(Request $request) 
181
-    {
182
-        foreach ($this->validationRules as &$rule) 
183
-        {
184
-            if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) 
185
-            {
186
-                $rule .= ',deleted_at,NULL';
187
-            }
188
-
189
-            if ($request->has('id')) 
190
-            {
191
-                $rule = str_replace('{id}', $request->get('id'), $rule);
192
-            }
193
-            else
194
-            {
195
-                $rule = str_replace(',{id}', '', $rule);
196
-            }
197
-        }
49
+		$this->relations           = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false;
50
+		$route                     = explode('@',\Route::currentRouteAction())[1];
51
+		$this->checkPermission(explode('_', snake_case($route))[1]);
52
+	}
53
+
54
+	/**
55
+	 * Fetch all records with relations from model repository.
56
+	 * 
57
+	 * @param  string  $sortBy
58
+	 * @param  boolean $desc
59
+	 * @return \Illuminate\Http\Response
60
+	 */
61
+	public function getIndex() 
62
+	{
63
+		if ($this->model)
64
+		{
65
+			$relations = $this->relations && $this->relations['all'] ? $this->relations['all'] : [];
66
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->all($relations), 200);
67
+		}
68
+	}
69
+
70
+	/**
71
+	 * Fetch the single object with relations from model repository.
72
+	 * 
73
+	 * @param  integer $id
74
+	 * @return \Illuminate\Http\Response
75
+	 */
76
+	public function getFind($id) 
77
+	{
78
+		if ($this->model) 
79
+		{
80
+			$relations = $this->relations && $this->relations['find'] ? $this->relations['find'] : [];
81
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->find($id, $relations), 200);
82
+		}
83
+	}
84
+
85
+	/**
86
+	 * Paginate all records with relations from model repository
87
+	 * that matche the given query.
88
+	 * 
89
+	 * @param  string  $query
90
+	 * @param  integer $perPage
91
+	 * @param  string  $sortBy
92
+	 * @param  boolean $desc
93
+	 * @return \Illuminate\Http\Response
94
+	 */
95
+	public function getSearch($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) 
96
+	{
97
+		if ($this->model) 
98
+		{
99
+			$relations = $this->relations && $this->relations['paginate'] ? $this->relations['paginate'] : [];
100
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->search($query, $perPage, $relations, $sortBy, $desc), 200);
101
+		}
102
+	}
103
+
104
+	/**
105
+	 * Fetch records from the storage based on the given
106
+	 * condition.
107
+	 * 
108
+	 * @param  \Illuminate\Http\Request  $request
109
+	 * @param  string  $sortBy
110
+	 * @param  boolean $desc
111
+	 * @return \Illuminate\Http\Response
112
+	 */
113
+	public function postFindby(Request $request, $sortBy = 'created_at', $desc = 1) 
114
+	{
115
+		if ($this->model) 
116
+		{
117
+			$relations = $this->relations && $this->relations['findBy'] ? $this->relations['findBy'] : [];
118
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->findBy($request->all(), $relations, $sortBy, $desc), 200);
119
+		}
120
+	}
121
+
122
+	/**
123
+	 * Fetch the first record from the storage based on the given
124
+	 * condition.
125
+	 * 
126
+	 * @param  \Illuminate\Http\Request  $request
127
+	 * @return \Illuminate\Http\Response
128
+	 */
129
+	public function postFirst(Request $request) 
130
+	{
131
+		if ($this->model) 
132
+		{
133
+			$relations = $this->relations && $this->relations['first'] ? $this->relations['first'] : [];
134
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->first($request->all(), $relations), 200);
135
+		}
136
+	}
137
+
138
+	/**
139
+	 * Paginate all records with relations from model repository.
140
+	 * 
141
+	 * @param  integer $perPage
142
+	 * @param  string  $sortBy
143
+	 * @param  boolean $desc
144
+	 * @return \Illuminate\Http\Response
145
+	 */
146
+	public function getPaginate($perPage = 15, $sortBy = 'created_at', $desc = 1) 
147
+	{
148
+		if ($this->model) 
149
+		{
150
+			$relations = $this->relations && $this->relations['paginate'] ? $this->relations['paginate'] : [];
151
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginate($perPage, $relations, $sortBy, $desc), 200);
152
+		}
153
+	}
154
+
155
+	/**
156
+	 * Fetch all records with relations based on
157
+	 * the given condition from storage in pages.
158
+	 * 
159
+	 * @param  \Illuminate\Http\Request  $request
160
+	 * @param  integer $perPage
161
+	 * @param  string  $sortBy
162
+	 * @param  boolean $desc
163
+	 * @return \Illuminate\Http\Response
164
+	 */
165
+	public function postPaginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) 
166
+	{
167
+		if ($this->model) 
168
+		{
169
+			$relations = $this->relations && $this->relations['paginateBy'] ? $this->relations['paginateBy'] : [];
170
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->paginateBy($request->all(), $perPage, $relations, $sortBy, $desc), 200);
171
+		}
172
+	}
173
+
174
+	/**
175
+	 * Save the given model to repository.
176
+	 * 
177
+	 * @param  \Illuminate\Http\Request  $request
178
+	 * @return \Illuminate\Http\Response
179
+	 */
180
+	public function postSave(Request $request) 
181
+	{
182
+		foreach ($this->validationRules as &$rule) 
183
+		{
184
+			if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) 
185
+			{
186
+				$rule .= ',deleted_at,NULL';
187
+			}
188
+
189
+			if ($request->has('id')) 
190
+			{
191
+				$rule = str_replace('{id}', $request->get('id'), $rule);
192
+			}
193
+			else
194
+			{
195
+				$rule = str_replace(',{id}', '', $rule);
196
+			}
197
+		}
198 198
         
199
-        $this->validate($request, $this->validationRules);
200
-
201
-        if ($this->model) 
202
-        {
203
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->save($request->all()), 200);
204
-        }
205
-    }
206
-
207
-    /**
208
-     * Delete by the given id from model repository.
209
-     * 
210
-     * @param  integer  $id
211
-     * @return \Illuminate\Http\Response
212
-     */
213
-    public function getDelete($id) 
214
-    {
215
-        if ($this->model) 
216
-        {
217
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->delete($id), 200);
218
-        }
219
-    }
220
-
221
-    /**
222
-     * Check if the logged in user can do the given permission.
223
-     * 
224
-     * @param  string $permission
225
-     * @return void
226
-     */
227
-    private function checkPermission($permission)
228
-    {
229
-        $permission = $permission !== 'index' ? $permission : 'list';
230
-        if ($permission == 'method') 
231
-        {
232
-            $error = $this->errorHandler->notFound('method');
233
-            abort($error['status'], $error['message']);
234
-        }
235
-        else if ( ! in_array($permission, $this->skipLoginCheck)) 
236
-        {
237
-            if ( ! \Auth::check()) 
238
-            {
239
-                $error = $this->errorHandler->unAuthorized();
240
-                abort($error['status'], $error['message']);
241
-            }
242
-            else if ( ! in_array($permission, $this->skipPermissionCheck) && 
243
-                      ! \Core::users()->can($permission, $this->model))
244
-            {
245
-                $error = $this->errorHandler->noPermissions();
246
-                abort($error['status'], $error['message']);
247
-            }
248
-        }
249
-    }
199
+		$this->validate($request, $this->validationRules);
200
+
201
+		if ($this->model) 
202
+		{
203
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->save($request->all()), 200);
204
+		}
205
+	}
206
+
207
+	/**
208
+	 * Delete by the given id from model repository.
209
+	 * 
210
+	 * @param  integer  $id
211
+	 * @return \Illuminate\Http\Response
212
+	 */
213
+	public function getDelete($id) 
214
+	{
215
+		if ($this->model) 
216
+		{
217
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->delete($id), 200);
218
+		}
219
+	}
220
+
221
+	/**
222
+	 * Check if the logged in user can do the given permission.
223
+	 * 
224
+	 * @param  string $permission
225
+	 * @return void
226
+	 */
227
+	private function checkPermission($permission)
228
+	{
229
+		$permission = $permission !== 'index' ? $permission : 'list';
230
+		if ($permission == 'method') 
231
+		{
232
+			$error = $this->errorHandler->notFound('method');
233
+			abort($error['status'], $error['message']);
234
+		}
235
+		else if ( ! in_array($permission, $this->skipLoginCheck)) 
236
+		{
237
+			if ( ! \Auth::check()) 
238
+			{
239
+				$error = $this->errorHandler->unAuthorized();
240
+				abort($error['status'], $error['message']);
241
+			}
242
+			else if ( ! in_array($permission, $this->skipPermissionCheck) && 
243
+					  ! \Core::users()->can($permission, $this->model))
244
+			{
245
+				$error = $this->errorHandler->noPermissions();
246
+				abort($error['status'], $error['message']);
247
+			}
248
+		}
249
+	}
250 250
 }
Please login to merge, or discard this patch.
src/Modules/Core/Http/Controllers/SettingsController.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -8,20 +8,20 @@
 block discarded – undo
8 8
 
9 9
 class SettingsController 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               = 'settings';
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               = 'settings';
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',
25
-    'value' => 'required|string|max:100'
26
-    ];
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',
25
+	'value' => 'required|string|max:100'
26
+	];
27 27
 }
Please login to merge, or discard this patch.
src/Modules/Core/Database/Migrations/2016_01_24_123630_settings.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@
 block discarded – undo
13 13
 	public function up()
14 14
 	{
15 15
 		Schema::create('settings', function (Blueprint $table) {
16
-            $table->increments('id');
17
-            $table->string('name',100);
18
-            $table->string('key',100)->unique();
19
-            $table->string('value',100);
20
-            $table->softDeletes();
21
-            $table->timestamps();
22
-        });
16
+			$table->increments('id');
17
+			$table->string('name',100);
18
+			$table->string('key',100)->unique();
19
+			$table->string('value',100);
20
+			$table->softDeletes();
21
+			$table->timestamps();
22
+		});
23 23
 	}
24 24
 
25 25
 	/**
Please login to merge, or discard this patch.
src/Modules/Logging/Log.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -5,40 +5,40 @@
 block discarded – undo
5 5
 
6 6
 class Log extends Model{
7 7
 
8
-    use SoftDeletes;
9
-    protected $table    = 'logs';
10
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
-    protected $hidden   = ['deleted_at', 'item_type'];
12
-    protected $guarded  = ['id'];
13
-    protected $fillable = ['action', 'item_name', 'item_type', 'item_id', 'user_id'];
14
-
15
-    public function getCreatedAtAttribute($value)
16
-    {
17
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
18
-    }
19
-
20
-    public function getUpdatedAtAttribute($value)
21
-    {
22
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
23
-    }
24
-
25
-    public function getDeletedAtAttribute($value)
26
-    {
27
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
28
-    }
8
+	use SoftDeletes;
9
+	protected $table    = 'logs';
10
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
+	protected $hidden   = ['deleted_at', 'item_type'];
12
+	protected $guarded  = ['id'];
13
+	protected $fillable = ['action', 'item_name', 'item_type', 'item_id', 'user_id'];
14
+
15
+	public function getCreatedAtAttribute($value)
16
+	{
17
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
18
+	}
19
+
20
+	public function getUpdatedAtAttribute($value)
21
+	{
22
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
23
+	}
24
+
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\Acl\AclUser');
33
-    }
34
-
35
-    public function item()
36
-    {
37
-        return $this->morphTo();
38
-    }
39
-
40
-    public static function boot()
41
-    {
42
-        parent::boot();
43
-    }
30
+	public function user()
31
+	{
32
+		return $this->belongsTo('App\Modules\Acl\AclUser');
33
+	}
34
+
35
+	public function item()
36
+	{
37
+		return $this->morphTo();
38
+	}
39
+
40
+	public static function boot()
41
+	{
42
+		parent::boot();
43
+	}
44 44
 }
Please login to merge, or discard this patch.
src/Modules/Logging/Http/Controllers/LogsController.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@
 block discarded – undo
8 8
 class LogsController 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            = 'logs';
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            = 'logs';
16 16
 }
Please login to merge, or discard this patch.
src/Modules/Reports/Repositories/ReportRepository.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -15,55 +15,55 @@
 block discarded – undo
15 15
 	}
16 16
 
17 17
 	/**
18
-     * Render the given report db view.
19
-     * 
20
-     * @param  integer $id
21
-     * @param  array   $relations
22
-     * @param  array   $columns
23
-     * @return object
24
-     */
25
-    public function find($id, $relations = [], $columns = array('*'))
26
-    {
18
+	 * Render the given report db view.
19
+	 * 
20
+	 * @param  integer $id
21
+	 * @param  array   $relations
22
+	 * @param  array   $columns
23
+	 * @return object
24
+	 */
25
+	public function find($id, $relations = [], $columns = array('*'))
26
+	{
27 27
 		$report = call_user_func_array("{$this->getModel()}::with", array($relations))->find($id, $columns);
28 28
 
29
-        if ( ! \Core::users()->can($report->view_name, 'reports'))
30
-        {
31
-            $error = $this->errorHandler->noPermissions();
32
-            abort($error['status'], $error['message']);
33
-        }
29
+		if ( ! \Core::users()->can($report->view_name, 'reports'))
30
+		{
31
+			$error = $this->errorHandler->noPermissions();
32
+			abort($error['status'], $error['message']);
33
+		}
34 34
 
35 35
 		if ( ! $report) 
36 36
 		{
37 37
 			$error = $this->errorHandler->notFound('report');
38 38
 			abort($error['status'], $error['message']);
39 39
 		}
40
-        return \DB::table($report->view_name)->get();
41
-    }
40
+		return \DB::table($report->view_name)->get();
41
+	}
42 42
 
43
-    /**
44
-     * Render the given report db view based on the given
45
-     * condition.
46
-     *
47
-     * @param  array   $conditions array of conditions
48
-     * @param  array   $relations
49
-     * @param  array   $colunmns
50
-     * @return object
51
-     */
52
-    public function first($conditions, $relations = [], $columns = array('*'))
53
-    {
43
+	/**
44
+	 * Render the given report db view based on the given
45
+	 * condition.
46
+	 *
47
+	 * @param  array   $conditions array of conditions
48
+	 * @param  array   $relations
49
+	 * @param  array   $colunmns
50
+	 * @return object
51
+	 */
52
+	public function first($conditions, $relations = [], $columns = array('*'))
53
+	{
54 54
 		$conditions = $this->constructConditions($conditions);
55 55
 		$report     = call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->first($columns);
56 56
         
57
-        if ( ! \Core::users()->can($report->view_name, 'reports'))
58
-        {
59
-            $error = $this->errorHandler->noPermissions();
60
-            abort($error['status'], $error['message']);
61
-        }
57
+		if ( ! \Core::users()->can($report->view_name, 'reports'))
58
+		{
59
+			$error = $this->errorHandler->noPermissions();
60
+			abort($error['status'], $error['message']);
61
+		}
62 62
 		if ( ! $report) 
63 63
 		{
64 64
 			$error = $this->errorHandler->notFound('report');
65 65
 			abort($error['status'], $error['message']);
66 66
 		}
67
-        return \DB::table($report->view_name)->get();  
68
-    }
67
+		return \DB::table($report->view_name)->get();  
68
+	}
69 69
 }
Please login to merge, or discard this patch.
src/Modules/Reports/Http/Controllers/ReportsController.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,16 +8,16 @@
 block discarded – undo
8 8
 class ReportsController 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            = 'reports';
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            = 'reports';
16 16
 
17
-    /**
18
-     * List of all route actions that the base api controller
19
-     * will skip permissions check for them.
20
-     * @var array
21
-     */
22
-    protected $skipPermissionCheck = ['find', 'first'];
17
+	/**
18
+	 * List of all route actions that the base api controller
19
+	 * will skip permissions check for them.
20
+	 * @var array
21
+	 */
22
+	protected $skipPermissionCheck = ['find', 'first'];
23 23
 }
Please login to merge, or discard this patch.
src/Modules/Reports/Report.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 
6 6
 class Report extends Model{
7 7
 
8
-    use SoftDeletes;
8
+	use SoftDeletes;
9 9
 	protected $table    = 'reports';
10 10
 	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11 11
 	protected $hidden   = ['deleted_at'];
@@ -13,22 +13,22 @@  discard block
 block discarded – undo
13 13
 	protected $fillable = ['report_name', 'view_name'];
14 14
 
15 15
 	public function getCreatedAtAttribute($value)
16
-    {
17
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
18
-    }
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 static function boot()
31
-    {
32
-        parent::boot();
33
-    }
30
+	public static function boot()
31
+	{
32
+		parent::boot();
33
+	}
34 34
 }
Please login to merge, or discard this patch.