@@ -8,72 +8,72 @@ |
||
| 8 | 8 | class RouteServiceProvider extends ServiceProvider |
| 9 | 9 | { |
| 10 | 10 | /** |
| 11 | - * This namespace is applied to your controller routes. |
|
| 12 | - * |
|
| 13 | - * In addition, it is set as the URL generator's root namespace. |
|
| 14 | - * |
|
| 15 | - * @var string |
|
| 16 | - */ |
|
| 17 | - protected $namespace = 'App\Modules\V1\Reporting\Http\Controllers'; |
|
| 11 | + * This namespace is applied to your controller routes. |
|
| 12 | + * |
|
| 13 | + * In addition, it is set as the URL generator's root namespace. |
|
| 14 | + * |
|
| 15 | + * @var string |
|
| 16 | + */ |
|
| 17 | + protected $namespace = 'App\Modules\V1\Reporting\Http\Controllers'; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Define your route model bindings, pattern filters, etc. |
|
| 21 | - * |
|
| 22 | - * @return void |
|
| 23 | - */ |
|
| 24 | - public function boot() |
|
| 25 | - { |
|
| 26 | - // |
|
| 19 | + /** |
|
| 20 | + * Define your route model bindings, pattern filters, etc. |
|
| 21 | + * |
|
| 22 | + * @return void |
|
| 23 | + */ |
|
| 24 | + public function boot() |
|
| 25 | + { |
|
| 26 | + // |
|
| 27 | 27 | |
| 28 | - parent::boot(); |
|
| 29 | - } |
|
| 28 | + parent::boot(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Define the routes for the module. |
|
| 33 | - * |
|
| 34 | - * @return void |
|
| 35 | - */ |
|
| 36 | - public function map() |
|
| 37 | - { |
|
| 38 | - $this->mapWebRoutes(); |
|
| 31 | + /** |
|
| 32 | + * Define the routes for the module. |
|
| 33 | + * |
|
| 34 | + * @return void |
|
| 35 | + */ |
|
| 36 | + public function map() |
|
| 37 | + { |
|
| 38 | + $this->mapWebRoutes(); |
|
| 39 | 39 | |
| 40 | - $this->mapApiRoutes(); |
|
| 40 | + $this->mapApiRoutes(); |
|
| 41 | 41 | |
| 42 | - // |
|
| 43 | - } |
|
| 42 | + // |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Define the "web" routes for the module. |
|
| 47 | - * |
|
| 48 | - * These routes all receive session state, CSRF protection, etc. |
|
| 49 | - * |
|
| 50 | - * @return void |
|
| 51 | - */ |
|
| 52 | - protected function mapWebRoutes() |
|
| 53 | - { |
|
| 54 | - Route::group([ |
|
| 55 | - 'middleware' => 'web', |
|
| 56 | - 'namespace' => $this->namespace, |
|
| 57 | - ], function ($router) { |
|
| 58 | - require module_path('reporting', 'Routes/web.php'); |
|
| 59 | - }); |
|
| 60 | - } |
|
| 45 | + /** |
|
| 46 | + * Define the "web" routes for the module. |
|
| 47 | + * |
|
| 48 | + * These routes all receive session state, CSRF protection, etc. |
|
| 49 | + * |
|
| 50 | + * @return void |
|
| 51 | + */ |
|
| 52 | + protected function mapWebRoutes() |
|
| 53 | + { |
|
| 54 | + Route::group([ |
|
| 55 | + 'middleware' => 'web', |
|
| 56 | + 'namespace' => $this->namespace, |
|
| 57 | + ], function ($router) { |
|
| 58 | + require module_path('reporting', 'Routes/web.php'); |
|
| 59 | + }); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Define the "api" routes for the module. |
|
| 64 | - * |
|
| 65 | - * These routes are typically stateless. |
|
| 66 | - * |
|
| 67 | - * @return void |
|
| 68 | - */ |
|
| 69 | - protected function mapApiRoutes() |
|
| 70 | - { |
|
| 71 | - Route::group([ |
|
| 72 | - 'middleware' => 'api', |
|
| 73 | - 'namespace' => $this->namespace, |
|
| 74 | - 'prefix' => 'api', |
|
| 75 | - ], function ($router) { |
|
| 76 | - require module_path('reporting', 'Routes/api.php'); |
|
| 77 | - }); |
|
| 78 | - } |
|
| 62 | + /** |
|
| 63 | + * Define the "api" routes for the module. |
|
| 64 | + * |
|
| 65 | + * These routes are typically stateless. |
|
| 66 | + * |
|
| 67 | + * @return void |
|
| 68 | + */ |
|
| 69 | + protected function mapApiRoutes() |
|
| 70 | + { |
|
| 71 | + Route::group([ |
|
| 72 | + 'middleware' => 'api', |
|
| 73 | + 'namespace' => $this->namespace, |
|
| 74 | + 'prefix' => 'api', |
|
| 75 | + ], function ($router) { |
|
| 76 | + require module_path('reporting', 'Routes/api.php'); |
|
| 77 | + }); |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | Route::group([ |
| 55 | 55 | 'middleware' => 'web', |
| 56 | 56 | 'namespace' => $this->namespace, |
| 57 | - ], function ($router) { |
|
| 57 | + ], function($router) { |
|
| 58 | 58 | require module_path('reporting', 'Routes/web.php'); |
| 59 | 59 | }); |
| 60 | 60 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | 'middleware' => 'api', |
| 73 | 73 | 'namespace' => $this->namespace, |
| 74 | 74 | 'prefix' => 'api', |
| 75 | - ], function ($router) { |
|
| 75 | + ], function($router) { |
|
| 76 | 76 | require module_path('reporting', 'Routes/api.php'); |
| 77 | 77 | }); |
| 78 | 78 | } |
@@ -8,72 +8,72 @@ |
||
| 8 | 8 | class RouteServiceProvider extends ServiceProvider |
| 9 | 9 | { |
| 10 | 10 | /** |
| 11 | - * This namespace is applied to your controller routes. |
|
| 12 | - * |
|
| 13 | - * In addition, it is set as the URL generator's root namespace. |
|
| 14 | - * |
|
| 15 | - * @var string |
|
| 16 | - */ |
|
| 17 | - protected $namespace = 'App\Modules\V1\Acl\Http\Controllers'; |
|
| 11 | + * This namespace is applied to your controller routes. |
|
| 12 | + * |
|
| 13 | + * In addition, it is set as the URL generator's root namespace. |
|
| 14 | + * |
|
| 15 | + * @var string |
|
| 16 | + */ |
|
| 17 | + protected $namespace = 'App\Modules\V1\Acl\Http\Controllers'; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Define your route model bindings, pattern filters, etc. |
|
| 21 | - * |
|
| 22 | - * @return void |
|
| 23 | - */ |
|
| 24 | - public function boot() |
|
| 25 | - { |
|
| 26 | - // |
|
| 19 | + /** |
|
| 20 | + * Define your route model bindings, pattern filters, etc. |
|
| 21 | + * |
|
| 22 | + * @return void |
|
| 23 | + */ |
|
| 24 | + public function boot() |
|
| 25 | + { |
|
| 26 | + // |
|
| 27 | 27 | |
| 28 | - parent::boot(); |
|
| 29 | - } |
|
| 28 | + parent::boot(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Define the routes for the module. |
|
| 33 | - * |
|
| 34 | - * @return void |
|
| 35 | - */ |
|
| 36 | - public function map() |
|
| 37 | - { |
|
| 38 | - $this->mapWebRoutes(); |
|
| 31 | + /** |
|
| 32 | + * Define the routes for the module. |
|
| 33 | + * |
|
| 34 | + * @return void |
|
| 35 | + */ |
|
| 36 | + public function map() |
|
| 37 | + { |
|
| 38 | + $this->mapWebRoutes(); |
|
| 39 | 39 | |
| 40 | - $this->mapApiRoutes(); |
|
| 40 | + $this->mapApiRoutes(); |
|
| 41 | 41 | |
| 42 | - // |
|
| 43 | - } |
|
| 42 | + // |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Define the "web" routes for the module. |
|
| 47 | - * |
|
| 48 | - * These routes all receive session state, CSRF protection, etc. |
|
| 49 | - * |
|
| 50 | - * @return void |
|
| 51 | - */ |
|
| 52 | - protected function mapWebRoutes() |
|
| 53 | - { |
|
| 54 | - Route::group([ |
|
| 55 | - 'middleware' => 'web', |
|
| 56 | - 'namespace' => $this->namespace, |
|
| 57 | - ], function ($router) { |
|
| 58 | - require module_path('acl', 'Routes/web.php'); |
|
| 59 | - }); |
|
| 60 | - } |
|
| 45 | + /** |
|
| 46 | + * Define the "web" routes for the module. |
|
| 47 | + * |
|
| 48 | + * These routes all receive session state, CSRF protection, etc. |
|
| 49 | + * |
|
| 50 | + * @return void |
|
| 51 | + */ |
|
| 52 | + protected function mapWebRoutes() |
|
| 53 | + { |
|
| 54 | + Route::group([ |
|
| 55 | + 'middleware' => 'web', |
|
| 56 | + 'namespace' => $this->namespace, |
|
| 57 | + ], function ($router) { |
|
| 58 | + require module_path('acl', 'Routes/web.php'); |
|
| 59 | + }); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Define the "api" routes for the module. |
|
| 64 | - * |
|
| 65 | - * These routes are typically stateless. |
|
| 66 | - * |
|
| 67 | - * @return void |
|
| 68 | - */ |
|
| 69 | - protected function mapApiRoutes() |
|
| 70 | - { |
|
| 71 | - Route::group([ |
|
| 72 | - 'middleware' => 'api', |
|
| 73 | - 'namespace' => $this->namespace, |
|
| 74 | - 'prefix' => 'api', |
|
| 75 | - ], function ($router) { |
|
| 76 | - require module_path('acl', 'Routes/api.php'); |
|
| 77 | - }); |
|
| 78 | - } |
|
| 62 | + /** |
|
| 63 | + * Define the "api" routes for the module. |
|
| 64 | + * |
|
| 65 | + * These routes are typically stateless. |
|
| 66 | + * |
|
| 67 | + * @return void |
|
| 68 | + */ |
|
| 69 | + protected function mapApiRoutes() |
|
| 70 | + { |
|
| 71 | + Route::group([ |
|
| 72 | + 'middleware' => 'api', |
|
| 73 | + 'namespace' => $this->namespace, |
|
| 74 | + 'prefix' => 'api', |
|
| 75 | + ], function ($router) { |
|
| 76 | + require module_path('acl', 'Routes/api.php'); |
|
| 77 | + }); |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | Route::group([ |
| 55 | 55 | 'middleware' => 'web', |
| 56 | 56 | 'namespace' => $this->namespace, |
| 57 | - ], function ($router) { |
|
| 57 | + ], function($router) { |
|
| 58 | 58 | require module_path('acl', 'Routes/web.php'); |
| 59 | 59 | }); |
| 60 | 60 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | 'middleware' => 'api', |
| 73 | 73 | 'namespace' => $this->namespace, |
| 74 | 74 | 'prefix' => 'api', |
| 75 | - ], function ($router) { |
|
| 75 | + ], function($router) { |
|
| 76 | 76 | require module_path('acl', 'Routes/api.php'); |
| 77 | 77 | }); |
| 78 | 78 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('users', function (Blueprint $table) { |
|
| 15 | + Schema::create('users', function(Blueprint $table) { |
|
| 16 | 16 | $table->increments('id'); |
| 17 | 17 | $table->string('name', 100)->nullable(); |
| 18 | 18 | $table->string('email')->unique(); |
@@ -13,30 +13,30 @@ |
||
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | 15 | Schema::create('users', function (Blueprint $table) { |
| 16 | - $table->increments('id'); |
|
| 17 | - $table->string('name', 100)->nullable(); |
|
| 18 | - $table->string('email')->unique(); |
|
| 19 | - $table->string('password', 60)->nullable(); |
|
| 20 | - $table->boolean('blocked')->default(0); |
|
| 16 | + $table->increments('id'); |
|
| 17 | + $table->string('name', 100)->nullable(); |
|
| 18 | + $table->string('email')->unique(); |
|
| 19 | + $table->string('password', 60)->nullable(); |
|
| 20 | + $table->boolean('blocked')->default(0); |
|
| 21 | 21 | $table->date('last_change_password')->nullable(); |
| 22 | - $table->string('two_factor_code', 4)->nullable(); |
|
| 23 | - $table->softDeletes(); |
|
| 24 | - $table->rememberToken(); |
|
| 25 | - $table->timestamps(); |
|
| 26 | - }); |
|
| 22 | + $table->string('two_factor_code', 4)->nullable(); |
|
| 23 | + $table->softDeletes(); |
|
| 24 | + $table->rememberToken(); |
|
| 25 | + $table->timestamps(); |
|
| 26 | + }); |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Create Default users. |
| 30 | 30 | */ |
| 31 | 31 | \DB::table('users')->insertGetId( |
| 32 | - [ |
|
| 32 | + [ |
|
| 33 | 33 | 'name' => 'Admin', |
| 34 | 34 | 'email' => '[email protected]', |
| 35 | 35 | 'password' => bcrypt('123456'), |
| 36 | 36 | 'created_at' => \DB::raw('NOW()'), |
| 37 | 37 | 'updated_at' => \DB::raw('NOW()') |
| 38 | 38 | ] |
| 39 | - ); |
|
| 39 | + ); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -170,8 +170,7 @@ |
||
| 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 | } |
@@ -1,7 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace App\Modules\V1\Acl\Http\Controllers; |
| 3 | 3 | |
| 4 | -use Illuminate\Foundation\Http\FormRequest; |
|
| 5 | 4 | use App\Modules\V1\Core\Http\Controllers\BaseApiController; |
| 6 | 5 | use App\Modules\V1\Acl\Proxy\LoginProxy; |
| 7 | 6 | use Illuminate\Http\Request; |
@@ -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']; |
|
| 30 | + protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken']; |
|
| 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' |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | /** |
| 57 | 57 | * Return the logged in user account. |
| 58 | 58 | * |
| 59 | - * @return \Illuminate\Http\Response |
|
| 59 | + * @return \Illuminate\Http\JsonResponse |
|
| 60 | 60 | */ |
| 61 | 61 | public function account() |
| 62 | 62 | { |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * Block the user. |
| 68 | 68 | * |
| 69 | 69 | * @param integer $id Id of the user. |
| 70 | - * @return \Illuminate\Http\Response |
|
| 70 | + * @return \Illuminate\Http\JsonResponse |
|
| 71 | 71 | */ |
| 72 | 72 | public function block($id) |
| 73 | 73 | { |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * Unblock the user. |
| 79 | 79 | * |
| 80 | 80 | * @param integer $id Id of the user. |
| 81 | - * @return \Illuminate\Http\Response |
|
| 81 | + * @return \Illuminate\Http\JsonResponse |
|
| 82 | 82 | */ |
| 83 | 83 | public function unblock($id) |
| 84 | 84 | { |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | /** |
| 89 | 89 | * Logout the user. |
| 90 | 90 | * |
| 91 | - * @return \Illuminate\Http\Response |
|
| 91 | + * @return \Illuminate\Http\JsonResponse |
|
| 92 | 92 | */ |
| 93 | 93 | public function logout() |
| 94 | 94 | { |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * Handle a registration request. |
| 100 | 100 | * |
| 101 | 101 | * @param \Illuminate\Http\Request $request |
| 102 | - * @return \Illuminate\Http\Response |
|
| 102 | + * @return \Illuminate\Http\JsonResponse |
|
| 103 | 103 | */ |
| 104 | 104 | public function register(Request $request) |
| 105 | 105 | { |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * Handle a login request to the application. |
| 117 | 117 | * |
| 118 | 118 | * @param \Illuminate\Http\Request $request |
| 119 | - * @return \Illuminate\Http\Response |
|
| 119 | + * @return \Illuminate\Http\JsonResponse |
|
| 120 | 120 | */ |
| 121 | 121 | public function login(Request $request) |
| 122 | 122 | { |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * Handle a social login request of the none admin to the application. |
| 134 | 134 | * |
| 135 | 135 | * @param \Illuminate\Http\Request $request |
| 136 | - * @return \Illuminate\Http\Response |
|
| 136 | + * @return \Illuminate\Http\JsonResponse |
|
| 137 | 137 | */ |
| 138 | 138 | public function loginSocial(Request $request) |
| 139 | 139 | { |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * Assign the given groups to the given user. |
| 151 | 151 | * |
| 152 | 152 | * @param \Illuminate\Http\Request $request |
| 153 | - * @return \Illuminate\Http\Response |
|
| 153 | + * @return \Illuminate\Http\JsonResponse |
|
| 154 | 154 | */ |
| 155 | 155 | public function assigngroups(Request $request) |
| 156 | 156 | { |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * Send a reset link to the given user. |
| 167 | 167 | * |
| 168 | 168 | * @param \Illuminate\Http\Request $request |
| 169 | - * @return \Illuminate\Http\Response |
|
| 169 | + * @return \Illuminate\Http\JsonResponse |
|
| 170 | 170 | */ |
| 171 | 171 | public function sendreset(Request $request) |
| 172 | 172 | { |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | * Reset the given user's password. |
| 180 | 180 | * |
| 181 | 181 | * @param \Illuminate\Http\Request $request |
| 182 | - * @return \Illuminate\Http\Response |
|
| 182 | + * @return \Illuminate\Http\JsonResponse |
|
| 183 | 183 | */ |
| 184 | 184 | public function resetpassword(Request $request) |
| 185 | 185 | { |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * Change the logged in user password. |
| 198 | 198 | * |
| 199 | 199 | * @param \Illuminate\Http\Request $request |
| 200 | - * @return \Illuminate\Http\Response |
|
| 200 | + * @return \Illuminate\Http\JsonResponse |
|
| 201 | 201 | */ |
| 202 | 202 | public function changePassword(Request $request) |
| 203 | 203 | { |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * Refresh the expired login token. |
| 215 | 215 | * |
| 216 | 216 | * @param \Illuminate\Http\Request $request |
| 217 | - * @return \Illuminate\Http\Response |
|
| 217 | + * @return \Illuminate\Http\JsonResponse |
|
| 218 | 218 | */ |
| 219 | 219 | public function refreshtoken(Request $request) |
| 220 | 220 | { |
@@ -232,8 +232,8 @@ discard block |
||
| 232 | 232 | * @param string $groupName The name of the requested group. |
| 233 | 233 | * @param integer $perPage Number of rows per page default 15. |
| 234 | 234 | * @param string $sortBy The name of the column to sort by. |
| 235 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 236 | - * @return \Illuminate\Http\Response |
|
| 235 | + * @param integer $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 236 | + * @return \Illuminate\Http\JsonResponse |
|
| 237 | 237 | */ |
| 238 | 238 | public function group(Request $request, $groupName, $perPage = false, $sortBy = 'created_at', $desc = 1) |
| 239 | 239 | { |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * Save the given data to the logged in user. |
| 245 | 245 | * |
| 246 | 246 | * @param \Illuminate\Http\Request $request |
| 247 | - * @return \Illuminate\Http\Response |
|
| 247 | + * @return \Illuminate\Http\JsonResponse|null |
|
| 248 | 248 | */ |
| 249 | 249 | public function saveProfile(Request $request) |
| 250 | 250 | { |
@@ -8,268 +8,268 @@ |
||
| 8 | 8 | |
| 9 | 9 | class UsersController 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 = 'users'; |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * List of all route actions that the base api controller |
|
| 20 | - * will skip permissions check for them. |
|
| 21 | - * @var array |
|
| 22 | - */ |
|
| 23 | - protected $skipPermissionCheck = ['account', 'logout', 'changePassword']; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * List of all route actions that the base api controller |
|
| 27 | - * will skip login check for them. |
|
| 28 | - * @var array |
|
| 29 | - */ |
|
| 30 | - protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken']; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * The validations rules used by the base api controller |
|
| 34 | - * to check before add. |
|
| 35 | - * @var array |
|
| 36 | - */ |
|
| 37 | - protected $validationRules = [ |
|
| 38 | - 'name' => 'nullable|string', |
|
| 39 | - 'email' => 'required|email|unique:users,email,{id}', |
|
| 40 | - 'password' => 'nullable|min:6' |
|
| 41 | - ]; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * The loginProxy implementation. |
|
| 45 | - * |
|
| 46 | - * @var \App\Modules\V1\Acl\Proxy\LoginProxy |
|
| 47 | - */ |
|
| 48 | - protected $loginProxy; |
|
| 49 | - |
|
| 50 | - public function __construct(LoginProxy $loginProxy) |
|
| 51 | - { |
|
| 52 | - $this->loginProxy = $loginProxy; |
|
| 53 | - parent::__construct(); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Return the logged in user account. |
|
| 58 | - * |
|
| 59 | - * @return \Illuminate\Http\Response |
|
| 60 | - */ |
|
| 61 | - public function account() |
|
| 62 | - { |
|
| 63 | - return \Response::json($this->repo->account($this->relations), 200); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Block the user. |
|
| 68 | - * |
|
| 69 | - * @param integer $id Id of the user. |
|
| 70 | - * @return \Illuminate\Http\Response |
|
| 71 | - */ |
|
| 72 | - public function block($id) |
|
| 73 | - { |
|
| 74 | - return \Response::json($this->repo->block($id), 200); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Unblock the user. |
|
| 79 | - * |
|
| 80 | - * @param integer $id Id of the user. |
|
| 81 | - * @return \Illuminate\Http\Response |
|
| 82 | - */ |
|
| 83 | - public function unblock($id) |
|
| 84 | - { |
|
| 85 | - return \Response::json($this->repo->unblock($id), 200); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Logout the user. |
|
| 90 | - * |
|
| 91 | - * @return \Illuminate\Http\Response |
|
| 92 | - */ |
|
| 93 | - public function logout() |
|
| 94 | - { |
|
| 95 | - return \Response::json($this->loginProxy->logout(), 200); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Handle a registration request. |
|
| 100 | - * |
|
| 101 | - * @param \Illuminate\Http\Request $request |
|
| 102 | - * @return \Illuminate\Http\Response |
|
| 103 | - */ |
|
| 104 | - public function register(Request $request) |
|
| 105 | - { |
|
| 106 | - $this->validate($request, [ |
|
| 107 | - 'name' => 'nullable|string', |
|
| 108 | - 'email' => 'required|email|unique:users,email,{id}', |
|
| 109 | - 'password' => 'required|min:6' |
|
| 110 | - ]); |
|
| 111 | - |
|
| 112 | - return \Response::json($this->repo->register($request->only('email', 'password')), 200); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Handle a login request to the application. |
|
| 117 | - * |
|
| 118 | - * @param \Illuminate\Http\Request $request |
|
| 119 | - * @return \Illuminate\Http\Response |
|
| 120 | - */ |
|
| 121 | - public function login(Request $request) |
|
| 122 | - { |
|
| 123 | - $this->validate($request, [ |
|
| 124 | - 'email' => 'required|email', |
|
| 125 | - 'password' => 'required|min:6', |
|
| 126 | - 'admin' => 'boolean' |
|
| 127 | - ]); |
|
| 128 | - |
|
| 129 | - return \Response::json($this->loginProxy->login($request->only('email', 'password'), $request->get('admin')), 200); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Handle a social login request of the none admin to the application. |
|
| 134 | - * |
|
| 135 | - * @param \Illuminate\Http\Request $request |
|
| 136 | - * @return \Illuminate\Http\Response |
|
| 137 | - */ |
|
| 138 | - public function loginSocial(Request $request) |
|
| 139 | - { |
|
| 140 | - $this->validate($request, [ |
|
| 141 | - 'auth_code' => 'required_without:access_token', |
|
| 142 | - 'access_token' => 'required_without:auth_code', |
|
| 143 | - 'type' => 'required|in:facebook,google' |
|
| 144 | - ]); |
|
| 145 | - |
|
| 146 | - return \Response::json($this->repo->loginSocial($request->only('auth_code', 'access_token', 'type')), 200); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Assign the given groups to the given user. |
|
| 151 | - * |
|
| 152 | - * @param \Illuminate\Http\Request $request |
|
| 153 | - * @return \Illuminate\Http\Response |
|
| 154 | - */ |
|
| 155 | - public function assigngroups(Request $request) |
|
| 156 | - { |
|
| 157 | - $this->validate($request, [ |
|
| 158 | - 'group_ids' => 'required|exists:groups,id', |
|
| 159 | - 'user_id' => 'required|exists:users,id' |
|
| 160 | - ]); |
|
| 161 | - |
|
| 162 | - return \Response::json($this->repo->assignGroups($request->get('user_id'), $request->get('group_ids')), 200); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * Send a reset link to the given user. |
|
| 167 | - * |
|
| 168 | - * @param \Illuminate\Http\Request $request |
|
| 169 | - * @return \Illuminate\Http\Response |
|
| 170 | - */ |
|
| 171 | - public function sendreset(Request $request) |
|
| 172 | - { |
|
| 173 | - $this->validate($request, ['email' => 'required|email']); |
|
| 174 | - |
|
| 175 | - return \Response::json($this->repo->sendReset($request->only('email')), 200); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Reset the given user's password. |
|
| 180 | - * |
|
| 181 | - * @param \Illuminate\Http\Request $request |
|
| 182 | - * @return \Illuminate\Http\Response |
|
| 183 | - */ |
|
| 184 | - public function resetpassword(Request $request) |
|
| 185 | - { |
|
| 186 | - $this->validate($request, [ |
|
| 187 | - 'token' => 'required', |
|
| 188 | - 'email' => 'required|email', |
|
| 189 | - 'password' => 'required|confirmed|min:6', |
|
| 190 | - 'password_confirmation' => 'required', |
|
| 191 | - ]); |
|
| 192 | - |
|
| 193 | - return \Response::json($this->repo->resetPassword($request->only('email', 'password', 'password_confirmation', 'token')), 200); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * Change the logged in user password. |
|
| 198 | - * |
|
| 199 | - * @param \Illuminate\Http\Request $request |
|
| 200 | - * @return \Illuminate\Http\Response |
|
| 201 | - */ |
|
| 202 | - public function changePassword(Request $request) |
|
| 203 | - { |
|
| 204 | - $this->validate($request, [ |
|
| 205 | - 'old_password' => 'required', |
|
| 206 | - 'password' => 'required|confirmed|min:6', |
|
| 207 | - 'password_confirmation' => 'required', |
|
| 208 | - ]); |
|
| 209 | - |
|
| 210 | - return \Response::json($this->repo->changePassword($request->only('old_password', 'password', 'password_confirmation')), 200); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * Refresh the expired login token. |
|
| 215 | - * |
|
| 216 | - * @param \Illuminate\Http\Request $request |
|
| 217 | - * @return \Illuminate\Http\Response |
|
| 218 | - */ |
|
| 219 | - public function refreshtoken(Request $request) |
|
| 220 | - { |
|
| 221 | - $this->validate($request, [ |
|
| 222 | - 'refreshtoken' => 'required', |
|
| 223 | - ]); |
|
| 224 | - |
|
| 225 | - return \Response::json($this->loginProxy->refreshtoken($request->only('refreshtoken')), 200); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - /** |
|
| 229 | - * Paginate all users with inthe given group. |
|
| 230 | - * |
|
| 231 | - * @param \Illuminate\Http\Request $request |
|
| 232 | - * @param string $groupName The name of the requested group. |
|
| 233 | - * @param integer $perPage Number of rows per page default 15. |
|
| 234 | - * @param string $sortBy The name of the column to sort by. |
|
| 235 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 236 | - * @return \Illuminate\Http\Response |
|
| 237 | - */ |
|
| 238 | - public function group(Request $request, $groupName, $perPage = false, $sortBy = 'created_at', $desc = 1) |
|
| 239 | - { |
|
| 240 | - return \Response::json($this->repo->group($request->all(), $groupName, $this->relations, $perPage, $sortBy, $desc), 200); |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Save the given data to the logged in user. |
|
| 245 | - * |
|
| 246 | - * @param \Illuminate\Http\Request $request |
|
| 247 | - * @return \Illuminate\Http\Response |
|
| 248 | - */ |
|
| 249 | - public function saveProfile(Request $request) |
|
| 250 | - { |
|
| 251 | - foreach ($this->validationRules as &$rule) |
|
| 252 | - { |
|
| 253 | - if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) |
|
| 254 | - { |
|
| 255 | - $rule .= ',deleted_at,NULL'; |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - if ($request->has('id')) |
|
| 259 | - { |
|
| 260 | - $rule = str_replace('{id}', $request->get('id'), $rule); |
|
| 261 | - } |
|
| 262 | - else |
|
| 263 | - { |
|
| 264 | - $rule = str_replace(',{id}', '', $rule); |
|
| 265 | - } |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - $this->validate($request, $this->validationRules); |
|
| 269 | - |
|
| 270 | - if ($this->model) |
|
| 271 | - { |
|
| 272 | - return \Response::json(call_user_func_array("\Core::{$this->model}", [])->saveProfile($request->all()), 200); |
|
| 273 | - } |
|
| 274 | - } |
|
| 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 = 'users'; |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * List of all route actions that the base api controller |
|
| 20 | + * will skip permissions check for them. |
|
| 21 | + * @var array |
|
| 22 | + */ |
|
| 23 | + protected $skipPermissionCheck = ['account', 'logout', 'changePassword']; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * List of all route actions that the base api controller |
|
| 27 | + * will skip login check for them. |
|
| 28 | + * @var array |
|
| 29 | + */ |
|
| 30 | + protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken']; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * The validations rules used by the base api controller |
|
| 34 | + * to check before add. |
|
| 35 | + * @var array |
|
| 36 | + */ |
|
| 37 | + protected $validationRules = [ |
|
| 38 | + 'name' => 'nullable|string', |
|
| 39 | + 'email' => 'required|email|unique:users,email,{id}', |
|
| 40 | + 'password' => 'nullable|min:6' |
|
| 41 | + ]; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * The loginProxy implementation. |
|
| 45 | + * |
|
| 46 | + * @var \App\Modules\V1\Acl\Proxy\LoginProxy |
|
| 47 | + */ |
|
| 48 | + protected $loginProxy; |
|
| 49 | + |
|
| 50 | + public function __construct(LoginProxy $loginProxy) |
|
| 51 | + { |
|
| 52 | + $this->loginProxy = $loginProxy; |
|
| 53 | + parent::__construct(); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Return the logged in user account. |
|
| 58 | + * |
|
| 59 | + * @return \Illuminate\Http\Response |
|
| 60 | + */ |
|
| 61 | + public function account() |
|
| 62 | + { |
|
| 63 | + return \Response::json($this->repo->account($this->relations), 200); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * Block the user. |
|
| 68 | + * |
|
| 69 | + * @param integer $id Id of the user. |
|
| 70 | + * @return \Illuminate\Http\Response |
|
| 71 | + */ |
|
| 72 | + public function block($id) |
|
| 73 | + { |
|
| 74 | + return \Response::json($this->repo->block($id), 200); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Unblock the user. |
|
| 79 | + * |
|
| 80 | + * @param integer $id Id of the user. |
|
| 81 | + * @return \Illuminate\Http\Response |
|
| 82 | + */ |
|
| 83 | + public function unblock($id) |
|
| 84 | + { |
|
| 85 | + return \Response::json($this->repo->unblock($id), 200); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Logout the user. |
|
| 90 | + * |
|
| 91 | + * @return \Illuminate\Http\Response |
|
| 92 | + */ |
|
| 93 | + public function logout() |
|
| 94 | + { |
|
| 95 | + return \Response::json($this->loginProxy->logout(), 200); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Handle a registration request. |
|
| 100 | + * |
|
| 101 | + * @param \Illuminate\Http\Request $request |
|
| 102 | + * @return \Illuminate\Http\Response |
|
| 103 | + */ |
|
| 104 | + public function register(Request $request) |
|
| 105 | + { |
|
| 106 | + $this->validate($request, [ |
|
| 107 | + 'name' => 'nullable|string', |
|
| 108 | + 'email' => 'required|email|unique:users,email,{id}', |
|
| 109 | + 'password' => 'required|min:6' |
|
| 110 | + ]); |
|
| 111 | + |
|
| 112 | + return \Response::json($this->repo->register($request->only('email', 'password')), 200); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Handle a login request to the application. |
|
| 117 | + * |
|
| 118 | + * @param \Illuminate\Http\Request $request |
|
| 119 | + * @return \Illuminate\Http\Response |
|
| 120 | + */ |
|
| 121 | + public function login(Request $request) |
|
| 122 | + { |
|
| 123 | + $this->validate($request, [ |
|
| 124 | + 'email' => 'required|email', |
|
| 125 | + 'password' => 'required|min:6', |
|
| 126 | + 'admin' => 'boolean' |
|
| 127 | + ]); |
|
| 128 | + |
|
| 129 | + return \Response::json($this->loginProxy->login($request->only('email', 'password'), $request->get('admin')), 200); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Handle a social login request of the none admin to the application. |
|
| 134 | + * |
|
| 135 | + * @param \Illuminate\Http\Request $request |
|
| 136 | + * @return \Illuminate\Http\Response |
|
| 137 | + */ |
|
| 138 | + public function loginSocial(Request $request) |
|
| 139 | + { |
|
| 140 | + $this->validate($request, [ |
|
| 141 | + 'auth_code' => 'required_without:access_token', |
|
| 142 | + 'access_token' => 'required_without:auth_code', |
|
| 143 | + 'type' => 'required|in:facebook,google' |
|
| 144 | + ]); |
|
| 145 | + |
|
| 146 | + return \Response::json($this->repo->loginSocial($request->only('auth_code', 'access_token', 'type')), 200); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Assign the given groups to the given user. |
|
| 151 | + * |
|
| 152 | + * @param \Illuminate\Http\Request $request |
|
| 153 | + * @return \Illuminate\Http\Response |
|
| 154 | + */ |
|
| 155 | + public function assigngroups(Request $request) |
|
| 156 | + { |
|
| 157 | + $this->validate($request, [ |
|
| 158 | + 'group_ids' => 'required|exists:groups,id', |
|
| 159 | + 'user_id' => 'required|exists:users,id' |
|
| 160 | + ]); |
|
| 161 | + |
|
| 162 | + return \Response::json($this->repo->assignGroups($request->get('user_id'), $request->get('group_ids')), 200); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * Send a reset link to the given user. |
|
| 167 | + * |
|
| 168 | + * @param \Illuminate\Http\Request $request |
|
| 169 | + * @return \Illuminate\Http\Response |
|
| 170 | + */ |
|
| 171 | + public function sendreset(Request $request) |
|
| 172 | + { |
|
| 173 | + $this->validate($request, ['email' => 'required|email']); |
|
| 174 | + |
|
| 175 | + return \Response::json($this->repo->sendReset($request->only('email')), 200); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Reset the given user's password. |
|
| 180 | + * |
|
| 181 | + * @param \Illuminate\Http\Request $request |
|
| 182 | + * @return \Illuminate\Http\Response |
|
| 183 | + */ |
|
| 184 | + public function resetpassword(Request $request) |
|
| 185 | + { |
|
| 186 | + $this->validate($request, [ |
|
| 187 | + 'token' => 'required', |
|
| 188 | + 'email' => 'required|email', |
|
| 189 | + 'password' => 'required|confirmed|min:6', |
|
| 190 | + 'password_confirmation' => 'required', |
|
| 191 | + ]); |
|
| 192 | + |
|
| 193 | + return \Response::json($this->repo->resetPassword($request->only('email', 'password', 'password_confirmation', 'token')), 200); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * Change the logged in user password. |
|
| 198 | + * |
|
| 199 | + * @param \Illuminate\Http\Request $request |
|
| 200 | + * @return \Illuminate\Http\Response |
|
| 201 | + */ |
|
| 202 | + public function changePassword(Request $request) |
|
| 203 | + { |
|
| 204 | + $this->validate($request, [ |
|
| 205 | + 'old_password' => 'required', |
|
| 206 | + 'password' => 'required|confirmed|min:6', |
|
| 207 | + 'password_confirmation' => 'required', |
|
| 208 | + ]); |
|
| 209 | + |
|
| 210 | + return \Response::json($this->repo->changePassword($request->only('old_password', 'password', 'password_confirmation')), 200); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * Refresh the expired login token. |
|
| 215 | + * |
|
| 216 | + * @param \Illuminate\Http\Request $request |
|
| 217 | + * @return \Illuminate\Http\Response |
|
| 218 | + */ |
|
| 219 | + public function refreshtoken(Request $request) |
|
| 220 | + { |
|
| 221 | + $this->validate($request, [ |
|
| 222 | + 'refreshtoken' => 'required', |
|
| 223 | + ]); |
|
| 224 | + |
|
| 225 | + return \Response::json($this->loginProxy->refreshtoken($request->only('refreshtoken')), 200); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + /** |
|
| 229 | + * Paginate all users with inthe given group. |
|
| 230 | + * |
|
| 231 | + * @param \Illuminate\Http\Request $request |
|
| 232 | + * @param string $groupName The name of the requested group. |
|
| 233 | + * @param integer $perPage Number of rows per page default 15. |
|
| 234 | + * @param string $sortBy The name of the column to sort by. |
|
| 235 | + * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 236 | + * @return \Illuminate\Http\Response |
|
| 237 | + */ |
|
| 238 | + public function group(Request $request, $groupName, $perPage = false, $sortBy = 'created_at', $desc = 1) |
|
| 239 | + { |
|
| 240 | + return \Response::json($this->repo->group($request->all(), $groupName, $this->relations, $perPage, $sortBy, $desc), 200); |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Save the given data to the logged in user. |
|
| 245 | + * |
|
| 246 | + * @param \Illuminate\Http\Request $request |
|
| 247 | + * @return \Illuminate\Http\Response |
|
| 248 | + */ |
|
| 249 | + public function saveProfile(Request $request) |
|
| 250 | + { |
|
| 251 | + foreach ($this->validationRules as &$rule) |
|
| 252 | + { |
|
| 253 | + if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) |
|
| 254 | + { |
|
| 255 | + $rule .= ',deleted_at,NULL'; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + if ($request->has('id')) |
|
| 259 | + { |
|
| 260 | + $rule = str_replace('{id}', $request->get('id'), $rule); |
|
| 261 | + } |
|
| 262 | + else |
|
| 263 | + { |
|
| 264 | + $rule = str_replace(',{id}', '', $rule); |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + $this->validate($request, $this->validationRules); |
|
| 269 | + |
|
| 270 | + if ($this->model) |
|
| 271 | + { |
|
| 272 | + return \Response::json(call_user_func_array("\Core::{$this->model}", [])->saveProfile($request->all()), 200); |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | 275 | } |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * Here goes your notification messages. |
|
| 7 | - */ |
|
| 5 | + /** |
|
| 6 | + * Here goes your notification messages. |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | ]; |
| 10 | 10 | \ No newline at end of file |
@@ -4,39 +4,39 @@ |
||
| 4 | 4 | |
| 5 | 5 | abstract class AbstractRepositoryContainer implements RepositoryContainerInterface |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Construct the repository class name based on |
|
| 9 | - * the method name called, search in the |
|
| 10 | - * given namespaces for the class and |
|
| 11 | - * return an instance. |
|
| 12 | - * |
|
| 13 | - * @param string $name the called method name |
|
| 14 | - * @param array $arguments the method arguments |
|
| 15 | - * @return object |
|
| 16 | - */ |
|
| 17 | - public function __call($name, $arguments) |
|
| 18 | - { |
|
| 19 | - foreach ($this->getRepoNameSpace() as $repoNameSpace) |
|
| 20 | - { |
|
| 21 | - $class = rtrim($repoNameSpace, '\\') . '\\' . ucfirst(str_singular($name)) . 'Repository'; |
|
| 22 | - if (class_exists($class)) |
|
| 23 | - { |
|
| 24 | - \App::singleton($class, function ($app) use ($class) { |
|
| 7 | + /** |
|
| 8 | + * Construct the repository class name based on |
|
| 9 | + * the method name called, search in the |
|
| 10 | + * given namespaces for the class and |
|
| 11 | + * return an instance. |
|
| 12 | + * |
|
| 13 | + * @param string $name the called method name |
|
| 14 | + * @param array $arguments the method arguments |
|
| 15 | + * @return object |
|
| 16 | + */ |
|
| 17 | + public function __call($name, $arguments) |
|
| 18 | + { |
|
| 19 | + foreach ($this->getRepoNameSpace() as $repoNameSpace) |
|
| 20 | + { |
|
| 21 | + $class = rtrim($repoNameSpace, '\\') . '\\' . ucfirst(str_singular($name)) . 'Repository'; |
|
| 22 | + if (class_exists($class)) |
|
| 23 | + { |
|
| 24 | + \App::singleton($class, function ($app) use ($class) { |
|
| 25 | 25 | |
| 26 | - return new \App\Modules\V1\Core\Decorators\CachingDecorator(new $class, $app['cache.store']); |
|
| 27 | - }); |
|
| 26 | + return new \App\Modules\V1\Core\Decorators\CachingDecorator(new $class, $app['cache.store']); |
|
| 27 | + }); |
|
| 28 | 28 | |
| 29 | - return \App::make($class); |
|
| 30 | - } |
|
| 31 | - } |
|
| 32 | - } |
|
| 29 | + return \App::make($class); |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Abstract methods that return the necessary |
|
| 36 | - * information (repositories namespaces) |
|
| 37 | - * needed to preform the previous actions. |
|
| 38 | - * |
|
| 39 | - * @return array |
|
| 40 | - */ |
|
| 41 | - abstract protected function getRepoNameSpace(); |
|
| 34 | + /** |
|
| 35 | + * Abstract methods that return the necessary |
|
| 36 | + * information (repositories namespaces) |
|
| 37 | + * needed to preform the previous actions. |
|
| 38 | + * |
|
| 39 | + * @return array |
|
| 40 | + */ |
|
| 41 | + abstract protected function getRepoNameSpace(); |
|
| 42 | 42 | } |
| 43 | 43 | \ No newline at end of file |
@@ -18,10 +18,10 @@ |
||
| 18 | 18 | { |
| 19 | 19 | foreach ($this->getRepoNameSpace() as $repoNameSpace) |
| 20 | 20 | { |
| 21 | - $class = rtrim($repoNameSpace, '\\') . '\\' . ucfirst(str_singular($name)) . 'Repository'; |
|
| 21 | + $class = rtrim($repoNameSpace, '\\').'\\'.ucfirst(str_singular($name)).'Repository'; |
|
| 22 | 22 | if (class_exists($class)) |
| 23 | 23 | { |
| 24 | - \App::singleton($class, function ($app) use ($class) { |
|
| 24 | + \App::singleton($class, function($app) use ($class) { |
|
| 25 | 25 | |
| 26 | 26 | return new \App\Modules\V1\Core\Decorators\CachingDecorator(new $class, $app['cache.store']); |
| 27 | 27 | }); |
@@ -13,13 +13,13 @@ |
||
| 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->text('value')->nullable(); |
|
| 20 | - $table->softDeletes(); |
|
| 21 | - $table->timestamps(); |
|
| 22 | - }); |
|
| 16 | + $table->increments('id'); |
|
| 17 | + $table->string('name',100); |
|
| 18 | + $table->string('key',100)->unique(); |
|
| 19 | + $table->text('value')->nullable(); |
|
| 20 | + $table->softDeletes(); |
|
| 21 | + $table->timestamps(); |
|
| 22 | + }); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -12,10 +12,10 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::create('settings', function (Blueprint $table) { |
|
| 15 | + Schema::create('settings', function(Blueprint $table) { |
|
| 16 | 16 | $table->increments('id'); |
| 17 | - $table->string('name',100); |
|
| 18 | - $table->string('key',100)->unique(); |
|
| 17 | + $table->string('name', 100); |
|
| 18 | + $table->string('key', 100)->unique(); |
|
| 19 | 19 | $table->text('value')->nullable(); |
| 20 | 20 | $table->softDeletes(); |
| 21 | 21 | $table->timestamps(); |
@@ -8,20 +8,20 @@ |
||
| 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' |
|
| 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' |
|
| 26 | + ]; |
|
| 27 | 27 | } |
@@ -13,14 +13,14 @@ |
||
| 13 | 13 | * to preform actions like (add, edit ... etc). |
| 14 | 14 | * @var string |
| 15 | 15 | */ |
| 16 | - protected $model = 'settings'; |
|
| 16 | + protected $model = 'settings'; |
|
| 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', |
| 25 | 25 | 'value' => 'required|string' |
| 26 | 26 | ]; |
@@ -7,50 +7,50 @@ |
||
| 7 | 7 | class ModuleServiceProvider extends ServiceProvider |
| 8 | 8 | { |
| 9 | 9 | /** |
| 10 | - * Bootstrap the module services. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function boot() |
|
| 15 | - { |
|
| 16 | - $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'core'); |
|
| 17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'core'); |
|
| 18 | - |
|
| 19 | - $factory = app('Illuminate\Database\Eloquent\Factory'); |
|
| 20 | - $factory->load(__DIR__.'/../Database/Factories'); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * Register the module services. |
|
| 25 | - * |
|
| 26 | - * @return void |
|
| 27 | - */ |
|
| 28 | - public function register() |
|
| 29 | - { |
|
| 30 | - //Bind Core Facade to the IoC Container |
|
| 31 | - \App::bind('Core', function() |
|
| 32 | - { |
|
| 33 | - return new \App\Modules\V1\Core\Core; |
|
| 34 | - }); |
|
| 35 | - |
|
| 36 | - //Bind ErrorHandler Facade to the IoC Container |
|
| 37 | - \App::bind('ErrorHandler', function() |
|
| 38 | - { |
|
| 39 | - return new \App\Modules\V1\Core\Utl\ErrorHandler; |
|
| 40 | - }); |
|
| 41 | - |
|
| 42 | - //Bind CoreConfig Facade to the IoC Container |
|
| 43 | - \App::bind('CoreConfig', function() |
|
| 44 | - { |
|
| 45 | - return new \App\Modules\V1\Core\Utl\CoreConfig; |
|
| 46 | - }); |
|
| 47 | - |
|
| 48 | - //Bind Logging Facade to the IoC Container |
|
| 49 | - \App::bind('Logging', function() |
|
| 50 | - { |
|
| 51 | - return new \App\Modules\V1\Core\Utl\Logging; |
|
| 52 | - }); |
|
| 10 | + * Bootstrap the module services. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function boot() |
|
| 15 | + { |
|
| 16 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'core'); |
|
| 17 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'core'); |
|
| 18 | + |
|
| 19 | + $factory = app('Illuminate\Database\Eloquent\Factory'); |
|
| 20 | + $factory->load(__DIR__.'/../Database/Factories'); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * Register the module services. |
|
| 25 | + * |
|
| 26 | + * @return void |
|
| 27 | + */ |
|
| 28 | + public function register() |
|
| 29 | + { |
|
| 30 | + //Bind Core Facade to the IoC Container |
|
| 31 | + \App::bind('Core', function() |
|
| 32 | + { |
|
| 33 | + return new \App\Modules\V1\Core\Core; |
|
| 34 | + }); |
|
| 35 | + |
|
| 36 | + //Bind ErrorHandler Facade to the IoC Container |
|
| 37 | + \App::bind('ErrorHandler', function() |
|
| 38 | + { |
|
| 39 | + return new \App\Modules\V1\Core\Utl\ErrorHandler; |
|
| 40 | + }); |
|
| 41 | + |
|
| 42 | + //Bind CoreConfig Facade to the IoC Container |
|
| 43 | + \App::bind('CoreConfig', function() |
|
| 44 | + { |
|
| 45 | + return new \App\Modules\V1\Core\Utl\CoreConfig; |
|
| 46 | + }); |
|
| 47 | + |
|
| 48 | + //Bind Logging Facade to the IoC Container |
|
| 49 | + \App::bind('Logging', function() |
|
| 50 | + { |
|
| 51 | + return new \App\Modules\V1\Core\Utl\Logging; |
|
| 52 | + }); |
|
| 53 | 53 | |
| 54 | - $this->app->register(RouteServiceProvider::class); |
|
| 55 | - } |
|
| 54 | + $this->app->register(RouteServiceProvider::class); |
|
| 55 | + } |
|
| 56 | 56 | } |