@@ -38,7 +38,7 @@ |
||
| 38 | 38 | return $values; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - if (! $primaryLocale || ! is_object($values) || ! property_exists($values, $primaryLocale)) { |
|
| 41 | + if ( ! $primaryLocale || ! is_object($values) || ! property_exists($values, $primaryLocale)) { |
|
| 42 | 42 | return $values ? isset($values->$fallbackLocale) ? $values->$fallbackLocale : $values : ''; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -4,46 +4,46 @@ |
||
| 4 | 4 | |
| 5 | 5 | trait Translatable |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Create a new model instance that is existing. |
|
| 9 | - * |
|
| 10 | - * @param array $attributes |
|
| 11 | - * @param string|null $connection |
|
| 12 | - * @return static |
|
| 13 | - */ |
|
| 14 | - public function newFromBuilder($attributes = [], $connection = null) |
|
| 15 | - { |
|
| 16 | - $model = parent::newFromBuilder($attributes, $connection); |
|
| 17 | - |
|
| 18 | - foreach ($model->attributes as $key => $value) { |
|
| 19 | - if (isset($this->translatable) && in_array($key, $this->translatable)) { |
|
| 20 | - $model->$key = $this->getTranslatedAttribute($value); |
|
| 21 | - } |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - return $model; |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * Returns a translatable model attribute based on the application's locale settings. |
|
| 29 | - * |
|
| 30 | - * @param $values |
|
| 31 | - * @return string |
|
| 32 | - */ |
|
| 33 | - protected function getTranslatedAttribute($values) |
|
| 34 | - { |
|
| 35 | - $values = json_decode($values); |
|
| 36 | - $primaryLocale = \Session::get('locale'); |
|
| 37 | - $fallbackLocale = 'en'; |
|
| 38 | - |
|
| 39 | - if ($primaryLocale == 'all') { |
|
| 40 | - return $values; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - if (! $primaryLocale || ! is_object($values) || ! property_exists($values, $primaryLocale)) { |
|
| 44 | - return $values ? isset($values->$fallbackLocale) ? $values->$fallbackLocale : $values : ''; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - return $primaryLocale == 'all' ? $values : $values->$primaryLocale; |
|
| 48 | - } |
|
| 7 | + /** |
|
| 8 | + * Create a new model instance that is existing. |
|
| 9 | + * |
|
| 10 | + * @param array $attributes |
|
| 11 | + * @param string|null $connection |
|
| 12 | + * @return static |
|
| 13 | + */ |
|
| 14 | + public function newFromBuilder($attributes = [], $connection = null) |
|
| 15 | + { |
|
| 16 | + $model = parent::newFromBuilder($attributes, $connection); |
|
| 17 | + |
|
| 18 | + foreach ($model->attributes as $key => $value) { |
|
| 19 | + if (isset($this->translatable) && in_array($key, $this->translatable)) { |
|
| 20 | + $model->$key = $this->getTranslatedAttribute($value); |
|
| 21 | + } |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + return $model; |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Returns a translatable model attribute based on the application's locale settings. |
|
| 29 | + * |
|
| 30 | + * @param $values |
|
| 31 | + * @return string |
|
| 32 | + */ |
|
| 33 | + protected function getTranslatedAttribute($values) |
|
| 34 | + { |
|
| 35 | + $values = json_decode($values); |
|
| 36 | + $primaryLocale = \Session::get('locale'); |
|
| 37 | + $fallbackLocale = 'en'; |
|
| 38 | + |
|
| 39 | + if ($primaryLocale == 'all') { |
|
| 40 | + return $values; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + if (! $primaryLocale || ! is_object($values) || ! property_exists($values, $primaryLocale)) { |
|
| 44 | + return $values ? isset($values->$fallbackLocale) ? $values->$fallbackLocale : $values : ''; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + return $primaryLocale == 'all' ? $values : $values->$primaryLocale; |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -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 | ]; |
@@ -2,15 +2,15 @@ |
||
| 2 | 2 | |
| 3 | 3 | interface BaseFactoryInterface |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * Construct the repository class name based on |
|
| 7 | - * the method name called, search in the |
|
| 8 | - * given namespaces for the class and |
|
| 9 | - * return an instance. |
|
| 10 | - * |
|
| 11 | - * @param string $name the called method name |
|
| 12 | - * @param array $arguments the method arguments |
|
| 13 | - * @return object |
|
| 14 | - */ |
|
| 15 | - public function __call($name, $arguments); |
|
| 5 | + /** |
|
| 6 | + * Construct the repository class name based on |
|
| 7 | + * the method name called, search in the |
|
| 8 | + * given namespaces for the class and |
|
| 9 | + * return an instance. |
|
| 10 | + * |
|
| 11 | + * @param string $name the called method name |
|
| 12 | + * @param array $arguments the method arguments |
|
| 13 | + * @return object |
|
| 14 | + */ |
|
| 15 | + public function __call($name, $arguments); |
|
| 16 | 16 | } |
@@ -6,14 +6,14 @@ |
||
| 6 | 6 | |
| 7 | 7 | class General extends JsonResource |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Transform the resource into an array. |
|
| 11 | - * |
|
| 12 | - * @param Request $request |
|
| 13 | - * @return array |
|
| 14 | - */ |
|
| 15 | - public function toArray($request) |
|
| 16 | - { |
|
| 17 | - return ['status' => $this->resource ?? 'success']; |
|
| 18 | - } |
|
| 9 | + /** |
|
| 10 | + * Transform the resource into an array. |
|
| 11 | + * |
|
| 12 | + * @param Request $request |
|
| 13 | + * @return array |
|
| 14 | + */ |
|
| 15 | + public function toArray($request) |
|
| 16 | + { |
|
| 17 | + return ['status' => $this->resource ?? 'success']; |
|
| 18 | + } |
|
| 19 | 19 | } |
@@ -1,7 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -use Illuminate\Http\Request; |
|
| 4 | - |
|
| 5 | 3 | /* |
| 6 | 4 | |-------------------------------------------------------------------------- |
| 7 | 5 | | API Routes |
@@ -15,6 +15,6 @@ |
||
| 15 | 15 | |
| 16 | 16 | Route::group(['prefix' => 'permissions'], function () { |
| 17 | 17 | |
| 18 | - Route::get('/', 'PermissionController@index'); |
|
| 19 | - Route::get('/{id}', 'PermissionController@show'); |
|
| 18 | + Route::get('/', 'PermissionController@index'); |
|
| 19 | + Route::get('/{id}', 'PermissionController@show'); |
|
| 20 | 20 | }); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | | |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -Route::group(['prefix' => 'permissions'], function () { |
|
| 16 | +Route::group(['prefix' => 'permissions'], function() { |
|
| 17 | 17 | |
| 18 | 18 | Route::get('/', 'PermissionController@index'); |
| 19 | 19 | Route::get('/{id}', 'PermissionController@show'); |
@@ -1,7 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -use Illuminate\Http\Request; |
|
| 4 | - |
|
| 5 | 3 | /* |
| 6 | 4 | |-------------------------------------------------------------------------- |
| 7 | 5 | | API Routes |
@@ -15,11 +15,11 @@ |
||
| 15 | 15 | |
| 16 | 16 | Route::group(['prefix' => 'push/notification/devices'], function () { |
| 17 | 17 | |
| 18 | - Route::get('/', 'PushNotificationDeviceController@index'); |
|
| 19 | - Route::get('{id}', 'PushNotificationDeviceController@show'); |
|
| 20 | - Route::post('/', 'PushNotificationDeviceController@store'); |
|
| 21 | - Route::patch('{id}', 'PushNotificationDeviceController@update'); |
|
| 22 | - Route::delete('{id}', 'PushNotificationDeviceController@destroy'); |
|
| 23 | - Route::patch('{id}/restore', 'PushNotificationDeviceController@restore'); |
|
| 24 | - Route::post('register/device', 'PushNotificationDeviceController@registerDevice'); |
|
| 18 | + Route::get('/', 'PushNotificationDeviceController@index'); |
|
| 19 | + Route::get('{id}', 'PushNotificationDeviceController@show'); |
|
| 20 | + Route::post('/', 'PushNotificationDeviceController@store'); |
|
| 21 | + Route::patch('{id}', 'PushNotificationDeviceController@update'); |
|
| 22 | + Route::delete('{id}', 'PushNotificationDeviceController@destroy'); |
|
| 23 | + Route::patch('{id}/restore', 'PushNotificationDeviceController@restore'); |
|
| 24 | + Route::post('register/device', 'PushNotificationDeviceController@registerDevice'); |
|
| 25 | 25 | }); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | | |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -Route::group(['prefix' => 'push/notification/devices'], function () { |
|
| 16 | +Route::group(['prefix' => 'push/notification/devices'], function() { |
|
| 17 | 17 | |
| 18 | 18 | Route::get('/', 'PushNotificationDeviceController@index'); |
| 19 | 19 | Route::get('{id}', 'PushNotificationDeviceController@show'); |
@@ -1,7 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -use Illuminate\Http\Request; |
|
| 4 | - |
|
| 5 | 3 | /* |
| 6 | 4 | |-------------------------------------------------------------------------- |
| 7 | 5 | | API Routes |
@@ -15,29 +15,29 @@ |
||
| 15 | 15 | |
| 16 | 16 | Route::group(['prefix' => 'users'], function () { |
| 17 | 17 | |
| 18 | - Route::get('/', 'UserController@index'); |
|
| 19 | - Route::get('{id}', 'UserController@show'); |
|
| 20 | - Route::post('/', 'UserController@store'); |
|
| 21 | - Route::patch('{id}', 'UserController@update'); |
|
| 22 | - Route::delete('{id}', 'UserController@destroy'); |
|
| 23 | - Route::patch('{id}/restore', 'UserController@restore'); |
|
| 24 | - Route::patch('{id}/block', 'UserController@block'); |
|
| 25 | - Route::patch('{id}/unblock', 'UserController@unblock'); |
|
| 26 | - Route::patch('{id}/assign/roles', 'UserController@assignRoles'); |
|
| 18 | + Route::get('/', 'UserController@index'); |
|
| 19 | + Route::get('{id}', 'UserController@show'); |
|
| 20 | + Route::post('/', 'UserController@store'); |
|
| 21 | + Route::patch('{id}', 'UserController@update'); |
|
| 22 | + Route::delete('{id}', 'UserController@destroy'); |
|
| 23 | + Route::patch('{id}/restore', 'UserController@restore'); |
|
| 24 | + Route::patch('{id}/block', 'UserController@block'); |
|
| 25 | + Route::patch('{id}/unblock', 'UserController@unblock'); |
|
| 26 | + Route::patch('{id}/assign/roles', 'UserController@assignRoles'); |
|
| 27 | 27 | |
| 28 | - Route::group(['prefix' => 'account'], function () { |
|
| 28 | + Route::group(['prefix' => 'account'], function () { |
|
| 29 | 29 | |
| 30 | - Route::get('my', 'UserController@account'); |
|
| 31 | - Route::get('logout', 'UserController@logout'); |
|
| 32 | - Route::post('refresh/token', 'UserController@refreshToken'); |
|
| 33 | - Route::post('save', 'UserController@saveProfile'); |
|
| 34 | - Route::post('register', 'UserController@register'); |
|
| 35 | - Route::post('login', 'UserController@login'); |
|
| 36 | - Route::post('login/social', 'UserController@loginSocial'); |
|
| 37 | - Route::post('send/reset', 'UserController@sendReset'); |
|
| 38 | - Route::post('reset/password', 'UserController@resetPassword'); |
|
| 39 | - Route::post('change/password', 'UserController@changePassword'); |
|
| 40 | - Route::post('confirm/email', 'UserController@confirmEmail'); |
|
| 41 | - Route::post('resend/email/confirmation', 'UserController@resendEmailConfirmation'); |
|
| 42 | - }); |
|
| 30 | + Route::get('my', 'UserController@account'); |
|
| 31 | + Route::get('logout', 'UserController@logout'); |
|
| 32 | + Route::post('refresh/token', 'UserController@refreshToken'); |
|
| 33 | + Route::post('save', 'UserController@saveProfile'); |
|
| 34 | + Route::post('register', 'UserController@register'); |
|
| 35 | + Route::post('login', 'UserController@login'); |
|
| 36 | + Route::post('login/social', 'UserController@loginSocial'); |
|
| 37 | + Route::post('send/reset', 'UserController@sendReset'); |
|
| 38 | + Route::post('reset/password', 'UserController@resetPassword'); |
|
| 39 | + Route::post('change/password', 'UserController@changePassword'); |
|
| 40 | + Route::post('confirm/email', 'UserController@confirmEmail'); |
|
| 41 | + Route::post('resend/email/confirmation', 'UserController@resendEmailConfirmation'); |
|
| 42 | + }); |
|
| 43 | 43 | }); |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | | |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -Route::group(['prefix' => 'users'], function () { |
|
| 16 | +Route::group(['prefix' => 'users'], function() { |
|
| 17 | 17 | |
| 18 | 18 | Route::get('/', 'UserController@index'); |
| 19 | 19 | Route::get('{id}', 'UserController@show'); |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | Route::patch('{id}/unblock', 'UserController@unblock'); |
| 26 | 26 | Route::patch('{id}/assign/roles', 'UserController@assignRoles'); |
| 27 | 27 | |
| 28 | - Route::group(['prefix' => 'account'], function () { |
|
| 28 | + Route::group(['prefix' => 'account'], function() { |
|
| 29 | 29 | |
| 30 | 30 | Route::get('my', 'UserController@account'); |
| 31 | 31 | Route::get('logout', 'UserController@logout'); |
@@ -7,73 +7,73 @@ |
||
| 7 | 7 | |
| 8 | 8 | class RouteServiceProvider extends ServiceProvider |
| 9 | 9 | { |
| 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\Users\Http\Controllers'; |
|
| 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\Users\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('users', 'Routes/web.php', 'app'); |
|
| 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('users', 'Routes/web.php', 'app'); |
|
| 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('users', 'Routes/api.php', 'app'); |
|
| 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('users', 'Routes/api.php', 'app'); |
|
| 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('users', 'Routes/web.php', 'app'); |
| 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('users', 'Routes/api.php', 'app'); |
| 77 | 77 | }); |
| 78 | 78 | } |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $factory->define(App\Modules\Users\AclUser::class, function (Faker\Generator $faker) { |
| 4 | - return [ |
|
| 5 | - 'profile_picture' => 'http://lorempixel.com/400/200/', |
|
| 6 | - 'name' => $faker->name(), |
|
| 7 | - 'email' => $faker->safeEmail(), |
|
| 8 | - 'password' => 123456, |
|
| 9 | - 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
| 10 | - 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
| 11 | - ]; |
|
| 4 | + return [ |
|
| 5 | + 'profile_picture' => 'http://lorempixel.com/400/200/', |
|
| 6 | + 'name' => $faker->name(), |
|
| 7 | + 'email' => $faker->safeEmail(), |
|
| 8 | + 'password' => 123456, |
|
| 9 | + 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
| 10 | + 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
| 11 | + ]; |
|
| 12 | 12 | }); |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$factory->define(App\Modules\Users\AclUser::class, function (Faker\Generator $faker) { |
|
| 3 | +$factory->define(App\Modules\Users\AclUser::class, function(Faker\Generator $faker) { |
|
| 4 | 4 | return [ |
| 5 | 5 | 'profile_picture' => 'http://lorempixel.com/400/200/', |
| 6 | 6 | 'name' => $faker->name(), |