@@ -2,123 +2,123 @@ |
||
| 2 | 2 | |
| 3 | 3 | class ErrorHandler |
| 4 | 4 | { |
| 5 | - public function unAuthorized() |
|
| 6 | - { |
|
| 7 | - $error = ['status' => 401, 'message' => trans('core::errors.unAuthorized')]; |
|
| 8 | - abort($error['status'], $error['message']); |
|
| 9 | - } |
|
| 10 | - |
|
| 11 | - public function invalidRefreshToken() |
|
| 12 | - { |
|
| 13 | - $error = ['status' => 400, 'message' => trans('core::errors.invalidRefreshToken')]; |
|
| 14 | - abort($error['status'], $error['message']); |
|
| 15 | - } |
|
| 16 | - |
|
| 17 | - public function noPermissions() |
|
| 18 | - { |
|
| 19 | - $error = ['status' => 403, 'message' => trans('core::errors.noPermissions')]; |
|
| 20 | - abort($error['status'], $error['message']); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - public function loginFailed() |
|
| 24 | - { |
|
| 25 | - $error = ['status' => 400, 'message' => trans('core::errors.loginFailed')]; |
|
| 26 | - abort($error['status'], $error['message']); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public function noSocialEmail() |
|
| 30 | - { |
|
| 31 | - $error = ['status' => 400, 'message' => trans('core::errors.noSocialEmail')]; |
|
| 32 | - abort($error['status'], $error['message']); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - public function userAlreadyRegistered() |
|
| 36 | - { |
|
| 37 | - $error = ['status' => 400, 'message' => trans('core::errors.userAlreadyRegistered')]; |
|
| 38 | - abort($error['status'], $error['message']); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - public function connectionError() |
|
| 42 | - { |
|
| 43 | - $error = ['status' => 400, 'message' => trans('core::errors.connectionError')]; |
|
| 44 | - abort($error['status'], $error['message']); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - public function redisNotRunning() |
|
| 48 | - { |
|
| 49 | - $error = ['status' => 400, 'message' => trans('core::errors.redisNotRunning')]; |
|
| 50 | - abort($error['status'], $error['message']); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - public function dbQueryError() |
|
| 54 | - { |
|
| 55 | - $error = ['status' => 400, 'message' => trans('core::errors.dbQueryError')]; |
|
| 56 | - abort($error['status'], $error['message']); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - public function cannotCreateSetting() |
|
| 60 | - { |
|
| 61 | - $error = ['status' => 400, 'message' => trans('core::errors.cannotCreateSetting')]; |
|
| 62 | - abort($error['status'], $error['message']); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - public function cannotUpdateSettingKey() |
|
| 66 | - { |
|
| 67 | - $error = ['status' => 400, 'message' => trans('core::errors.cannotUpdateSettingKey')]; |
|
| 68 | - abort($error['status'], $error['message']); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - public function userIsBlocked() |
|
| 72 | - { |
|
| 73 | - $error = ['status' => 403, 'message' => trans('core::errors.userIsBlocked')]; |
|
| 74 | - abort($error['status'], $error['message']); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - public function emailNotConfirmed() |
|
| 78 | - { |
|
| 79 | - $error = ['status' => 403, 'message' => trans('core::errors.emailNotConfirmed')]; |
|
| 80 | - abort($error['status'], $error['message']); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - public function emailAlreadyConfirmed() |
|
| 84 | - { |
|
| 85 | - $error = ['status' => 403, 'message' => trans('core::errors.emailAlreadyConfirmed')]; |
|
| 86 | - abort($error['status'], $error['message']); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - public function invalidResetToken() |
|
| 90 | - { |
|
| 91 | - $error = ['status' => 400, 'message' => trans('core::errors.invalidResetToken')]; |
|
| 92 | - abort($error['status'], $error['message']); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - public function invalidResetPassword() |
|
| 96 | - { |
|
| 97 | - $error = ['status' => 400, 'message' => trans('core::errors.invalidResetPassword')]; |
|
| 98 | - abort($error['status'], $error['message']); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - public function invalidOldPassword() |
|
| 102 | - { |
|
| 103 | - $error = ['status' => 400, 'message' => trans('core::errors.invalidOldPassword')]; |
|
| 104 | - abort($error['status'], $error['message']); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - public function invalidConfirmationCode() |
|
| 108 | - { |
|
| 109 | - $error = ['status' => 400, 'message' => trans('core::errors.invalidConfirmationCode')]; |
|
| 110 | - abort($error['status'], $error['message']); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - public function notFound($text) |
|
| 114 | - { |
|
| 115 | - $error = ['status' => 404, 'message' => trans('core::errors.notFound', ['replace' => $text])]; |
|
| 116 | - abort($error['status'], $error['message']); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - public function generalError() |
|
| 120 | - { |
|
| 121 | - $error = ['status' => 400, 'message' => trans('core::errors.generalError')]; |
|
| 122 | - abort($error['status'], $error['message']); |
|
| 123 | - } |
|
| 5 | + public function unAuthorized() |
|
| 6 | + { |
|
| 7 | + $error = ['status' => 401, 'message' => trans('core::errors.unAuthorized')]; |
|
| 8 | + abort($error['status'], $error['message']); |
|
| 9 | + } |
|
| 10 | + |
|
| 11 | + public function invalidRefreshToken() |
|
| 12 | + { |
|
| 13 | + $error = ['status' => 400, 'message' => trans('core::errors.invalidRefreshToken')]; |
|
| 14 | + abort($error['status'], $error['message']); |
|
| 15 | + } |
|
| 16 | + |
|
| 17 | + public function noPermissions() |
|
| 18 | + { |
|
| 19 | + $error = ['status' => 403, 'message' => trans('core::errors.noPermissions')]; |
|
| 20 | + abort($error['status'], $error['message']); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + public function loginFailed() |
|
| 24 | + { |
|
| 25 | + $error = ['status' => 400, 'message' => trans('core::errors.loginFailed')]; |
|
| 26 | + abort($error['status'], $error['message']); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public function noSocialEmail() |
|
| 30 | + { |
|
| 31 | + $error = ['status' => 400, 'message' => trans('core::errors.noSocialEmail')]; |
|
| 32 | + abort($error['status'], $error['message']); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + public function userAlreadyRegistered() |
|
| 36 | + { |
|
| 37 | + $error = ['status' => 400, 'message' => trans('core::errors.userAlreadyRegistered')]; |
|
| 38 | + abort($error['status'], $error['message']); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + public function connectionError() |
|
| 42 | + { |
|
| 43 | + $error = ['status' => 400, 'message' => trans('core::errors.connectionError')]; |
|
| 44 | + abort($error['status'], $error['message']); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + public function redisNotRunning() |
|
| 48 | + { |
|
| 49 | + $error = ['status' => 400, 'message' => trans('core::errors.redisNotRunning')]; |
|
| 50 | + abort($error['status'], $error['message']); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + public function dbQueryError() |
|
| 54 | + { |
|
| 55 | + $error = ['status' => 400, 'message' => trans('core::errors.dbQueryError')]; |
|
| 56 | + abort($error['status'], $error['message']); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + public function cannotCreateSetting() |
|
| 60 | + { |
|
| 61 | + $error = ['status' => 400, 'message' => trans('core::errors.cannotCreateSetting')]; |
|
| 62 | + abort($error['status'], $error['message']); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + public function cannotUpdateSettingKey() |
|
| 66 | + { |
|
| 67 | + $error = ['status' => 400, 'message' => trans('core::errors.cannotUpdateSettingKey')]; |
|
| 68 | + abort($error['status'], $error['message']); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + public function userIsBlocked() |
|
| 72 | + { |
|
| 73 | + $error = ['status' => 403, 'message' => trans('core::errors.userIsBlocked')]; |
|
| 74 | + abort($error['status'], $error['message']); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + public function emailNotConfirmed() |
|
| 78 | + { |
|
| 79 | + $error = ['status' => 403, 'message' => trans('core::errors.emailNotConfirmed')]; |
|
| 80 | + abort($error['status'], $error['message']); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + public function emailAlreadyConfirmed() |
|
| 84 | + { |
|
| 85 | + $error = ['status' => 403, 'message' => trans('core::errors.emailAlreadyConfirmed')]; |
|
| 86 | + abort($error['status'], $error['message']); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + public function invalidResetToken() |
|
| 90 | + { |
|
| 91 | + $error = ['status' => 400, 'message' => trans('core::errors.invalidResetToken')]; |
|
| 92 | + abort($error['status'], $error['message']); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + public function invalidResetPassword() |
|
| 96 | + { |
|
| 97 | + $error = ['status' => 400, 'message' => trans('core::errors.invalidResetPassword')]; |
|
| 98 | + abort($error['status'], $error['message']); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + public function invalidOldPassword() |
|
| 102 | + { |
|
| 103 | + $error = ['status' => 400, 'message' => trans('core::errors.invalidOldPassword')]; |
|
| 104 | + abort($error['status'], $error['message']); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + public function invalidConfirmationCode() |
|
| 108 | + { |
|
| 109 | + $error = ['status' => 400, 'message' => trans('core::errors.invalidConfirmationCode')]; |
|
| 110 | + abort($error['status'], $error['message']); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + public function notFound($text) |
|
| 114 | + { |
|
| 115 | + $error = ['status' => 404, 'message' => trans('core::errors.notFound', ['replace' => $text])]; |
|
| 116 | + abort($error['status'], $error['message']); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + public function generalError() |
|
| 120 | + { |
|
| 121 | + $error = ['status' => 400, 'message' => trans('core::errors.generalError')]; |
|
| 122 | + abort($error['status'], $error['message']); |
|
| 123 | + } |
|
| 124 | 124 | } |
@@ -13,16 +13,16 @@ |
||
| 13 | 13 | |
| 14 | 14 | Route::group(['prefix' => 'core'], function () { |
| 15 | 15 | |
| 16 | - Route::group(['prefix' => 'settings'], function () { |
|
| 16 | + Route::group(['prefix' => 'settings'], function () { |
|
| 17 | 17 | |
| 18 | - Route::get('list/{sortBy?}/{desc?}', 'SettingsController@index'); |
|
| 19 | - Route::get('find/{id}', 'SettingsController@find'); |
|
| 20 | - Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'SettingsController@search'); |
|
| 21 | - Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'SettingsController@paginate'); |
|
| 22 | - Route::post('first', 'SettingsController@first'); |
|
| 23 | - Route::post('findby/{sortBy?}/{desc?}', 'SettingsController@findby'); |
|
| 24 | - Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'SettingsController@paginateby'); |
|
| 25 | - Route::post('save', 'SettingsController@save'); |
|
| 26 | - Route::post('save/many', 'SettingsController@saveMany'); |
|
| 27 | - }); |
|
| 18 | + Route::get('list/{sortBy?}/{desc?}', 'SettingsController@index'); |
|
| 19 | + Route::get('find/{id}', 'SettingsController@find'); |
|
| 20 | + Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'SettingsController@search'); |
|
| 21 | + Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'SettingsController@paginate'); |
|
| 22 | + Route::post('first', 'SettingsController@first'); |
|
| 23 | + Route::post('findby/{sortBy?}/{desc?}', 'SettingsController@findby'); |
|
| 24 | + Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'SettingsController@paginateby'); |
|
| 25 | + Route::post('save', 'SettingsController@save'); |
|
| 26 | + Route::post('save/many', 'SettingsController@saveMany'); |
|
| 27 | + }); |
|
| 28 | 28 | }); |
@@ -11,9 +11,9 @@ |
||
| 11 | 11 | | |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -Route::group(['prefix' => 'core'], function () { |
|
| 14 | +Route::group(['prefix' => 'core'], function() { |
|
| 15 | 15 | |
| 16 | - Route::group(['prefix' => 'settings'], function () { |
|
| 16 | + Route::group(['prefix' => 'settings'], function() { |
|
| 17 | 17 | |
| 18 | 18 | Route::get('list/{sortBy?}/{desc?}', 'SettingsController@index'); |
| 19 | 19 | Route::get('find/{id}', 'SettingsController@find'); |
@@ -6,67 +6,67 @@ |
||
| 6 | 6 | class SettingsObserver |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - public function saving($model) |
|
| 10 | - { |
|
| 11 | - // |
|
| 12 | - } |
|
| 9 | + public function saving($model) |
|
| 10 | + { |
|
| 11 | + // |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - public function saved($model) |
|
| 15 | - { |
|
| 16 | - // |
|
| 17 | - } |
|
| 14 | + public function saved($model) |
|
| 15 | + { |
|
| 16 | + // |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Prevent the creating of the settings. |
|
| 21 | - * |
|
| 22 | - * @param object $model the model beign created. |
|
| 23 | - * @return void |
|
| 24 | - */ |
|
| 25 | - public function creating($model) |
|
| 26 | - { |
|
| 27 | - \ErrorHandler::cannotCreateSetting(); |
|
| 28 | - } |
|
| 19 | + /** |
|
| 20 | + * Prevent the creating of the settings. |
|
| 21 | + * |
|
| 22 | + * @param object $model the model beign created. |
|
| 23 | + * @return void |
|
| 24 | + */ |
|
| 25 | + public function creating($model) |
|
| 26 | + { |
|
| 27 | + \ErrorHandler::cannotCreateSetting(); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - public function created($model) |
|
| 31 | - { |
|
| 32 | - // |
|
| 33 | - } |
|
| 30 | + public function created($model) |
|
| 31 | + { |
|
| 32 | + // |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Prevent updating of the setting key. |
|
| 37 | - * |
|
| 38 | - * @param object $model the model beign updated. |
|
| 39 | - * @return void |
|
| 40 | - */ |
|
| 41 | - public function updating($model) |
|
| 42 | - { |
|
| 43 | - if ($model->getOriginal('key') !== $model->key) { |
|
| 44 | - \ErrorHandler::cannotUpdateSettingKey(); |
|
| 45 | - } |
|
| 46 | - } |
|
| 35 | + /** |
|
| 36 | + * Prevent updating of the setting key. |
|
| 37 | + * |
|
| 38 | + * @param object $model the model beign updated. |
|
| 39 | + * @return void |
|
| 40 | + */ |
|
| 41 | + public function updating($model) |
|
| 42 | + { |
|
| 43 | + if ($model->getOriginal('key') !== $model->key) { |
|
| 44 | + \ErrorHandler::cannotUpdateSettingKey(); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function updated($model) |
|
| 49 | - { |
|
| 50 | - // |
|
| 51 | - } |
|
| 48 | + public function updated($model) |
|
| 49 | + { |
|
| 50 | + // |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function deleting($model) |
|
| 54 | - { |
|
| 55 | - // |
|
| 56 | - } |
|
| 53 | + public function deleting($model) |
|
| 54 | + { |
|
| 55 | + // |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function deleted($model) |
|
| 59 | - { |
|
| 60 | - // |
|
| 61 | - } |
|
| 58 | + public function deleted($model) |
|
| 59 | + { |
|
| 60 | + // |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function restoring($model) |
|
| 64 | - { |
|
| 65 | - // |
|
| 66 | - } |
|
| 63 | + public function restoring($model) |
|
| 64 | + { |
|
| 65 | + // |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - public function restored($model) |
|
| 69 | - { |
|
| 70 | - // |
|
| 71 | - } |
|
| 68 | + public function restored($model) |
|
| 69 | + { |
|
| 70 | + // |
|
| 71 | + } |
|
| 72 | 72 | } |
@@ -6,37 +6,37 @@ |
||
| 6 | 6 | class Settings extends Model |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - use SoftDeletes; |
|
| 10 | - protected $table = 'settings'; |
|
| 11 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 12 | - protected $hidden = ['deleted_at']; |
|
| 13 | - protected $guarded = ['id', 'key']; |
|
| 14 | - protected $fillable = ['name', 'value']; |
|
| 15 | - public $searchable = ['name', 'value', 'key']; |
|
| 9 | + use SoftDeletes; |
|
| 10 | + protected $table = 'settings'; |
|
| 11 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 12 | + protected $hidden = ['deleted_at']; |
|
| 13 | + protected $guarded = ['id', 'key']; |
|
| 14 | + protected $fillable = ['name', 'value']; |
|
| 15 | + public $searchable = ['name', 'value', 'key']; |
|
| 16 | 16 | |
| 17 | - public function getCreatedAtAttribute($value) |
|
| 18 | - { |
|
| 19 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 20 | - } |
|
| 17 | + public function getCreatedAtAttribute($value) |
|
| 18 | + { |
|
| 19 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - public function getUpdatedAtAttribute($value) |
|
| 23 | - { |
|
| 24 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 25 | - } |
|
| 22 | + public function getUpdatedAtAttribute($value) |
|
| 23 | + { |
|
| 24 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - public function getDeletedAtAttribute($value) |
|
| 28 | - { |
|
| 29 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 30 | - } |
|
| 27 | + public function getDeletedAtAttribute($value) |
|
| 28 | + { |
|
| 29 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public function newCollection(array $models = []) |
|
| 33 | - { |
|
| 34 | - return parent::newCollection($models)->keyBy('key'); |
|
| 35 | - } |
|
| 32 | + public function newCollection(array $models = []) |
|
| 33 | + { |
|
| 34 | + return parent::newCollection($models)->keyBy('key'); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public static function boot() |
|
| 38 | - { |
|
| 39 | - parent::boot(); |
|
| 40 | - Settings::observe(\App::make('App\Modules\Core\ModelObservers\SettingsObserver')); |
|
| 41 | - } |
|
| 37 | + public static function boot() |
|
| 38 | + { |
|
| 39 | + parent::boot(); |
|
| 40 | + Settings::observe(\App::make('App\Modules\Core\ModelObservers\SettingsObserver')); |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -5,37 +5,37 @@ |
||
| 5 | 5 | |
| 6 | 6 | abstract class AbstractRepositoryContainer implements RepositoryContainerInterface |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Construct the repository class name based on |
|
| 10 | - * the method name called, search in the |
|
| 11 | - * given namespaces for the class and |
|
| 12 | - * return an instance. |
|
| 13 | - * |
|
| 14 | - * @param string $name the called method name |
|
| 15 | - * @param array $arguments the method arguments |
|
| 16 | - * @return object |
|
| 17 | - */ |
|
| 18 | - public function __call($name, $arguments) |
|
| 19 | - { |
|
| 20 | - foreach ($this->getRepoNameSpace() as $repoNameSpace) { |
|
| 21 | - $class = rtrim($repoNameSpace, '\\').'\\'.ucfirst(Str::singular($name)).'Repository'; |
|
| 22 | - if (class_exists($class)) { |
|
| 23 | - \App::singleton($class, function ($app) use ($class) { |
|
| 8 | + /** |
|
| 9 | + * Construct the repository class name based on |
|
| 10 | + * the method name called, search in the |
|
| 11 | + * given namespaces for the class and |
|
| 12 | + * return an instance. |
|
| 13 | + * |
|
| 14 | + * @param string $name the called method name |
|
| 15 | + * @param array $arguments the method arguments |
|
| 16 | + * @return object |
|
| 17 | + */ |
|
| 18 | + public function __call($name, $arguments) |
|
| 19 | + { |
|
| 20 | + foreach ($this->getRepoNameSpace() as $repoNameSpace) { |
|
| 21 | + $class = rtrim($repoNameSpace, '\\').'\\'.ucfirst(Str::singular($name)).'Repository'; |
|
| 22 | + if (class_exists($class)) { |
|
| 23 | + \App::singleton($class, function ($app) use ($class) { |
|
| 24 | 24 | |
| 25 | - return new \App\Modules\Core\Decorators\CachingDecorator(new $class, $app['cache.store']); |
|
| 26 | - }); |
|
| 25 | + return new \App\Modules\Core\Decorators\CachingDecorator(new $class, $app['cache.store']); |
|
| 26 | + }); |
|
| 27 | 27 | |
| 28 | - return \App::make($class); |
|
| 29 | - } |
|
| 30 | - } |
|
| 31 | - } |
|
| 28 | + return \App::make($class); |
|
| 29 | + } |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Abstract methods that return the necessary |
|
| 35 | - * information (repositories namespaces) |
|
| 36 | - * needed to preform the previous actions. |
|
| 37 | - * |
|
| 38 | - * @return array |
|
| 39 | - */ |
|
| 40 | - abstract protected function getRepoNameSpace(); |
|
| 33 | + /** |
|
| 34 | + * Abstract methods that return the necessary |
|
| 35 | + * information (repositories namespaces) |
|
| 36 | + * needed to preform the previous actions. |
|
| 37 | + * |
|
| 38 | + * @return array |
|
| 39 | + */ |
|
| 40 | + abstract protected function getRepoNameSpace(); |
|
| 41 | 41 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | foreach ($this->getRepoNameSpace() as $repoNameSpace) { |
| 21 | 21 | $class = rtrim($repoNameSpace, '\\').'\\'.ucfirst(Str::singular($name)).'Repository'; |
| 22 | 22 | if (class_exists($class)) { |
| 23 | - \App::singleton($class, function ($app) use ($class) { |
|
| 23 | + \App::singleton($class, function($app) use ($class) { |
|
| 24 | 24 | |
| 25 | 25 | return new \App\Modules\Core\Decorators\CachingDecorator(new $class, $app['cache.store']); |
| 26 | 26 | }); |
@@ -2,46 +2,46 @@ |
||
| 2 | 2 | |
| 3 | 3 | trait Translatable |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * Create a new model instance that is existing. |
|
| 7 | - * |
|
| 8 | - * @param array $attributes |
|
| 9 | - * @param string|null $connection |
|
| 10 | - * @return static |
|
| 11 | - */ |
|
| 12 | - public function newFromBuilder($attributes = [], $connection = null) |
|
| 13 | - { |
|
| 14 | - $model = parent::newFromBuilder($attributes, $connection); |
|
| 5 | + /** |
|
| 6 | + * Create a new model instance that is existing. |
|
| 7 | + * |
|
| 8 | + * @param array $attributes |
|
| 9 | + * @param string|null $connection |
|
| 10 | + * @return static |
|
| 11 | + */ |
|
| 12 | + public function newFromBuilder($attributes = [], $connection = null) |
|
| 13 | + { |
|
| 14 | + $model = parent::newFromBuilder($attributes, $connection); |
|
| 15 | 15 | |
| 16 | - foreach ($model->attributes as $key => $value) { |
|
| 17 | - if (isset($this->translatable) && in_array($key, $this->translatable)) { |
|
| 18 | - $model->$key = $this->getTranslatedAttribute($value); |
|
| 19 | - } |
|
| 20 | - } |
|
| 16 | + foreach ($model->attributes as $key => $value) { |
|
| 17 | + if (isset($this->translatable) && in_array($key, $this->translatable)) { |
|
| 18 | + $model->$key = $this->getTranslatedAttribute($value); |
|
| 19 | + } |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - return $model; |
|
| 23 | - } |
|
| 22 | + return $model; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Returns a translatable model attribute based on the application's locale settings. |
|
| 27 | - * |
|
| 28 | - * @param $values |
|
| 29 | - * @return string |
|
| 30 | - */ |
|
| 31 | - protected function getTranslatedAttribute($values) |
|
| 32 | - { |
|
| 33 | - $values = json_decode($values); |
|
| 34 | - $primaryLocale = \Session::get('locale'); |
|
| 35 | - $fallbackLocale = 'en'; |
|
| 25 | + /** |
|
| 26 | + * Returns a translatable model attribute based on the application's locale settings. |
|
| 27 | + * |
|
| 28 | + * @param $values |
|
| 29 | + * @return string |
|
| 30 | + */ |
|
| 31 | + protected function getTranslatedAttribute($values) |
|
| 32 | + { |
|
| 33 | + $values = json_decode($values); |
|
| 34 | + $primaryLocale = \Session::get('locale'); |
|
| 35 | + $fallbackLocale = 'en'; |
|
| 36 | 36 | |
| 37 | - if ($primaryLocale == 'all') { |
|
| 38 | - return $values; |
|
| 39 | - } |
|
| 37 | + if ($primaryLocale == 'all') { |
|
| 38 | + return $values; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - if (! $primaryLocale || ! is_object($values) || ! property_exists($values, $primaryLocale)) { |
|
| 42 | - return $values ? isset($values->$fallbackLocale) ? $values->$fallbackLocale : $values : ''; |
|
| 43 | - } |
|
| 41 | + if (! $primaryLocale || ! is_object($values) || ! property_exists($values, $primaryLocale)) { |
|
| 42 | + return $values ? isset($values->$fallbackLocale) ? $values->$fallbackLocale : $values : ''; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - return $primaryLocale == 'all' ? $values : $values->$primaryLocale; |
|
| 46 | - } |
|
| 45 | + return $primaryLocale == 'all' ? $values : $values->$primaryLocale; |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -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,28 +4,28 @@ |
||
| 4 | 4 | |
| 5 | 5 | class SettingRepository extends AbstractRepository |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Return the model full namespace. |
|
| 9 | - * |
|
| 10 | - * @return string |
|
| 11 | - */ |
|
| 12 | - protected function getModel() |
|
| 13 | - { |
|
| 14 | - return 'App\Modules\Core\Settings'; |
|
| 15 | - } |
|
| 7 | + /** |
|
| 8 | + * Return the model full namespace. |
|
| 9 | + * |
|
| 10 | + * @return string |
|
| 11 | + */ |
|
| 12 | + protected function getModel() |
|
| 13 | + { |
|
| 14 | + return 'App\Modules\Core\Settings'; |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Save list of settings. |
|
| 19 | - * |
|
| 20 | - * @param array $data |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public function saveMany(array $data) |
|
| 24 | - { |
|
| 25 | - \DB::transaction(function () use ($data) { |
|
| 26 | - foreach ($data as $value) { |
|
| 27 | - $this->save($value); |
|
| 28 | - } |
|
| 29 | - }); |
|
| 30 | - } |
|
| 17 | + /** |
|
| 18 | + * Save list of settings. |
|
| 19 | + * |
|
| 20 | + * @param array $data |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public function saveMany(array $data) |
|
| 24 | + { |
|
| 25 | + \DB::transaction(function () use ($data) { |
|
| 26 | + foreach ($data as $value) { |
|
| 27 | + $this->save($value); |
|
| 28 | + } |
|
| 29 | + }); |
|
| 30 | + } |
|
| 31 | 31 | } |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | public function saveMany(array $data) |
| 24 | 24 | { |
| 25 | - \DB::transaction(function () use ($data) { |
|
| 25 | + \DB::transaction(function() use ($data) { |
|
| 26 | 26 | foreach ($data as $value) { |
| 27 | 27 | $this->save($value); |
| 28 | 28 | } |
@@ -7,66 +7,66 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Handler extends ExceptionHandler |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * A list of the exception types that are not reported. |
|
| 12 | - * |
|
| 13 | - * @var array |
|
| 14 | - */ |
|
| 15 | - protected $dontReport = [ |
|
| 16 | - \League\OAuth2\Server\Exception\OAuthServerException::class, |
|
| 17 | - ]; |
|
| 10 | + /** |
|
| 11 | + * A list of the exception types that are not reported. |
|
| 12 | + * |
|
| 13 | + * @var array |
|
| 14 | + */ |
|
| 15 | + protected $dontReport = [ |
|
| 16 | + \League\OAuth2\Server\Exception\OAuthServerException::class, |
|
| 17 | + ]; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * A list of the inputs that are never flashed for validation exceptions. |
|
| 21 | - * |
|
| 22 | - * @var array |
|
| 23 | - */ |
|
| 24 | - protected $dontFlash = [ |
|
| 25 | - 'password', |
|
| 26 | - 'password_confirmation', |
|
| 27 | - ]; |
|
| 19 | + /** |
|
| 20 | + * A list of the inputs that are never flashed for validation exceptions. |
|
| 21 | + * |
|
| 22 | + * @var array |
|
| 23 | + */ |
|
| 24 | + protected $dontFlash = [ |
|
| 25 | + 'password', |
|
| 26 | + 'password_confirmation', |
|
| 27 | + ]; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Report or log an exception. |
|
| 31 | - * |
|
| 32 | - * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
|
| 33 | - * |
|
| 34 | - * @param \Exception $exception |
|
| 35 | - * @return void |
|
| 36 | - */ |
|
| 37 | - public function report(Exception $exception) |
|
| 38 | - { |
|
| 39 | - parent::report($exception); |
|
| 40 | - } |
|
| 29 | + /** |
|
| 30 | + * Report or log an exception. |
|
| 31 | + * |
|
| 32 | + * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
|
| 33 | + * |
|
| 34 | + * @param \Exception $exception |
|
| 35 | + * @return void |
|
| 36 | + */ |
|
| 37 | + public function report(Exception $exception) |
|
| 38 | + { |
|
| 39 | + parent::report($exception); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Render an exception into an HTTP response. |
|
| 44 | - * |
|
| 45 | - * @param \Illuminate\Http\Request $request |
|
| 46 | - * @param \Exception $exception |
|
| 47 | - * @return \Illuminate\Http\Response |
|
| 48 | - */ |
|
| 49 | - public function render($request, Exception $exception) |
|
| 50 | - { |
|
| 51 | - if ($request->wantsJson()) { |
|
| 52 | - if ($exception instanceof \Illuminate\Auth\AuthenticationException) { |
|
| 53 | - \ErrorHandler::unAuthorized(); |
|
| 54 | - } |
|
| 55 | - if ($exception instanceof \Illuminate\Database\QueryException) { |
|
| 56 | - \ErrorHandler::dbQueryError(); |
|
| 57 | - } elseif ($exception instanceof \predis\connection\connectionexception) { |
|
| 58 | - \ErrorHandler::redisNotRunning(); |
|
| 59 | - } elseif ($exception instanceof \GuzzleHttp\Exception\ClientException) { |
|
| 60 | - \ErrorHandler::connectionError(); |
|
| 61 | - } elseif ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException) { |
|
| 62 | - return \Response::json([$exception->getMessage()], $exception->getStatusCode()); |
|
| 63 | - } elseif ($exception instanceof \Illuminate\Validation\ValidationException) { |
|
| 64 | - return \Response::json($exception->errors(), 422); |
|
| 65 | - } elseif (! $exception instanceof \Symfony\Component\Debug\Exception\FatalErrorException) { |
|
| 66 | - return parent::render($request, $exception); |
|
| 67 | - } |
|
| 68 | - } |
|
| 42 | + /** |
|
| 43 | + * Render an exception into an HTTP response. |
|
| 44 | + * |
|
| 45 | + * @param \Illuminate\Http\Request $request |
|
| 46 | + * @param \Exception $exception |
|
| 47 | + * @return \Illuminate\Http\Response |
|
| 48 | + */ |
|
| 49 | + public function render($request, Exception $exception) |
|
| 50 | + { |
|
| 51 | + if ($request->wantsJson()) { |
|
| 52 | + if ($exception instanceof \Illuminate\Auth\AuthenticationException) { |
|
| 53 | + \ErrorHandler::unAuthorized(); |
|
| 54 | + } |
|
| 55 | + if ($exception instanceof \Illuminate\Database\QueryException) { |
|
| 56 | + \ErrorHandler::dbQueryError(); |
|
| 57 | + } elseif ($exception instanceof \predis\connection\connectionexception) { |
|
| 58 | + \ErrorHandler::redisNotRunning(); |
|
| 59 | + } elseif ($exception instanceof \GuzzleHttp\Exception\ClientException) { |
|
| 60 | + \ErrorHandler::connectionError(); |
|
| 61 | + } elseif ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException) { |
|
| 62 | + return \Response::json([$exception->getMessage()], $exception->getStatusCode()); |
|
| 63 | + } elseif ($exception instanceof \Illuminate\Validation\ValidationException) { |
|
| 64 | + return \Response::json($exception->errors(), 422); |
|
| 65 | + } elseif (! $exception instanceof \Symfony\Component\Debug\Exception\FatalErrorException) { |
|
| 66 | + return parent::render($request, $exception); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - return parent::render($request, $exception); |
|
| 71 | - } |
|
| 70 | + return parent::render($request, $exception); |
|
| 71 | + } |
|
| 72 | 72 | } |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | return \Response::json([$exception->getMessage()], $exception->getStatusCode()); |
| 63 | 63 | } elseif ($exception instanceof \Illuminate\Validation\ValidationException) { |
| 64 | 64 | return \Response::json($exception->errors(), 422); |
| 65 | - } elseif (! $exception instanceof \Symfony\Component\Debug\Exception\FatalErrorException) { |
|
| 65 | + } elseif ( ! $exception instanceof \Symfony\Component\Debug\Exception\FatalErrorException) { |
|
| 66 | 66 | return parent::render($request, $exception); |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -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 | ]; |