Completed
Push — master ( 4b6f70...bf5864 )
by Sherif
02:04
created
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.
src/Modules/Core/Resources/Lang/en/errors.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -2,15 +2,15 @@
 block discarded – undo
2 2
 
3 3
 return [
4 4
     
5
-    /**
6
-     * Here goes your error messages.
7
-     */
8
-    'connectionError'         => 'Connection error',
9
-    'redisNotRunning'         => 'Your redis notification server is\'t running',
10
-    'dbQueryError'            => 'Please check the given inputes',
11
-    'cannotCreateSetting'     => 'Can\'t create setting',
12
-    'cannotUpdateSettingKey'  => 'Can\'t update setting key',
13
-    'notFound'                => 'The requested :replace not found',
14
-    'cannotUploadImage'       => 'Can\'t upload the given image'
5
+	/**
6
+	 * Here goes your error messages.
7
+	 */
8
+	'connectionError'         => 'Connection error',
9
+	'redisNotRunning'         => 'Your redis notification server is\'t running',
10
+	'dbQueryError'            => 'Please check the given inputes',
11
+	'cannotCreateSetting'     => 'Can\'t create setting',
12
+	'cannotUpdateSettingKey'  => 'Can\'t update setting key',
13
+	'notFound'                => 'The requested :replace not found',
14
+	'cannotUploadImage'       => 'Can\'t upload the given image'
15 15
 
16 16
 ];
Please login to merge, or discard this patch.
src/Modules/Core/Resources/Lang/ar/errors.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -2,15 +2,15 @@
 block discarded – undo
2 2
 
3 3
 return [
4 4
     
5
-    /**
6
-     * Here goes your error messages.
7
-     */
8
-    'connectionError'         => 'خطأ في الاتصال',
9
-    'redisNotRunning'         => 'سيرفير الاشعارات لايعمل',
10
-    'dbQueryError'            => 'خطا في البيانات',
11
-    'cannotCreateSetting'     => 'لا يمكن اضافة اعدادات',
12
-    'cannotUpdateSettingKey'  => 'لا يمكن تعديل اعدادات',
13
-    'notFound'                => 'ال :replace المطلوب غير موجود',
14
-    'cannotUploadImage'       => 'لا يمكن رفع هذه الصورة'
5
+	/**
6
+	 * Here goes your error messages.
7
+	 */
8
+	'connectionError'         => 'خطأ في الاتصال',
9
+	'redisNotRunning'         => 'سيرفير الاشعارات لايعمل',
10
+	'dbQueryError'            => 'خطا في البيانات',
11
+	'cannotCreateSetting'     => 'لا يمكن اضافة اعدادات',
12
+	'cannotUpdateSettingKey'  => 'لا يمكن تعديل اعدادات',
13
+	'notFound'                => 'ال :replace المطلوب غير موجود',
14
+	'cannotUploadImage'       => 'لا يمكن رفع هذه الصورة'
15 15
 
16 16
 ];
Please login to merge, or discard this patch.
src/Modules/Core/BaseClasses/BaseApiController.php 1 patch
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -9,109 +9,109 @@
 block discarded – undo
9 9
 
10 10
 class BaseApiController extends Controller
11 11
 {
12
-    /**
13
-     * Array of eager loaded relations.
14
-     *
15
-     * @var array
16
-     */
17
-    protected $relations;
12
+	/**
13
+	 * Array of eager loaded relations.
14
+	 *
15
+	 * @var array
16
+	 */
17
+	protected $relations;
18 18
 
19
-    /**
20
-     * @var object
21
-     */
22
-    protected $service;
19
+	/**
20
+	 * @var object
21
+	 */
22
+	protected $service;
23 23
 
24
-    /**
25
-     * Path of the model resource.
26
-     *
27
-     * @var string
28
-     */
29
-    protected $modelResource;
24
+	/**
25
+	 * Path of the model resource.
26
+	 *
27
+	 * @var string
28
+	 */
29
+	protected $modelResource;
30 30
 
31
-    /**
32
-     * Path of the sotre form request.
33
-     *
34
-     * @var string
35
-     */
36
-    protected $storeFormRequest;
31
+	/**
32
+	 * Path of the sotre form request.
33
+	 *
34
+	 * @var string
35
+	 */
36
+	protected $storeFormRequest;
37 37
 
38
-    /**
39
-     * Init new object.
40
-     *
41
-     * @param   mixed      $service
42
-     * @return  void
43
-     */
44
-    public function __construct($service)
45
-    {
46
-        $this->service = new CachingDecorator($service, \App::make('Illuminate\Contracts\Cache\Repository'));
47
-    }
38
+	/**
39
+	 * Init new object.
40
+	 *
41
+	 * @param   mixed      $service
42
+	 * @return  void
43
+	 */
44
+	public function __construct($service)
45
+	{
46
+		$this->service = new CachingDecorator($service, \App::make('Illuminate\Contracts\Cache\Repository'));
47
+	}
48 48
 
49
-    /**
50
-     * Fetch all records with relations from storage.
51
-     *
52
-     * @param Request $request
53
-     * @return \Illuminate\Http\Response
54
-     */
55
-    public function index(Request $request)
56
-    {
57
-        return $this->modelResource::collection($this->service->list($request->relations, $request->query(), $request->query('perPage'), $request->query('sortBy'), $request->query('desc'), $request->query('trashed')));
58
-    }
49
+	/**
50
+	 * Fetch all records with relations from storage.
51
+	 *
52
+	 * @param Request $request
53
+	 * @return \Illuminate\Http\Response
54
+	 */
55
+	public function index(Request $request)
56
+	{
57
+		return $this->modelResource::collection($this->service->list($request->relations, $request->query(), $request->query('perPage'), $request->query('sortBy'), $request->query('desc'), $request->query('trashed')));
58
+	}
59 59
 
60
-    /**
61
-     * Fetch the single object with relations from storage.
62
-     *
63
-     * @param  Request $request
64
-     * @param  integer $id Id of the requested model.
65
-     * @return \Illuminate\Http\Response
66
-     */
67
-    public function show(Request $request, $id)
68
-    {
69
-        return new $this->modelResource($this->service->find($id, $request->relations));
70
-    }
60
+	/**
61
+	 * Fetch the single object with relations from storage.
62
+	 *
63
+	 * @param  Request $request
64
+	 * @param  integer $id Id of the requested model.
65
+	 * @return \Illuminate\Http\Response
66
+	 */
67
+	public function show(Request $request, $id)
68
+	{
69
+		return new $this->modelResource($this->service->find($id, $request->relations));
70
+	}
71 71
 
72
-    /**
73
-     * Insert the given model to storage.
74
-     *
75
-     * @return \Illuminate\Http\Response
76
-     */
77
-    public function store()
78
-    {
79
-        $data = \App::make($this->storeFormRequest)->validated();
80
-        return new $this->modelResource($this->service->save($data));
81
-    }
72
+	/**
73
+	 * Insert the given model to storage.
74
+	 *
75
+	 * @return \Illuminate\Http\Response
76
+	 */
77
+	public function store()
78
+	{
79
+		$data = \App::make($this->storeFormRequest)->validated();
80
+		return new $this->modelResource($this->service->save($data));
81
+	}
82 82
 
83
-    /**
84
-     * Update the given model to storage.
85
-     *
86
-     * @param integer   $id
87
-     * @return \Illuminate\Http\Response
88
-     */
89
-    public function update($id)
90
-    {
91
-        $data = \App::make($this->storeFormRequest)->validated();
92
-        $data['id'] = $id;
93
-        return new $this->modelResource($this->service->save($data));
94
-    }
83
+	/**
84
+	 * Update the given model to storage.
85
+	 *
86
+	 * @param integer   $id
87
+	 * @return \Illuminate\Http\Response
88
+	 */
89
+	public function update($id)
90
+	{
91
+		$data = \App::make($this->storeFormRequest)->validated();
92
+		$data['id'] = $id;
93
+		return new $this->modelResource($this->service->save($data));
94
+	}
95 95
 
96
-    /**
97
-     * Delete by the given id from storage.
98
-     *
99
-     * @param  integer $id Id of the deleted model.
100
-     * @return \Illuminate\Http\Response
101
-     */
102
-    public function destroy($id)
103
-    {
104
-        return new GeneralResource($this->service->delete($id));
105
-    }
96
+	/**
97
+	 * Delete by the given id from storage.
98
+	 *
99
+	 * @param  integer $id Id of the deleted model.
100
+	 * @return \Illuminate\Http\Response
101
+	 */
102
+	public function destroy($id)
103
+	{
104
+		return new GeneralResource($this->service->delete($id));
105
+	}
106 106
 
107
-    /**
108
-     * Restore the deleted model.
109
-     *
110
-     * @param  integer $id Id of the restored model.
111
-     * @return \Illuminate\Http\Response
112
-     */
113
-    public function restore($id)
114
-    {
115
-        return new GeneralResource($this->service->restore($id));
116
-    }
107
+	/**
108
+	 * Restore the deleted model.
109
+	 *
110
+	 * @param  integer $id Id of the restored model.
111
+	 * @return \Illuminate\Http\Response
112
+	 */
113
+	public function restore($id)
114
+	{
115
+		return new GeneralResource($this->service->restore($id));
116
+	}
117 117
 }
Please login to merge, or discard this patch.
src/Modules/Core/Decorators/CachingDecorator.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
         if ($this->cacheConfig && $this->cacheConfig == 'cache') {
77 77
             $page     = \Request::get('page') !== null ? \Request::get('page') : '1';
78 78
             $cacheKey = $name.$page.\Session::get('locale').serialize($arguments);
79
-            return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function () use ($arguments, $name) {
79
+            return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) {
80 80
                 return call_user_func_array([$this->service, $name], $arguments);
81 81
             });
82 82
         } elseif ($this->cacheConfig) {
Please login to merge, or discard this patch.
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -7,84 +7,84 @@
 block discarded – undo
7 7
 
8 8
 class CachingDecorator
9 9
 {
10
-    /**
11
-     * @var String
12
-     */
13
-    public $service;
10
+	/**
11
+	 * @var String
12
+	 */
13
+	public $service;
14 14
 
15
-    /**
16
-     * @var Cache
17
-     */
18
-    protected $cache;
15
+	/**
16
+	 * @var Cache
17
+	 */
18
+	protected $cache;
19 19
 
20
-    /**
21
-     * @var mixed
22
-     */
23
-    public $cacheConfig;
20
+	/**
21
+	 * @var mixed
22
+	 */
23
+	public $cacheConfig;
24 24
 
25
-    /**
26
-     * @var string
27
-     */
28
-    public $cacheTag;
25
+	/**
26
+	 * @var string
27
+	 */
28
+	public $cacheTag;
29 29
     
30
-    /**
31
-     * Init new object.
32
-     *
33
-     * @param  Object $service
34
-     * @param  Cache  $cache
35
-     *
36
-     * @return  void
37
-     */
38
-    public function __construct($service, Cache $cache)
39
-    {
40
-        $this->service    = $service;
41
-        $this->cache      = $cache;
42
-        $serviceClass     = explode('\\', get_class($this->service));
43
-        $serviceName      = end($serviceClass);
44
-        $this->cacheTag   = lcfirst(substr($serviceName, 0, strpos($serviceName, 'Service')));
45
-    }
30
+	/**
31
+	 * Init new object.
32
+	 *
33
+	 * @param  Object $service
34
+	 * @param  Cache  $cache
35
+	 *
36
+	 * @return  void
37
+	 */
38
+	public function __construct($service, Cache $cache)
39
+	{
40
+		$this->service    = $service;
41
+		$this->cache      = $cache;
42
+		$serviceClass     = explode('\\', get_class($this->service));
43
+		$serviceName      = end($serviceClass);
44
+		$this->cacheTag   = lcfirst(substr($serviceName, 0, strpos($serviceName, 'Service')));
45
+	}
46 46
 
47
-    /**
48
-     * Handle the cache mechanism for the called method
49
-     * based the configurations.
50
-     *
51
-     * @param  string $name the called method name
52
-     * @param  array  $arguments the method arguments
53
-     * @return object
54
-     */
55
-    public function __call($name, $arguments)
56
-    {
57
-        $this->setCacheConfig($name);
47
+	/**
48
+	 * Handle the cache mechanism for the called method
49
+	 * based the configurations.
50
+	 *
51
+	 * @param  string $name the called method name
52
+	 * @param  array  $arguments the method arguments
53
+	 * @return object
54
+	 */
55
+	public function __call($name, $arguments)
56
+	{
57
+		$this->setCacheConfig($name);
58 58
 
59
-        if ($this->cacheConfig && $this->cacheConfig == 'cache') {
60
-            $page     = \Request::get('page') !== null ? \Request::get('page') : '1';
61
-            $cacheKey = $name.$page.\Session::get('locale').serialize($arguments);
62
-            return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function () use ($arguments, $name) {
63
-                return call_user_func_array([$this->service, $name], $arguments);
64
-            });
65
-        } elseif ($this->cacheConfig) {
66
-            $this->cache->tags($this->cacheConfig)->flush();
67
-            return call_user_func_array([$this->service, $name], $arguments);
68
-        }
59
+		if ($this->cacheConfig && $this->cacheConfig == 'cache') {
60
+			$page     = \Request::get('page') !== null ? \Request::get('page') : '1';
61
+			$cacheKey = $name.$page.\Session::get('locale').serialize($arguments);
62
+			return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function () use ($arguments, $name) {
63
+				return call_user_func_array([$this->service, $name], $arguments);
64
+			});
65
+		} elseif ($this->cacheConfig) {
66
+			$this->cache->tags($this->cacheConfig)->flush();
67
+			return call_user_func_array([$this->service, $name], $arguments);
68
+		}
69 69
 
70
-        return call_user_func_array([$this->service, $name], $arguments);
71
-    }
70
+		return call_user_func_array([$this->service, $name], $arguments);
71
+	}
72 72
 
73
-    /**
74
-     * Set cache config based on the called method.
75
-     *
76
-     * @param  string $name
77
-     * @return void
78
-     */
79
-    private function setCacheConfig($name)
80
-    {
81
-        $cacheConfig       = Arr::get(config('core.cache_config'), $this->cacheTag, false);
82
-        $this->cacheConfig = false;
73
+	/**
74
+	 * Set cache config based on the called method.
75
+	 *
76
+	 * @param  string $name
77
+	 * @return void
78
+	 */
79
+	private function setCacheConfig($name)
80
+	{
81
+		$cacheConfig       = Arr::get(config('core.cache_config'), $this->cacheTag, false);
82
+		$this->cacheConfig = false;
83 83
 
84
-        if ($cacheConfig && in_array($name, $cacheConfig['cache'])) {
85
-            $this->cacheConfig = 'cache';
86
-        } elseif ($cacheConfig && isset($cacheConfig['clear'][$name])) {
87
-            $this->cacheConfig = $cacheConfig['clear'][$name];
88
-        }
89
-    }
84
+		if ($cacheConfig && in_array($name, $cacheConfig['cache'])) {
85
+			$this->cacheConfig = 'cache';
86
+		} elseif ($cacheConfig && isset($cacheConfig['clear'][$name])) {
87
+			$this->cacheConfig = $cacheConfig['clear'][$name];
88
+		}
89
+	}
90 90
 }
Please login to merge, or discard this patch.
src/Modules/Core/Utl/Media.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -4,70 +4,70 @@
 block discarded – undo
4 4
 
5 5
 class Media
6 6
 {
7
-    /**
8
-     * Upload the given image.
9
-     *
10
-     * @param  object  $image
11
-     * @param  string  $dir
12
-     * @return string
13
-     */
14
-    public function uploadImage($image, $dir)
15
-    {
16
-        $image = \Image::make($image);
17
-        return $this->saveImage($image, $dir);
18
-    }
7
+	/**
8
+	 * Upload the given image.
9
+	 *
10
+	 * @param  object  $image
11
+	 * @param  string  $dir
12
+	 * @return string
13
+	 */
14
+	public function uploadImage($image, $dir)
15
+	{
16
+		$image = \Image::make($image);
17
+		return $this->saveImage($image, $dir);
18
+	}
19 19
 
20
-    /**
21
-     * Upload the given image.
22
-     *
23
-     * @param  object  $image
24
-     * @param  string  $dir
25
-     * @return string
26
-     */
27
-    public function uploadImageBas64($image, $dir)
28
-    {
29
-        if (! strlen($image)) {
30
-            return null;
31
-        }
20
+	/**
21
+	 * Upload the given image.
22
+	 *
23
+	 * @param  object  $image
24
+	 * @param  string  $dir
25
+	 * @return string
26
+	 */
27
+	public function uploadImageBas64($image, $dir)
28
+	{
29
+		if (! strlen($image)) {
30
+			return null;
31
+		}
32 32
 
33
-        if(filter_var($image, FILTER_VALIDATE_URL)) {
34
-            return $image;
35
-        }
33
+		if(filter_var($image, FILTER_VALIDATE_URL)) {
34
+			return $image;
35
+		}
36 36
         
37
-        try {
38
-            $base  = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $image));
39
-            $image = \Image::make($base);
40
-        } catch (\Exception $e) {
41
-            \Errors::cannotUploadImage();
42
-        }
37
+		try {
38
+			$base  = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $image));
39
+			$image = \Image::make($base);
40
+		} catch (\Exception $e) {
41
+			\Errors::cannotUploadImage();
42
+		}
43 43
 
44
-        return $this->saveImage($image, $dir);
45
-    }
44
+		return $this->saveImage($image, $dir);
45
+	}
46 46
 
47
-    /**
48
-     * Delete the given image.
49
-     *
50
-     * @param  object $path
51
-     * @return void
52
-     */
53
-    public function deleteImage($path)
54
-    {
55
-        \Storage::delete($path);
56
-    }
47
+	/**
48
+	 * Delete the given image.
49
+	 *
50
+	 * @param  object $path
51
+	 * @return void
52
+	 */
53
+	public function deleteImage($path)
54
+	{
55
+		\Storage::delete($path);
56
+	}
57 57
 
58
-    /**
59
-     * Save the given image.
60
-     *
61
-     * @param  object  $image
62
-     * @param  string  $dir
63
-     * @return string
64
-     */
65
-    protected function saveImage($image, $dir)
66
-    {
67
-        $imageName = 'image'.uniqid().time().'.jpg';
68
-        $path      = 'public'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.$imageName;
69
-        \Storage::put($path, $image->stream());
58
+	/**
59
+	 * Save the given image.
60
+	 *
61
+	 * @param  object  $image
62
+	 * @param  string  $dir
63
+	 * @return string
64
+	 */
65
+	protected function saveImage($image, $dir)
66
+	{
67
+		$imageName = 'image'.uniqid().time().'.jpg';
68
+		$path      = 'public'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.$imageName;
69
+		\Storage::put($path, $image->stream());
70 70
 
71
-        return $path;
72
-    }
71
+		return $path;
72
+	}
73 73
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@
 block discarded – undo
26 26
      */
27 27
     public function uploadImageBas64($image, $dir)
28 28
     {
29
-        if (! strlen($image)) {
29
+        if ( ! strlen($image)) {
30 30
             return null;
31 31
         }
32 32
 
33
-        if(filter_var($image, FILTER_VALIDATE_URL)) {
33
+        if (filter_var($image, FILTER_VALIDATE_URL)) {
34 34
             return $image;
35 35
         }
36 36
         
Please login to merge, or discard this patch.
src/Modules/Core/Errors/CoreErrors.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -4,38 +4,38 @@
 block discarded – undo
4 4
 
5 5
 class CoreErrors
6 6
 {
7
-    public function connectionError()
8
-    {
9
-        abort(500, trans('core::errors.connectionError'));
10
-    }
11
-
12
-    public function redisNotRunning()
13
-    {
14
-        abort(500, trans('core::errors.redisNotRunning'));
15
-    }
16
-
17
-    public function dbQueryError()
18
-    {
19
-        abort(500, trans('core::errors.dbQueryError'));
20
-    }
21
-
22
-    public function cannotCreateSetting()
23
-    {
24
-        abort(400, trans('core::errors.cannotCreateSetting'));
25
-    }
26
-
27
-    public function cannotUpdateSettingKey()
28
-    {
29
-        abort(400, trans('core::errors.cannotUpdateSettingKey'));
30
-    }
31
-
32
-    public function notFound($text)
33
-    {
34
-        abort(404, trans('core::errors.notFound', ['replace' => $text]));
35
-    }
36
-
37
-    public function cannotUploadImage()
38
-    {
39
-        abort(400, trans('core::errors.cannotUploadImage'));
40
-    }
7
+	public function connectionError()
8
+	{
9
+		abort(500, trans('core::errors.connectionError'));
10
+	}
11
+
12
+	public function redisNotRunning()
13
+	{
14
+		abort(500, trans('core::errors.redisNotRunning'));
15
+	}
16
+
17
+	public function dbQueryError()
18
+	{
19
+		abort(500, trans('core::errors.dbQueryError'));
20
+	}
21
+
22
+	public function cannotCreateSetting()
23
+	{
24
+		abort(400, trans('core::errors.cannotCreateSetting'));
25
+	}
26
+
27
+	public function cannotUpdateSettingKey()
28
+	{
29
+		abort(400, trans('core::errors.cannotUpdateSettingKey'));
30
+	}
31
+
32
+	public function notFound($text)
33
+	{
34
+		abort(404, trans('core::errors.notFound', ['replace' => $text]));
35
+	}
36
+
37
+	public function cannotUploadImage()
38
+	{
39
+		abort(400, trans('core::errors.cannotUploadImage'));
40
+	}
41 41
 }
Please login to merge, or discard this patch.
src/Modules/Core/Console/Commands/PassportInstallCommand.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
 
8 8
 class PassportInstallCommand extends Command
9 9
 {
10
-    /**
11
-     * The name and signature of the console command.
12
-     *
13
-     * @var string
14
-     */
15
-    protected $signature = 'module:passport:install
10
+	/**
11
+	 * The name and signature of the console command.
12
+	 *
13
+	 * @var string
14
+	 */
15
+	protected $signature = 'module:passport:install
16 16
                             {--force : Overwrite keys they already exist}
17 17
                             {--length=4096 : The length of the private key}';
18 18
 
19
-    /**
20
-     * The console command description.
21
-     *
22
-     * @var string
23
-     */
24
-    protected $description = 'Run the commands necessary to prepare Passport for use';
19
+	/**
20
+	 * The console command description.
21
+	 *
22
+	 * @var string
23
+	 */
24
+	protected $description = 'Run the commands necessary to prepare Passport for use';
25 25
 
26
-    /**
27
-     * Execute the console command.
28
-     *
29
-     * @return void
30
-     */
31
-    public function handle(ClientRepository $client)
32
-    {
33
-        $this->call('passport:keys', ['--force' => $this->option('force'), '--length' => $this->option('length')]);
34
-        $oauthClient = \Core::oauthCLients()->first(['password_client' => 1]);
35
-        if (! $oauthClient) {
36
-            $oauthClient = $client->createPasswordGrantClient(
37
-                null,
38
-                config('app.name'),
39
-                'http://localhost'
40
-            );
41
-        }
42
-        \DotenvEditor::setKey('PASSWORD_CLIENT_ID', $oauthClient->id);
43
-        \DotenvEditor::setKey('PASSWORD_CLIENT_SECRET', $oauthClient->secret);
44
-        \DotenvEditor::save();
45
-    }
26
+	/**
27
+	 * Execute the console command.
28
+	 *
29
+	 * @return void
30
+	 */
31
+	public function handle(ClientRepository $client)
32
+	{
33
+		$this->call('passport:keys', ['--force' => $this->option('force'), '--length' => $this->option('length')]);
34
+		$oauthClient = \Core::oauthCLients()->first(['password_client' => 1]);
35
+		if (! $oauthClient) {
36
+			$oauthClient = $client->createPasswordGrantClient(
37
+				null,
38
+				config('app.name'),
39
+				'http://localhost'
40
+			);
41
+		}
42
+		\DotenvEditor::setKey('PASSWORD_CLIENT_ID', $oauthClient->id);
43
+		\DotenvEditor::setKey('PASSWORD_CLIENT_SECRET', $oauthClient->secret);
44
+		\DotenvEditor::save();
45
+	}
46 46
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
     {
33 33
         $this->call('passport:keys', ['--force' => $this->option('force'), '--length' => $this->option('length')]);
34 34
         $oauthClient = \Core::oauthCLients()->first(['password_client' => 1]);
35
-        if (! $oauthClient) {
35
+        if ( ! $oauthClient) {
36 36
             $oauthClient = $client->createPasswordGrantClient(
37 37
                 null,
38 38
                 config('app.name'),
Please login to merge, or discard this patch.
Core/Console/Commands/Stubs/Module/Http/Controllers/DummyController.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -8,42 +8,42 @@
 block discarded – undo
8 8
 
9 9
 class DummyController extends BaseApiController
10 10
 {
11
-    /**
12
-     * Path of the sotre form request.
13
-     *
14
-     * @var string
15
-     */
16
-    protected $storeFormRequest = 'App\Modules\DummyModule\Http\Requests\StoreDummy';
11
+	/**
12
+	 * Path of the sotre form request.
13
+	 *
14
+	 * @var string
15
+	 */
16
+	protected $storeFormRequest = 'App\Modules\DummyModule\Http\Requests\StoreDummy';
17 17
     
18
-    /**
19
-     * Path of the model resource
20
-     *
21
-     * @var string
22
-     */
23
-    protected $modelResource = 'App\Modules\DummyModule\Http\Resources\DummyModel';
18
+	/**
19
+	 * Path of the model resource
20
+	 *
21
+	 * @var string
22
+	 */
23
+	protected $modelResource = 'App\Modules\DummyModule\Http\Resources\DummyModel';
24 24
 
25
-    /**
26
-     * List of all route actions that the base api controller
27
-     * will skip permissions check for them.
28
-     * @var array
29
-     */
30
-    protected $skipPermissionCheck = [];
25
+	/**
26
+	 * List of all route actions that the base api controller
27
+	 * will skip permissions check for them.
28
+	 * @var array
29
+	 */
30
+	protected $skipPermissionCheck = [];
31 31
 
32
-    /**
33
-     * List of all route actions that the base api controller
34
-     * will skip login check for them.
35
-     * @var array
36
-     */
37
-    protected $skipLoginCheck = [];
32
+	/**
33
+	 * List of all route actions that the base api controller
34
+	 * will skip login check for them.
35
+	 * @var array
36
+	 */
37
+	protected $skipLoginCheck = [];
38 38
 
39
-    /**
40
-     * Init new object.
41
-     *
42
-     * @param   DummyService $service
43
-     * @return  void
44
-     */
45
-    public function __construct(DummyService $service)
46
-    {
47
-        parent::__construct($service);
48
-    }
39
+	/**
40
+	 * Init new object.
41
+	 *
42
+	 * @param   DummyService $service
43
+	 * @return  void
44
+	 */
45
+	public function __construct(DummyService $service)
46
+	{
47
+		parent::__construct($service);
48
+	}
49 49
 }
Please login to merge, or discard this patch.