@@ -22,7 +22,7 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | public function saveMany(array $data) |
| 24 | 24 | { |
| 25 | - \DB::transaction(function () use ($data) { |
|
| 25 | + \DB::transaction(function() use ($data) { |
|
| 26 | 26 | foreach ($data as $key => $value) |
| 27 | 27 | { |
| 28 | 28 | $this->save($value); |
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | { |
| 14 | 14 | $response = []; |
| 15 | 15 | $image = $image; |
| 16 | - $imageName = str_slug('image' . uniqid() . time() . '_' . $image->getClientOriginalName()); |
|
| 17 | - $destinationPath = 'media' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR; |
|
| 16 | + $imageName = str_slug('image'.uniqid().time().'_'.$image->getClientOriginalName()); |
|
| 17 | + $destinationPath = 'media'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR; |
|
| 18 | 18 | |
| 19 | 19 | ! file_exists($destinationPath) ? \File::makeDirectory($destinationPath) : false; |
| 20 | 20 | $image->move($destinationPath, $imageName); |
| 21 | 21 | |
| 22 | - return url($destinationPath . $imageName); |
|
| 22 | + return url($destinationPath.$imageName); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -31,22 +31,22 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function uploadImageBas64($image, $dir) |
| 33 | 33 | { |
| 34 | - if (! strlen($image)) |
|
| 34 | + if ( ! strlen($image)) |
|
| 35 | 35 | { |
| 36 | 36 | return null; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $response = []; |
| 40 | 40 | $image = $image; |
| 41 | - $imageName = 'image' . uniqid() . time() . '.jpg'; |
|
| 42 | - $destinationPath = 'media' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR; |
|
| 41 | + $imageName = 'image'.uniqid().time().'.jpg'; |
|
| 42 | + $destinationPath = 'media'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR; |
|
| 43 | 43 | |
| 44 | 44 | ! file_exists($destinationPath) ? \File::makeDirectory($destinationPath) : false; |
| 45 | 45 | |
| 46 | 46 | $base = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $image)); |
| 47 | - $image = \Image::make($base)->save($destinationPath . $imageName); |
|
| 47 | + $image = \Image::make($base)->save($destinationPath.$imageName); |
|
| 48 | 48 | |
| 49 | - return url($destinationPath . $imageName); |
|
| 49 | + return url($destinationPath.$imageName); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | public function deleteImage($path, $dir) |
| 60 | 60 | { |
| 61 | 61 | $arr = explode('/', $path); |
| 62 | - $path = 'media' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . end($arr); |
|
| 62 | + $path = 'media'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.end($arr); |
|
| 63 | 63 | if (\File::exists($path)) |
| 64 | 64 | { |
| 65 | 65 | \File::delete($path); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $route['response'] = $this->getResponseObject($classProperties['model'], $route['name'], $route['returnDocBlock']); |
| 63 | 63 | |
| 64 | 64 | preg_match('/api\/v1\/([^#]+)\//iU', $route['uri'], $module); |
| 65 | - $docData['modules'][$module[1]][substr($route['prefix'], strlen('/api/v1/' . $module[1] . '/') - 1)][] = $route; |
|
| 65 | + $docData['modules'][$module[1]][substr($route['prefix'], strlen('/api/v1/'.$module[1].'/') - 1)][] = $route; |
|
| 66 | 66 | |
| 67 | 67 | $this->getModels($classProperties['model'], $docData); |
| 68 | 68 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | protected function getRoutes() |
| 81 | 81 | { |
| 82 | - return collect(\Route::getRoutes())->map(function ($route) { |
|
| 82 | + return collect(\Route::getRoutes())->map(function($route) { |
|
| 83 | 83 | if (strpos($route->uri(), 'api/v') !== false) |
| 84 | 84 | { |
| 85 | 85 | return [ |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | ]; |
| 112 | 112 | |
| 113 | 113 | |
| 114 | - if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) |
|
| 114 | + if ( ! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) |
|
| 115 | 115 | { |
| 116 | 116 | $route['headers']['Authorization'] = 'Bearer {token}'; |
| 117 | 117 | } |
@@ -165,16 +165,16 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | else |
| 167 | 167 | { |
| 168 | - $route['body'] = eval('return ' . str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]) . ';'); |
|
| 168 | + $route['body'] = eval('return '.str_replace(',\'.$request->get(\'id\')', ',{id}\'', $match[1]).';'); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | foreach ($route['body'] as &$rule) |
| 172 | 172 | { |
| 173 | - if(strpos($rule, 'unique')) |
|
| 173 | + if (strpos($rule, 'unique')) |
|
| 174 | 174 | { |
| 175 | 175 | $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
| 176 | 176 | } |
| 177 | - elseif(strpos($rule, 'exists')) |
|
| 177 | + elseif (strpos($rule, 'exists')) |
|
| 178 | 178 | { |
| 179 | 179 | $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
| 180 | 180 | } |
@@ -247,10 +247,10 @@ discard block |
||
| 247 | 247 | $model = factory($modelClass)->make(); |
| 248 | 248 | $modelArr = $model->toArray(); |
| 249 | 249 | |
| 250 | - if ( $model->trans && ! $model->trans->count()) |
|
| 250 | + if ($model->trans && ! $model->trans->count()) |
|
| 251 | 251 | { |
| 252 | 252 | $modelArr['trans'] = [ |
| 253 | - 'en' => factory($modelClass . 'Translation')->make()->toArray() |
|
| 253 | + 'en' => factory($modelClass.'Translation')->make()->toArray() |
|
| 254 | 254 | ]; |
| 255 | 255 | } |
| 256 | 256 | |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | $this->validationRules = property_exists($this, 'validationRules') ? $this->validationRules : false; |
| 35 | 35 | $this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : []; |
| 36 | 36 | $this->skipLoginCheck = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : []; |
| 37 | - $route = explode('@',\Route::currentRouteAction())[1]; |
|
| 37 | + $route = explode('@', \Route::currentRouteAction())[1]; |
|
| 38 | 38 | |
| 39 | - $this->middleware(function ($request, $next) { |
|
| 39 | + $this->middleware(function($request, $next) { |
|
| 40 | 40 | |
| 41 | 41 | $this->repo = call_user_func_array("\Core::{$this->model}", []); |
| 42 | 42 | return $next($request); |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->model))) |
| 230 | 230 | {} |
| 231 | - elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
| 231 | + elseif ( ! $isPasswordClient && $user->tokenCan($this->model.'-'.$permission)) |
|
| 232 | 232 | {} |
| 233 | 233 | else |
| 234 | 234 | { |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * to preform actions like (add, edit ... etc). |
| 14 | 14 | * @var string |
| 15 | 15 | */ |
| 16 | - protected $model = 'users'; |
|
| 16 | + protected $model = 'users'; |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * List of all route actions that the base api controller |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | * will skip login check for them. |
| 28 | 28 | * @var array |
| 29 | 29 | */ |
| 30 | - protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken', 'confirmEmail', 'resendEmailConfirmation']; |
|
| 30 | + protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken', 'confirmEmail', 'resendEmailConfirmation']; |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * The validations rules used by the base api controller |
| 34 | 34 | * to check before add. |
| 35 | 35 | * @var array |
| 36 | 36 | */ |
| 37 | - protected $validationRules = [ |
|
| 37 | + protected $validationRules = [ |
|
| 38 | 38 | 'name' => 'nullable|string', |
| 39 | 39 | 'email' => 'required|email|unique:users,email,{id}', |
| 40 | 40 | 'password' => 'nullable|min:6' |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | $this->validate($request, [ |
| 282 | 282 | 'profile_picture' => 'nullable|base64image', |
| 283 | 283 | 'name' => 'nullable|string', |
| 284 | - 'email' => 'required|email|unique:users,email,' . \Auth::id() |
|
| 284 | + 'email' => 'required|email|unique:users,email,'.\Auth::id() |
|
| 285 | 285 | ]); |
| 286 | 286 | |
| 287 | 287 | return \Response::json($this->repo->saveProfile($request->only('name', 'email', 'profile_picture')), 200); |