-
composer.json
Open in GitHub{ // "require": { "php": "^7.3|^8.0", // "spatie/laravel-permission": "^3.17" }, // }
-
app/Models/User.php
Open in GitHubuse Spatie\Permission\Traits\HasRoles; class User extends Authenticatable { use HasRoles; // }
-
app/Models/Setting.php
Open in GitHubclass Setting extends BaseModel { // public static function getValidationRules() { return self::getDefinedSettingFields()->pluck('rules', 'name') ->reject(function ($val) { return is_null($val); })->toArray(); } // }
-
app/Http/Controllers/Backend/SettingController.php
Open in GitHubuse App\Models\Setting; class SettingController extends Controller { // public function store(Request $request) { $rules = Setting::getValidationRules(); $data = $this->validate($request, $rules); $validSettings = array_keys($rules); foreach ($data as $key => $val) { if (in_array($key, $validSettings)) { Setting::add($key, $val, Setting::getDataType($key)); } } return redirect()->back()->with('status', 'Settings has been saved.'); } }