@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $factory->define(App\Modules\Core\Settings::class, function (Faker\Generator $faker) { |
| 4 | - return [ |
|
| 4 | + return [ |
|
| 5 | 5 | 'name' => $faker->randomElement(['Company Name', 'Title', 'Header Image']), |
| 6 | 6 | 'value' => $faker->word(), |
| 7 | 7 | 'key' => $faker->word(), |
| 8 | 8 | 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
| 9 | 9 | 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
| 10 | - ]; |
|
| 10 | + ]; |
|
| 11 | 11 | }); |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$factory->define(App\Modules\Core\Settings::class, function (Faker\Generator $faker) { |
|
| 3 | +$factory->define(App\Modules\Core\Settings::class, function(Faker\Generator $faker) { |
|
| 4 | 4 | return [ |
| 5 | 5 | 'name' => $faker->randomElement(['Company Name', 'Title', 'Header Image']), |
| 6 | 6 | 'value' => $faker->word(), |
@@ -5,37 +5,37 @@ |
||
| 5 | 5 | |
| 6 | 6 | class Settings extends Model{ |
| 7 | 7 | |
| 8 | - use SoftDeletes; |
|
| 9 | - protected $table = 'settings'; |
|
| 10 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 11 | - protected $hidden = ['deleted_at']; |
|
| 12 | - protected $guarded = ['id', 'key']; |
|
| 13 | - protected $fillable = ['name','value']; |
|
| 14 | - public $searchable = ['name', 'value', 'key']; |
|
| 8 | + use SoftDeletes; |
|
| 9 | + protected $table = 'settings'; |
|
| 10 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 11 | + protected $hidden = ['deleted_at']; |
|
| 12 | + protected $guarded = ['id', 'key']; |
|
| 13 | + protected $fillable = ['name','value']; |
|
| 14 | + public $searchable = ['name', 'value', 'key']; |
|
| 15 | 15 | |
| 16 | - public function getCreatedAtAttribute($value) |
|
| 17 | - { |
|
| 18 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 19 | - } |
|
| 16 | + public function getCreatedAtAttribute($value) |
|
| 17 | + { |
|
| 18 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function getUpdatedAtAttribute($value) |
|
| 22 | - { |
|
| 23 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 24 | - } |
|
| 21 | + public function getUpdatedAtAttribute($value) |
|
| 22 | + { |
|
| 23 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - public function getDeletedAtAttribute($value) |
|
| 27 | - { |
|
| 28 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 29 | - } |
|
| 26 | + public function getDeletedAtAttribute($value) |
|
| 27 | + { |
|
| 28 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - public function newCollection(array $models = []) |
|
| 32 | - { |
|
| 33 | - return parent::newCollection($models)->keyBy('key'); |
|
| 34 | - } |
|
| 31 | + public function newCollection(array $models = []) |
|
| 32 | + { |
|
| 33 | + return parent::newCollection($models)->keyBy('key'); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - public static function boot() |
|
| 37 | - { |
|
| 38 | - parent::boot(); |
|
| 39 | - parent::observe(\App::make('App\Modules\Core\ModelObservers\SettingsObserver')); |
|
| 40 | - } |
|
| 36 | + public static function boot() |
|
| 37 | + { |
|
| 38 | + parent::boot(); |
|
| 39 | + parent::observe(\App::make('App\Modules\Core\ModelObservers\SettingsObserver')); |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -3,14 +3,14 @@ |
||
| 3 | 3 | use Illuminate\Database\Eloquent\Model; |
| 4 | 4 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 5 | 5 | |
| 6 | -class Settings extends Model{ |
|
| 6 | +class Settings extends Model { |
|
| 7 | 7 | |
| 8 | 8 | use SoftDeletes; |
| 9 | 9 | protected $table = 'settings'; |
| 10 | 10 | protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
| 11 | 11 | protected $hidden = ['deleted_at']; |
| 12 | 12 | protected $guarded = ['id', 'key']; |
| 13 | - protected $fillable = ['name','value']; |
|
| 13 | + protected $fillable = ['name', 'value']; |
|
| 14 | 14 | public $searchable = ['name', 'value', 'key']; |
| 15 | 15 | |
| 16 | 16 | public function getCreatedAtAttribute($value) |
@@ -2,118 +2,118 @@ |
||
| 2 | 2 | |
| 3 | 3 | interface RepositoryInterface |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * Fetch all records with relations from the storage. |
|
| 7 | - * |
|
| 8 | - * @param array $relations |
|
| 9 | - * @param array $sortBy |
|
| 10 | - * @param array $desc |
|
| 11 | - * @param array $columns |
|
| 12 | - * @return collection |
|
| 13 | - */ |
|
| 14 | - public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 5 | + /** |
|
| 6 | + * Fetch all records with relations from the storage. |
|
| 7 | + * |
|
| 8 | + * @param array $relations |
|
| 9 | + * @param array $sortBy |
|
| 10 | + * @param array $desc |
|
| 11 | + * @param array $columns |
|
| 12 | + * @return collection |
|
| 13 | + */ |
|
| 14 | + public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Fetch all records with relations from storage in pages |
|
| 18 | - * that matche the given query. |
|
| 19 | - * |
|
| 20 | - * @param string $query |
|
| 21 | - * @param integer $perPage |
|
| 22 | - * @param array $relations |
|
| 23 | - * @param array $sortBy |
|
| 24 | - * @param array $desc |
|
| 25 | - * @param array $columns |
|
| 26 | - * @return collection |
|
| 27 | - */ |
|
| 28 | - public function search($query, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 16 | + /** |
|
| 17 | + * Fetch all records with relations from storage in pages |
|
| 18 | + * that matche the given query. |
|
| 19 | + * |
|
| 20 | + * @param string $query |
|
| 21 | + * @param integer $perPage |
|
| 22 | + * @param array $relations |
|
| 23 | + * @param array $sortBy |
|
| 24 | + * @param array $desc |
|
| 25 | + * @param array $columns |
|
| 26 | + * @return collection |
|
| 27 | + */ |
|
| 28 | + public function search($query, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Fetch all records with relations from storage in pages. |
|
| 32 | - * |
|
| 33 | - * @param integer $perPage |
|
| 34 | - * @param array $relations |
|
| 35 | - * @param array $sortBy |
|
| 36 | - * @param array $desc |
|
| 37 | - * @param array $columns |
|
| 38 | - * @return collection |
|
| 39 | - */ |
|
| 40 | - public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 30 | + /** |
|
| 31 | + * Fetch all records with relations from storage in pages. |
|
| 32 | + * |
|
| 33 | + * @param integer $perPage |
|
| 34 | + * @param array $relations |
|
| 35 | + * @param array $sortBy |
|
| 36 | + * @param array $desc |
|
| 37 | + * @param array $columns |
|
| 38 | + * @return collection |
|
| 39 | + */ |
|
| 40 | + public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Fetch all records with relations based on |
|
| 44 | - * the given condition from storage in pages. |
|
| 45 | - * |
|
| 46 | - * @param array $conditions array of conditions |
|
| 47 | - * @param integer $perPage |
|
| 48 | - * @param array $relations |
|
| 49 | - * @param array $sortBy |
|
| 50 | - * @param array $desc |
|
| 51 | - * @param array $columns |
|
| 52 | - * @return collection |
|
| 53 | - */ |
|
| 54 | - public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 42 | + /** |
|
| 43 | + * Fetch all records with relations based on |
|
| 44 | + * the given condition from storage in pages. |
|
| 45 | + * |
|
| 46 | + * @param array $conditions array of conditions |
|
| 47 | + * @param integer $perPage |
|
| 48 | + * @param array $relations |
|
| 49 | + * @param array $sortBy |
|
| 50 | + * @param array $desc |
|
| 51 | + * @param array $columns |
|
| 52 | + * @return collection |
|
| 53 | + */ |
|
| 54 | + public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Save the given model/models to the storage. |
|
| 58 | - * |
|
| 59 | - * @param array $data |
|
| 60 | - * @return object |
|
| 61 | - */ |
|
| 62 | - public function save(array $data); |
|
| 56 | + /** |
|
| 57 | + * Save the given model/models to the storage. |
|
| 58 | + * |
|
| 59 | + * @param array $data |
|
| 60 | + * @return object |
|
| 61 | + */ |
|
| 62 | + public function save(array $data); |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Update record in the storage based on the given |
|
| 66 | - * condition. |
|
| 67 | - * |
|
| 68 | - * @param var $value condition value |
|
| 69 | - * @param array $data |
|
| 70 | - * @param string $attribute condition column name |
|
| 71 | - * @return integer affected rows |
|
| 72 | - */ |
|
| 73 | - public function update($value, array $data, $attribute = 'id'); |
|
| 64 | + /** |
|
| 65 | + * Update record in the storage based on the given |
|
| 66 | + * condition. |
|
| 67 | + * |
|
| 68 | + * @param var $value condition value |
|
| 69 | + * @param array $data |
|
| 70 | + * @param string $attribute condition column name |
|
| 71 | + * @return integer affected rows |
|
| 72 | + */ |
|
| 73 | + public function update($value, array $data, $attribute = 'id'); |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Delete record from the storage based on the given |
|
| 77 | - * condition. |
|
| 78 | - * |
|
| 79 | - * @param var $value condition value |
|
| 80 | - * @param string $attribute condition column name |
|
| 81 | - * @return integer affected rows |
|
| 82 | - */ |
|
| 83 | - public function delete($value, $attribute = 'id'); |
|
| 75 | + /** |
|
| 76 | + * Delete record from the storage based on the given |
|
| 77 | + * condition. |
|
| 78 | + * |
|
| 79 | + * @param var $value condition value |
|
| 80 | + * @param string $attribute condition column name |
|
| 81 | + * @return integer affected rows |
|
| 82 | + */ |
|
| 83 | + public function delete($value, $attribute = 'id'); |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Fetch records from the storage based on the given |
|
| 87 | - * id. |
|
| 88 | - * |
|
| 89 | - * @param integer $id |
|
| 90 | - * @param array $relations |
|
| 91 | - * @param array $columns |
|
| 92 | - * @return object |
|
| 93 | - */ |
|
| 94 | - public function find($id, $relations = [], $columns = array('*')); |
|
| 85 | + /** |
|
| 86 | + * Fetch records from the storage based on the given |
|
| 87 | + * id. |
|
| 88 | + * |
|
| 89 | + * @param integer $id |
|
| 90 | + * @param array $relations |
|
| 91 | + * @param array $columns |
|
| 92 | + * @return object |
|
| 93 | + */ |
|
| 94 | + public function find($id, $relations = [], $columns = array('*')); |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Fetch records from the storage based on the given |
|
| 98 | - * condition. |
|
| 99 | - * |
|
| 100 | - * @param array $conditions array of conditions |
|
| 101 | - * @param array $relations |
|
| 102 | - * @param array $sortBy |
|
| 103 | - * @param array $desc |
|
| 104 | - * @param array $columns |
|
| 105 | - * @return collection |
|
| 106 | - */ |
|
| 107 | - public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 96 | + /** |
|
| 97 | + * Fetch records from the storage based on the given |
|
| 98 | + * condition. |
|
| 99 | + * |
|
| 100 | + * @param array $conditions array of conditions |
|
| 101 | + * @param array $relations |
|
| 102 | + * @param array $sortBy |
|
| 103 | + * @param array $desc |
|
| 104 | + * @param array $columns |
|
| 105 | + * @return collection |
|
| 106 | + */ |
|
| 107 | + public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Fetch the first record fro the storage based on the given |
|
| 111 | - * condition. |
|
| 112 | - * |
|
| 113 | - * @param array $conditions array of conditions |
|
| 114 | - * @param array $relations |
|
| 115 | - * @param array $columns |
|
| 116 | - * @return object |
|
| 117 | - */ |
|
| 118 | - public function first($conditions, $relations = [], $columns = array('*')); |
|
| 109 | + /** |
|
| 110 | + * Fetch the first record fro the storage based on the given |
|
| 111 | + * condition. |
|
| 112 | + * |
|
| 113 | + * @param array $conditions array of conditions |
|
| 114 | + * @param array $relations |
|
| 115 | + * @param array $columns |
|
| 116 | + * @return object |
|
| 117 | + */ |
|
| 118 | + public function first($conditions, $relations = [], $columns = array('*')); |
|
| 119 | 119 | } |
| 120 | 120 | \ No newline at end of file |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | $this->validationRules = property_exists($this, 'validationRules') ? $this->validationRules : false; |
| 35 | 35 | $this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : []; |
| 36 | 36 | $this->skipLoginCheck = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : []; |
| 37 | - $route = explode('@',\Route::currentRouteAction())[1]; |
|
| 37 | + $route = explode('@', \Route::currentRouteAction())[1]; |
|
| 38 | 38 | |
| 39 | - $this->middleware(function ($request, $next) { |
|
| 39 | + $this->middleware(function($request, $next) { |
|
| 40 | 40 | |
| 41 | 41 | $this->repo = call_user_func_array("\Core::{$this->model}", []); |
| 42 | 42 | return $next($request); |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->model))) |
| 230 | 230 | {} |
| 231 | - elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
| 231 | + elseif ( ! $isPasswordClient && $user->tokenCan($this->model.'-'.$permission)) |
|
| 232 | 232 | {} |
| 233 | 233 | else |
| 234 | 234 | { |
@@ -173,8 +173,7 @@ discard block |
||
| 173 | 173 | if ($request->has('id')) |
| 174 | 174 | { |
| 175 | 175 | $rule = str_replace('{id}', $request->get('id'), $rule); |
| 176 | - } |
|
| 177 | - else |
|
| 176 | + } else |
|
| 178 | 177 | { |
| 179 | 178 | $rule = str_replace(',{id}', '', $rule); |
| 180 | 179 | } |
@@ -252,10 +251,8 @@ discard block |
||
| 252 | 251 | } |
| 253 | 252 | |
| 254 | 253 | if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->model))) |
| 255 | - {} |
|
| 256 | - elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
| 257 | - {} |
|
| 258 | - else |
|
| 254 | + {} elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
| 255 | + {} else |
|
| 259 | 256 | { |
| 260 | 257 | |
| 261 | 258 | \ErrorHandler::noPermissions(); |
@@ -6,283 +6,283 @@ |
||
| 6 | 6 | |
| 7 | 7 | class BaseApiController extends Controller |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * The config implementation. |
|
| 11 | - * |
|
| 12 | - * @var array |
|
| 13 | - */ |
|
| 14 | - protected $config; |
|
| 9 | + /** |
|
| 10 | + * The config implementation. |
|
| 11 | + * |
|
| 12 | + * @var array |
|
| 13 | + */ |
|
| 14 | + protected $config; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * The relations implementation. |
|
| 18 | - * |
|
| 19 | - * @var array |
|
| 20 | - */ |
|
| 21 | - protected $relations; |
|
| 16 | + /** |
|
| 17 | + * The relations implementation. |
|
| 18 | + * |
|
| 19 | + * @var array |
|
| 20 | + */ |
|
| 21 | + protected $relations; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * The repo implementation. |
|
| 25 | - * |
|
| 26 | - * @var object |
|
| 27 | - */ |
|
| 28 | - protected $repo; |
|
| 23 | + /** |
|
| 24 | + * The repo implementation. |
|
| 25 | + * |
|
| 26 | + * @var object |
|
| 27 | + */ |
|
| 28 | + protected $repo; |
|
| 29 | 29 | |
| 30 | - public function __construct() |
|
| 31 | - { |
|
| 32 | - $this->config = \CoreConfig::getConfig(); |
|
| 33 | - $this->model = property_exists($this, 'model') ? $this->model : false; |
|
| 34 | - $this->validationRules = property_exists($this, 'validationRules') ? $this->validationRules : false; |
|
| 35 | - $this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : []; |
|
| 36 | - $this->skipLoginCheck = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : []; |
|
| 37 | - $route = explode('@',\Route::currentRouteAction())[1]; |
|
| 30 | + public function __construct() |
|
| 31 | + { |
|
| 32 | + $this->config = \CoreConfig::getConfig(); |
|
| 33 | + $this->model = property_exists($this, 'model') ? $this->model : false; |
|
| 34 | + $this->validationRules = property_exists($this, 'validationRules') ? $this->validationRules : false; |
|
| 35 | + $this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : []; |
|
| 36 | + $this->skipLoginCheck = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : []; |
|
| 37 | + $route = explode('@',\Route::currentRouteAction())[1]; |
|
| 38 | 38 | |
| 39 | - $this->middleware(function ($request, $next) { |
|
| 39 | + $this->middleware(function ($request, $next) { |
|
| 40 | 40 | |
| 41 | - $this->repo = call_user_func_array("\Core::{$this->model}", []); |
|
| 42 | - return $next($request); |
|
| 43 | - }); |
|
| 41 | + $this->repo = call_user_func_array("\Core::{$this->model}", []); |
|
| 42 | + return $next($request); |
|
| 43 | + }); |
|
| 44 | 44 | |
| 45 | - $this->checkPermission($route); |
|
| 46 | - $this->setRelations($route); |
|
| 47 | - $this->setSessions(); |
|
| 48 | - } |
|
| 45 | + $this->checkPermission($route); |
|
| 46 | + $this->setRelations($route); |
|
| 47 | + $this->setSessions(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Fetch all records with relations from storage. |
|
| 52 | - * |
|
| 53 | - * @param string $sortBy The name of the column to sort by. |
|
| 54 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 55 | - * @return \Illuminate\Http\Response |
|
| 56 | - */ |
|
| 57 | - public function index($sortBy = 'created_at', $desc = 1) |
|
| 58 | - { |
|
| 59 | - return \Response::json($this->repo->all($this->relations, $sortBy, $desc), 200); |
|
| 60 | - } |
|
| 50 | + /** |
|
| 51 | + * Fetch all records with relations from storage. |
|
| 52 | + * |
|
| 53 | + * @param string $sortBy The name of the column to sort by. |
|
| 54 | + * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 55 | + * @return \Illuminate\Http\Response |
|
| 56 | + */ |
|
| 57 | + public function index($sortBy = 'created_at', $desc = 1) |
|
| 58 | + { |
|
| 59 | + return \Response::json($this->repo->all($this->relations, $sortBy, $desc), 200); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Fetch the single object with relations from storage. |
|
| 64 | - * |
|
| 65 | - * @param integer $id Id of the requested model. |
|
| 66 | - * @return \Illuminate\Http\Response |
|
| 67 | - */ |
|
| 68 | - public function find($id) |
|
| 69 | - { |
|
| 70 | - return \Response::json($this->repo->find($id, $this->relations), 200); |
|
| 71 | - } |
|
| 62 | + /** |
|
| 63 | + * Fetch the single object with relations from storage. |
|
| 64 | + * |
|
| 65 | + * @param integer $id Id of the requested model. |
|
| 66 | + * @return \Illuminate\Http\Response |
|
| 67 | + */ |
|
| 68 | + public function find($id) |
|
| 69 | + { |
|
| 70 | + return \Response::json($this->repo->find($id, $this->relations), 200); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Paginate all records with relations from storage |
|
| 75 | - * that matche the given query. |
|
| 76 | - * |
|
| 77 | - * @param string $query The search text. |
|
| 78 | - * @param integer $perPage Number of rows per page default 15. |
|
| 79 | - * @param string $sortBy The name of the column to sort by. |
|
| 80 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 81 | - * @return \Illuminate\Http\Response |
|
| 82 | - */ |
|
| 83 | - public function search($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
| 84 | - { |
|
| 85 | - return \Response::json($this->repo->search($query, $perPage, $this->relations, $sortBy, $desc), 200); |
|
| 86 | - } |
|
| 73 | + /** |
|
| 74 | + * Paginate all records with relations from storage |
|
| 75 | + * that matche the given query. |
|
| 76 | + * |
|
| 77 | + * @param string $query The search text. |
|
| 78 | + * @param integer $perPage Number of rows per page default 15. |
|
| 79 | + * @param string $sortBy The name of the column to sort by. |
|
| 80 | + * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 81 | + * @return \Illuminate\Http\Response |
|
| 82 | + */ |
|
| 83 | + public function search($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
| 84 | + { |
|
| 85 | + return \Response::json($this->repo->search($query, $perPage, $this->relations, $sortBy, $desc), 200); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Fetch records from the storage based on the given |
|
| 90 | - * condition. |
|
| 91 | - * |
|
| 92 | - * @param \Illuminate\Http\Request $request |
|
| 93 | - * @param string $sortBy The name of the column to sort by. |
|
| 94 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 95 | - * @return \Illuminate\Http\Response |
|
| 96 | - */ |
|
| 97 | - public function findby(Request $request, $sortBy = 'created_at', $desc = 1) |
|
| 98 | - { |
|
| 99 | - return \Response::json($this->repo->findBy($request->all(), $this->relations, $sortBy, $desc), 200); |
|
| 100 | - } |
|
| 88 | + /** |
|
| 89 | + * Fetch records from the storage based on the given |
|
| 90 | + * condition. |
|
| 91 | + * |
|
| 92 | + * @param \Illuminate\Http\Request $request |
|
| 93 | + * @param string $sortBy The name of the column to sort by. |
|
| 94 | + * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 95 | + * @return \Illuminate\Http\Response |
|
| 96 | + */ |
|
| 97 | + public function findby(Request $request, $sortBy = 'created_at', $desc = 1) |
|
| 98 | + { |
|
| 99 | + return \Response::json($this->repo->findBy($request->all(), $this->relations, $sortBy, $desc), 200); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Fetch the first record from the storage based on the given |
|
| 104 | - * condition. |
|
| 105 | - * |
|
| 106 | - * @param \Illuminate\Http\Request $request |
|
| 107 | - * @return \Illuminate\Http\Response |
|
| 108 | - */ |
|
| 109 | - public function first(Request $request) |
|
| 110 | - { |
|
| 111 | - return \Response::json($this->repo->first($request->all(), $this->relations), 200); |
|
| 112 | - } |
|
| 102 | + /** |
|
| 103 | + * Fetch the first record from the storage based on the given |
|
| 104 | + * condition. |
|
| 105 | + * |
|
| 106 | + * @param \Illuminate\Http\Request $request |
|
| 107 | + * @return \Illuminate\Http\Response |
|
| 108 | + */ |
|
| 109 | + public function first(Request $request) |
|
| 110 | + { |
|
| 111 | + return \Response::json($this->repo->first($request->all(), $this->relations), 200); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Paginate all records with relations from storage. |
|
| 116 | - * |
|
| 117 | - * @param integer $perPage Number of rows per page default 15. |
|
| 118 | - * @param string $sortBy The name of the column to sort by. |
|
| 119 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 120 | - * @return \Illuminate\Http\Response |
|
| 121 | - */ |
|
| 122 | - public function paginate($perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
| 123 | - { |
|
| 124 | - return \Response::json($this->repo->paginate($perPage, $this->relations, $sortBy, $desc), 200); |
|
| 125 | - } |
|
| 114 | + /** |
|
| 115 | + * Paginate all records with relations from storage. |
|
| 116 | + * |
|
| 117 | + * @param integer $perPage Number of rows per page default 15. |
|
| 118 | + * @param string $sortBy The name of the column to sort by. |
|
| 119 | + * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 120 | + * @return \Illuminate\Http\Response |
|
| 121 | + */ |
|
| 122 | + public function paginate($perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
| 123 | + { |
|
| 124 | + return \Response::json($this->repo->paginate($perPage, $this->relations, $sortBy, $desc), 200); |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * Fetch all records with relations based on |
|
| 129 | - * the given condition from storage in pages. |
|
| 130 | - * |
|
| 131 | - * @param \Illuminate\Http\Request $request |
|
| 132 | - * @param integer $perPage Number of rows per page default 15. |
|
| 133 | - * @param string $sortBy The name of the column to sort by. |
|
| 134 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 135 | - * @return \Illuminate\Http\Response |
|
| 136 | - */ |
|
| 137 | - public function paginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
| 138 | - { |
|
| 139 | - return \Response::json($this->repo->paginateBy($request->all(), $perPage, $this->relations, $sortBy, $desc), 200); |
|
| 140 | - } |
|
| 127 | + /** |
|
| 128 | + * Fetch all records with relations based on |
|
| 129 | + * the given condition from storage in pages. |
|
| 130 | + * |
|
| 131 | + * @param \Illuminate\Http\Request $request |
|
| 132 | + * @param integer $perPage Number of rows per page default 15. |
|
| 133 | + * @param string $sortBy The name of the column to sort by. |
|
| 134 | + * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 135 | + * @return \Illuminate\Http\Response |
|
| 136 | + */ |
|
| 137 | + public function paginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
| 138 | + { |
|
| 139 | + return \Response::json($this->repo->paginateBy($request->all(), $perPage, $this->relations, $sortBy, $desc), 200); |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * Save the given model to storage. |
|
| 144 | - * |
|
| 145 | - * @param \Illuminate\Http\Request $request |
|
| 146 | - * @return \Illuminate\Http\Response |
|
| 147 | - */ |
|
| 148 | - public function save(Request $request) |
|
| 149 | - { |
|
| 150 | - foreach ($this->validationRules as &$rule) |
|
| 151 | - { |
|
| 152 | - if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) |
|
| 153 | - { |
|
| 154 | - $rule .= ',deleted_at,NULL'; |
|
| 155 | - } |
|
| 142 | + /** |
|
| 143 | + * Save the given model to storage. |
|
| 144 | + * |
|
| 145 | + * @param \Illuminate\Http\Request $request |
|
| 146 | + * @return \Illuminate\Http\Response |
|
| 147 | + */ |
|
| 148 | + public function save(Request $request) |
|
| 149 | + { |
|
| 150 | + foreach ($this->validationRules as &$rule) |
|
| 151 | + { |
|
| 152 | + if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) |
|
| 153 | + { |
|
| 154 | + $rule .= ',deleted_at,NULL'; |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - if ($request->has('id')) |
|
| 158 | - { |
|
| 159 | - $rule = str_replace('{id}', $request->get('id'), $rule); |
|
| 160 | - } |
|
| 161 | - else |
|
| 162 | - { |
|
| 163 | - $rule = str_replace(',{id}', '', $rule); |
|
| 164 | - } |
|
| 165 | - } |
|
| 157 | + if ($request->has('id')) |
|
| 158 | + { |
|
| 159 | + $rule = str_replace('{id}', $request->get('id'), $rule); |
|
| 160 | + } |
|
| 161 | + else |
|
| 162 | + { |
|
| 163 | + $rule = str_replace(',{id}', '', $rule); |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - $this->validate($request, $this->validationRules); |
|
| 167 | + $this->validate($request, $this->validationRules); |
|
| 168 | 168 | |
| 169 | - return \Response::json($this->repo->save($request->all()), 200); |
|
| 170 | - } |
|
| 169 | + return \Response::json($this->repo->save($request->all()), 200); |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - /** |
|
| 173 | - * Delete by the given id from storage. |
|
| 174 | - * |
|
| 175 | - * @param integer $id Id of the deleted model. |
|
| 176 | - * @return \Illuminate\Http\Response |
|
| 177 | - */ |
|
| 178 | - public function delete($id) |
|
| 179 | - { |
|
| 180 | - return \Response::json($this->repo->delete($id), 200); |
|
| 181 | - } |
|
| 172 | + /** |
|
| 173 | + * Delete by the given id from storage. |
|
| 174 | + * |
|
| 175 | + * @param integer $id Id of the deleted model. |
|
| 176 | + * @return \Illuminate\Http\Response |
|
| 177 | + */ |
|
| 178 | + public function delete($id) |
|
| 179 | + { |
|
| 180 | + return \Response::json($this->repo->delete($id), 200); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - /** |
|
| 184 | - * Return the deleted models in pages based on the given conditions. |
|
| 185 | - * |
|
| 186 | - * @param \Illuminate\Http\Request $request |
|
| 187 | - * @param integer $perPage Number of rows per page default 15. |
|
| 188 | - * @param string $sortBy The name of the column to sort by. |
|
| 189 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 190 | - * @return \Illuminate\Http\Response |
|
| 191 | - */ |
|
| 192 | - public function deleted(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
| 193 | - { |
|
| 194 | - return \Response::json($this->repo->deleted($request->all(), $perPage, $sortBy, $desc), 200); |
|
| 195 | - } |
|
| 183 | + /** |
|
| 184 | + * Return the deleted models in pages based on the given conditions. |
|
| 185 | + * |
|
| 186 | + * @param \Illuminate\Http\Request $request |
|
| 187 | + * @param integer $perPage Number of rows per page default 15. |
|
| 188 | + * @param string $sortBy The name of the column to sort by. |
|
| 189 | + * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 190 | + * @return \Illuminate\Http\Response |
|
| 191 | + */ |
|
| 192 | + public function deleted(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
| 193 | + { |
|
| 194 | + return \Response::json($this->repo->deleted($request->all(), $perPage, $sortBy, $desc), 200); |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - /** |
|
| 198 | - * Restore the deleted model. |
|
| 199 | - * |
|
| 200 | - * @param integer $id Id of the restored model. |
|
| 201 | - * @return \Illuminate\Http\Response |
|
| 202 | - */ |
|
| 203 | - public function restore($id) |
|
| 204 | - { |
|
| 205 | - return \Response::json($this->repo->restore($id), 200); |
|
| 206 | - } |
|
| 197 | + /** |
|
| 198 | + * Restore the deleted model. |
|
| 199 | + * |
|
| 200 | + * @param integer $id Id of the restored model. |
|
| 201 | + * @return \Illuminate\Http\Response |
|
| 202 | + */ |
|
| 203 | + public function restore($id) |
|
| 204 | + { |
|
| 205 | + return \Response::json($this->repo->restore($id), 200); |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - /** |
|
| 209 | - * Check if the logged in user can do the given permission. |
|
| 210 | - * |
|
| 211 | - * @param string $permission |
|
| 212 | - * @return void |
|
| 213 | - */ |
|
| 214 | - private function checkPermission($permission) |
|
| 215 | - { |
|
| 216 | - \Auth::shouldUse('api'); |
|
| 217 | - $this->middleware('auth:api', ['except' => $this->skipLoginCheck]); |
|
| 208 | + /** |
|
| 209 | + * Check if the logged in user can do the given permission. |
|
| 210 | + * |
|
| 211 | + * @param string $permission |
|
| 212 | + * @return void |
|
| 213 | + */ |
|
| 214 | + private function checkPermission($permission) |
|
| 215 | + { |
|
| 216 | + \Auth::shouldUse('api'); |
|
| 217 | + $this->middleware('auth:api', ['except' => $this->skipLoginCheck]); |
|
| 218 | 218 | |
| 219 | - if (\Auth::user() && ! in_array($permission, $this->skipLoginCheck)) |
|
| 220 | - { |
|
| 221 | - $user = \Auth::user(); |
|
| 222 | - $permission = $permission !== 'index' ? $permission : 'list'; |
|
| 223 | - $isPasswordClient = $user->token()->client->password_client; |
|
| 219 | + if (\Auth::user() && ! in_array($permission, $this->skipLoginCheck)) |
|
| 220 | + { |
|
| 221 | + $user = \Auth::user(); |
|
| 222 | + $permission = $permission !== 'index' ? $permission : 'list'; |
|
| 223 | + $isPasswordClient = $user->token()->client->password_client; |
|
| 224 | 224 | |
| 225 | - if ($user->blocked) |
|
| 226 | - { |
|
| 227 | - \ErrorHandler::userIsBlocked(); |
|
| 228 | - } |
|
| 225 | + if ($user->blocked) |
|
| 226 | + { |
|
| 227 | + \ErrorHandler::userIsBlocked(); |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->model))) |
|
| 231 | - {} |
|
| 232 | - elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
| 233 | - {} |
|
| 234 | - else |
|
| 235 | - { |
|
| 230 | + if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->model))) |
|
| 231 | + {} |
|
| 232 | + elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
| 233 | + {} |
|
| 234 | + else |
|
| 235 | + { |
|
| 236 | 236 | |
| 237 | - \ErrorHandler::noPermissions(); |
|
| 238 | - } |
|
| 239 | - } |
|
| 240 | - } |
|
| 237 | + \ErrorHandler::noPermissions(); |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | - /** |
|
| 243 | - * Set sessions based on the given headers in the request. |
|
| 244 | - * |
|
| 245 | - * @return void |
|
| 246 | - */ |
|
| 247 | - private function setSessions() |
|
| 248 | - { |
|
| 249 | - \Session::put('time-zone', \Request::header('time-zone') ?: 0); |
|
| 242 | + /** |
|
| 243 | + * Set sessions based on the given headers in the request. |
|
| 244 | + * |
|
| 245 | + * @return void |
|
| 246 | + */ |
|
| 247 | + private function setSessions() |
|
| 248 | + { |
|
| 249 | + \Session::put('time-zone', \Request::header('time-zone') ?: 0); |
|
| 250 | 250 | |
| 251 | - $locale = \Request::header('locale'); |
|
| 252 | - switch ($locale) |
|
| 253 | - { |
|
| 254 | - case 'en': |
|
| 255 | - \App::setLocale('en'); |
|
| 256 | - \Session::put('locale', 'en'); |
|
| 257 | - break; |
|
| 251 | + $locale = \Request::header('locale'); |
|
| 252 | + switch ($locale) |
|
| 253 | + { |
|
| 254 | + case 'en': |
|
| 255 | + \App::setLocale('en'); |
|
| 256 | + \Session::put('locale', 'en'); |
|
| 257 | + break; |
|
| 258 | 258 | |
| 259 | - case 'ar': |
|
| 260 | - \App::setLocale('ar'); |
|
| 261 | - \Session::put('locale', 'ar'); |
|
| 262 | - break; |
|
| 259 | + case 'ar': |
|
| 260 | + \App::setLocale('ar'); |
|
| 261 | + \Session::put('locale', 'ar'); |
|
| 262 | + break; |
|
| 263 | 263 | |
| 264 | - case 'all': |
|
| 265 | - \App::setLocale('en'); |
|
| 266 | - \Session::put('locale', 'all'); |
|
| 267 | - break; |
|
| 264 | + case 'all': |
|
| 265 | + \App::setLocale('en'); |
|
| 266 | + \Session::put('locale', 'all'); |
|
| 267 | + break; |
|
| 268 | 268 | |
| 269 | - default: |
|
| 270 | - \App::setLocale('en'); |
|
| 271 | - \Session::put('locale', 'en'); |
|
| 272 | - break; |
|
| 273 | - } |
|
| 274 | - } |
|
| 269 | + default: |
|
| 270 | + \App::setLocale('en'); |
|
| 271 | + \Session::put('locale', 'en'); |
|
| 272 | + break; |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - /** |
|
| 277 | - * Set relation based on the called api. |
|
| 278 | - * |
|
| 279 | - * @param string $route |
|
| 280 | - * @return void |
|
| 281 | - */ |
|
| 282 | - private function setRelations($route) |
|
| 283 | - { |
|
| 284 | - $route = $route !== 'index' ? $route : 'list'; |
|
| 285 | - $relations = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false; |
|
| 286 | - $this->relations = $relations && isset($relations[$route]) ? $relations[$route] : []; |
|
| 287 | - } |
|
| 276 | + /** |
|
| 277 | + * Set relation based on the called api. |
|
| 278 | + * |
|
| 279 | + * @param string $route |
|
| 280 | + * @return void |
|
| 281 | + */ |
|
| 282 | + private function setRelations($route) |
|
| 283 | + { |
|
| 284 | + $route = $route !== 'index' ? $route : 'list'; |
|
| 285 | + $relations = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false; |
|
| 286 | + $this->relations = $relations && isset($relations[$route]) ? $relations[$route] : []; |
|
| 287 | + } |
|
| 288 | 288 | } |
@@ -8,31 +8,31 @@ |
||
| 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 | - 'id' => 'required|exists:settings,id', |
|
| 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 | + 'id' => 'required|exists:settings,id', |
|
| 25 | + 'value' => 'required|string' |
|
| 26 | + ]; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Save list of settings. |
|
| 30 | - * |
|
| 31 | - * @param \Illuminate\Http\Request $request |
|
| 32 | - * @return \Illuminate\Http\Response |
|
| 33 | - */ |
|
| 34 | - public function saveMany(Request $request) |
|
| 35 | - { |
|
| 36 | - return \Response::json($this->repo->saveMany($request->all()), 200); |
|
| 37 | - } |
|
| 28 | + /** |
|
| 29 | + * Save list of settings. |
|
| 30 | + * |
|
| 31 | + * @param \Illuminate\Http\Request $request |
|
| 32 | + * @return \Illuminate\Http\Response |
|
| 33 | + */ |
|
| 34 | + public function saveMany(Request $request) |
|
| 35 | + { |
|
| 36 | + return \Response::json($this->repo->saveMany($request->all()), 200); |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -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 | 'id' => 'required|exists:settings,id', |
| 25 | 25 | 'value' => 'required|string' |
| 26 | 26 | ]; |
@@ -5,68 +5,68 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class SettingsObserver { |
| 7 | 7 | |
| 8 | - public function saving($model) |
|
| 9 | - { |
|
| 10 | - // |
|
| 11 | - } |
|
| 8 | + public function saving($model) |
|
| 9 | + { |
|
| 10 | + // |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public function saved($model) |
|
| 14 | - { |
|
| 15 | - // |
|
| 16 | - } |
|
| 13 | + public function saved($model) |
|
| 14 | + { |
|
| 15 | + // |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Prevent the creating of the settings. |
|
| 20 | - * |
|
| 21 | - * @param object $model the model beign created. |
|
| 22 | - * @return void |
|
| 23 | - */ |
|
| 24 | - public function creating($model) |
|
| 25 | - { |
|
| 26 | - \ErrorHandler::cannotCreateSetting(); |
|
| 27 | - } |
|
| 18 | + /** |
|
| 19 | + * Prevent the creating of the settings. |
|
| 20 | + * |
|
| 21 | + * @param object $model the model beign created. |
|
| 22 | + * @return void |
|
| 23 | + */ |
|
| 24 | + public function creating($model) |
|
| 25 | + { |
|
| 26 | + \ErrorHandler::cannotCreateSetting(); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public function created($model) |
|
| 30 | - { |
|
| 31 | - // |
|
| 32 | - } |
|
| 29 | + public function created($model) |
|
| 30 | + { |
|
| 31 | + // |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Prevent updating of the setting key. |
|
| 36 | - * |
|
| 37 | - * @param object $model the model beign updated. |
|
| 38 | - * @return void |
|
| 39 | - */ |
|
| 40 | - public function updating($model) |
|
| 41 | - { |
|
| 42 | - if ($model->getOriginal('key') !== $model->key) |
|
| 43 | - { |
|
| 44 | - \ErrorHandler::cannotUpdateSettingKey(); |
|
| 45 | - } |
|
| 46 | - } |
|
| 34 | + /** |
|
| 35 | + * Prevent updating of the setting key. |
|
| 36 | + * |
|
| 37 | + * @param object $model the model beign updated. |
|
| 38 | + * @return void |
|
| 39 | + */ |
|
| 40 | + public function updating($model) |
|
| 41 | + { |
|
| 42 | + if ($model->getOriginal('key') !== $model->key) |
|
| 43 | + { |
|
| 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 | } |
| 73 | 73 | \ No newline at end of file |
@@ -14,19 +14,19 @@ |
||
| 14 | 14 | return 'App\Modules\Core\Settings'; |
| 15 | 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 $key => $value) |
|
| 27 | - { |
|
| 28 | - $this->save($value); |
|
| 29 | - } |
|
| 30 | - }); |
|
| 31 | - } |
|
| 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 $key => $value) |
|
| 27 | + { |
|
| 28 | + $this->save($value); |
|
| 29 | + } |
|
| 30 | + }); |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | public function saveMany(array $data) |
| 24 | 24 | { |
| 25 | - \DB::transaction(function () use ($data) { |
|
| 25 | + \DB::transaction(function() use ($data) { |
|
| 26 | 26 | foreach ($data as $key => $value) |
| 27 | 27 | { |
| 28 | 28 | $this->save($value); |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /* |
|
| 5 | + /* |
|
| 6 | 6 | |-------------------------------------------------------------------------- |
| 7 | 7 | | Validation Language Lines |
| 8 | 8 | |-------------------------------------------------------------------------- |
@@ -13,74 +13,74 @@ discard block |
||
| 13 | 13 | | |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | - 'accepted' => 'The :attribute must be accepted.', |
|
| 17 | - 'active_url' => 'The :attribute is not a valid URL.', |
|
| 18 | - 'after' => 'The :attribute must be a date after :date.', |
|
| 19 | - 'alpha' => 'The :attribute may only contain letters.', |
|
| 20 | - 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', |
|
| 21 | - 'alpha_num' => 'The :attribute may only contain letters and numbers.', |
|
| 22 | - 'array' => 'The :attribute must be an array.', |
|
| 23 | - 'before' => 'The :attribute must be a date before :date.', |
|
| 24 | - 'between' => [ |
|
| 25 | - 'numeric' => 'The :attribute must be between :min and :max.', |
|
| 26 | - 'file' => 'The :attribute must be between :min and :max kilobytes.', |
|
| 27 | - 'string' => 'The :attribute must be between :min and :max characters.', |
|
| 28 | - 'array' => 'The :attribute must have between :min and :max items.', |
|
| 29 | - ], |
|
| 30 | - 'boolean' => 'The :attribute field must be true or false.', |
|
| 31 | - 'confirmed' => 'The :attribute confirmation does not match.', |
|
| 32 | - 'date' => 'The :attribute is not a valid date.', |
|
| 33 | - 'date_format' => 'The :attribute does not match the format :format.', |
|
| 34 | - 'different' => 'The :attribute and :other must be different.', |
|
| 35 | - 'digits' => 'The :attribute must be :digits digits.', |
|
| 36 | - 'digits_between' => 'The :attribute must be between :min and :max digits.', |
|
| 37 | - 'distinct' => 'The :attribute field has a duplicate value.', |
|
| 38 | - 'email' => 'The :attribute must be a valid email address.', |
|
| 39 | - 'exists' => 'The selected :attribute is invalid.', |
|
| 40 | - 'filled' => 'The :attribute field is required.', |
|
| 41 | - 'image' => 'The :attribute must be an image.', |
|
| 42 | - 'in' => 'The selected :attribute is invalid.', |
|
| 43 | - 'in_array' => 'The :attribute field does not exist in :other.', |
|
| 44 | - 'integer' => 'The :attribute must be an integer.', |
|
| 45 | - 'ip' => 'The :attribute must be a valid IP address.', |
|
| 46 | - 'json' => 'The :attribute must be a valid JSON string.', |
|
| 47 | - 'max' => [ |
|
| 48 | - 'numeric' => 'The :attribute may not be greater than :max.', |
|
| 49 | - 'file' => 'The :attribute may not be greater than :max kilobytes.', |
|
| 50 | - 'string' => 'The :attribute may not be greater than :max characters.', |
|
| 51 | - 'array' => 'The :attribute may not have more than :max items.', |
|
| 52 | - ], |
|
| 53 | - 'mimes' => 'The :attribute must be a file of type: :values.', |
|
| 54 | - 'min' => [ |
|
| 55 | - 'numeric' => 'The :attribute must be at least :min.', |
|
| 56 | - 'file' => 'The :attribute must be at least :min kilobytes.', |
|
| 57 | - 'string' => 'The :attribute must be at least :min characters.', |
|
| 58 | - 'array' => 'The :attribute must have at least :min items.', |
|
| 59 | - ], |
|
| 60 | - 'not_in' => 'The selected :attribute is invalid.', |
|
| 61 | - 'numeric' => 'The :attribute must be a number.', |
|
| 62 | - 'present' => 'The :attribute field must be present.', |
|
| 63 | - 'regex' => 'The :attribute format is invalid.', |
|
| 64 | - 'required' => 'The :attribute field is required.', |
|
| 65 | - 'required_if' => 'The :attribute field is required when :other is :value.', |
|
| 66 | - 'required_unless' => 'The :attribute field is required unless :other is in :values.', |
|
| 67 | - 'required_with' => 'The :attribute field is required when :values is present.', |
|
| 68 | - 'required_with_all' => 'The :attribute field is required when :values is present.', |
|
| 69 | - 'required_without' => 'The :attribute field is required when :values is not present.', |
|
| 70 | - 'required_without_all' => 'The :attribute field is required when none of :values are present.', |
|
| 71 | - 'same' => 'The :attribute and :other must match.', |
|
| 72 | - 'size' => [ |
|
| 73 | - 'numeric' => 'The :attribute must be :size.', |
|
| 74 | - 'file' => 'The :attribute must be :size kilobytes.', |
|
| 75 | - 'string' => 'The :attribute must be :size characters.', |
|
| 76 | - 'array' => 'The :attribute must contain :size items.', |
|
| 77 | - ], |
|
| 78 | - 'string' => 'The :attribute must be a string.', |
|
| 79 | - 'timezone' => 'The :attribute must be a valid zone.', |
|
| 80 | - 'unique' => 'The :attribute has already been taken.', |
|
| 81 | - 'url' => 'The :attribute format is invalid.', |
|
| 16 | + 'accepted' => 'The :attribute must be accepted.', |
|
| 17 | + 'active_url' => 'The :attribute is not a valid URL.', |
|
| 18 | + 'after' => 'The :attribute must be a date after :date.', |
|
| 19 | + 'alpha' => 'The :attribute may only contain letters.', |
|
| 20 | + 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', |
|
| 21 | + 'alpha_num' => 'The :attribute may only contain letters and numbers.', |
|
| 22 | + 'array' => 'The :attribute must be an array.', |
|
| 23 | + 'before' => 'The :attribute must be a date before :date.', |
|
| 24 | + 'between' => [ |
|
| 25 | + 'numeric' => 'The :attribute must be between :min and :max.', |
|
| 26 | + 'file' => 'The :attribute must be between :min and :max kilobytes.', |
|
| 27 | + 'string' => 'The :attribute must be between :min and :max characters.', |
|
| 28 | + 'array' => 'The :attribute must have between :min and :max items.', |
|
| 29 | + ], |
|
| 30 | + 'boolean' => 'The :attribute field must be true or false.', |
|
| 31 | + 'confirmed' => 'The :attribute confirmation does not match.', |
|
| 32 | + 'date' => 'The :attribute is not a valid date.', |
|
| 33 | + 'date_format' => 'The :attribute does not match the format :format.', |
|
| 34 | + 'different' => 'The :attribute and :other must be different.', |
|
| 35 | + 'digits' => 'The :attribute must be :digits digits.', |
|
| 36 | + 'digits_between' => 'The :attribute must be between :min and :max digits.', |
|
| 37 | + 'distinct' => 'The :attribute field has a duplicate value.', |
|
| 38 | + 'email' => 'The :attribute must be a valid email address.', |
|
| 39 | + 'exists' => 'The selected :attribute is invalid.', |
|
| 40 | + 'filled' => 'The :attribute field is required.', |
|
| 41 | + 'image' => 'The :attribute must be an image.', |
|
| 42 | + 'in' => 'The selected :attribute is invalid.', |
|
| 43 | + 'in_array' => 'The :attribute field does not exist in :other.', |
|
| 44 | + 'integer' => 'The :attribute must be an integer.', |
|
| 45 | + 'ip' => 'The :attribute must be a valid IP address.', |
|
| 46 | + 'json' => 'The :attribute must be a valid JSON string.', |
|
| 47 | + 'max' => [ |
|
| 48 | + 'numeric' => 'The :attribute may not be greater than :max.', |
|
| 49 | + 'file' => 'The :attribute may not be greater than :max kilobytes.', |
|
| 50 | + 'string' => 'The :attribute may not be greater than :max characters.', |
|
| 51 | + 'array' => 'The :attribute may not have more than :max items.', |
|
| 52 | + ], |
|
| 53 | + 'mimes' => 'The :attribute must be a file of type: :values.', |
|
| 54 | + 'min' => [ |
|
| 55 | + 'numeric' => 'The :attribute must be at least :min.', |
|
| 56 | + 'file' => 'The :attribute must be at least :min kilobytes.', |
|
| 57 | + 'string' => 'The :attribute must be at least :min characters.', |
|
| 58 | + 'array' => 'The :attribute must have at least :min items.', |
|
| 59 | + ], |
|
| 60 | + 'not_in' => 'The selected :attribute is invalid.', |
|
| 61 | + 'numeric' => 'The :attribute must be a number.', |
|
| 62 | + 'present' => 'The :attribute field must be present.', |
|
| 63 | + 'regex' => 'The :attribute format is invalid.', |
|
| 64 | + 'required' => 'The :attribute field is required.', |
|
| 65 | + 'required_if' => 'The :attribute field is required when :other is :value.', |
|
| 66 | + 'required_unless' => 'The :attribute field is required unless :other is in :values.', |
|
| 67 | + 'required_with' => 'The :attribute field is required when :values is present.', |
|
| 68 | + 'required_with_all' => 'The :attribute field is required when :values is present.', |
|
| 69 | + 'required_without' => 'The :attribute field is required when :values is not present.', |
|
| 70 | + 'required_without_all' => 'The :attribute field is required when none of :values are present.', |
|
| 71 | + 'same' => 'The :attribute and :other must match.', |
|
| 72 | + 'size' => [ |
|
| 73 | + 'numeric' => 'The :attribute must be :size.', |
|
| 74 | + 'file' => 'The :attribute must be :size kilobytes.', |
|
| 75 | + 'string' => 'The :attribute must be :size characters.', |
|
| 76 | + 'array' => 'The :attribute must contain :size items.', |
|
| 77 | + ], |
|
| 78 | + 'string' => 'The :attribute must be a string.', |
|
| 79 | + 'timezone' => 'The :attribute must be a valid zone.', |
|
| 80 | + 'unique' => 'The :attribute has already been taken.', |
|
| 81 | + 'url' => 'The :attribute format is invalid.', |
|
| 82 | 82 | |
| 83 | - /* |
|
| 83 | + /* |
|
| 84 | 84 | |-------------------------------------------------------------------------- |
| 85 | 85 | | Custom Validation Language Lines |
| 86 | 86 | |-------------------------------------------------------------------------- |
@@ -91,13 +91,13 @@ discard block |
||
| 91 | 91 | | |
| 92 | 92 | */ |
| 93 | 93 | |
| 94 | - 'custom' => [ |
|
| 95 | - 'attribute-name' => [ |
|
| 96 | - 'rule-name' => 'custom-message', |
|
| 97 | - ], |
|
| 98 | - ], |
|
| 94 | + 'custom' => [ |
|
| 95 | + 'attribute-name' => [ |
|
| 96 | + 'rule-name' => 'custom-message', |
|
| 97 | + ], |
|
| 98 | + ], |
|
| 99 | 99 | |
| 100 | - /* |
|
| 100 | + /* |
|
| 101 | 101 | |-------------------------------------------------------------------------- |
| 102 | 102 | | Custom Validation Attributes |
| 103 | 103 | |-------------------------------------------------------------------------- |
@@ -108,6 +108,6 @@ discard block |
||
| 108 | 108 | | |
| 109 | 109 | */ |
| 110 | 110 | |
| 111 | - 'attributes' => [], |
|
| 111 | + 'attributes' => [], |
|
| 112 | 112 | |
| 113 | 113 | ]; |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /* |
|
| 5 | + /* |
|
| 6 | 6 | |-------------------------------------------------------------------------- |
| 7 | 7 | | Pagination Language Lines |
| 8 | 8 | |-------------------------------------------------------------------------- |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | | |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | - 'previous' => '« Previous', |
|
| 17 | - 'next' => 'Next »', |
|
| 16 | + 'previous' => '« Previous', |
|
| 17 | + 'next' => 'Next »', |
|
| 18 | 18 | |
| 19 | 19 | ]; |