user()->can('create', User::class); } public function rules() { $this->sanitize(); return [ 'first_name' => 'required|string|max:100', 'last_name' => 'required|string:max:100', 'email' => new NewUniqueUserRule(), 'is_admin' => 'required', ]; } public function sanitize() { $input = $this->all(); if(!isset($input['is_admin'])) $input['is_admin'] = null; if(!isset($input['permissions'])) $input['permissions'] = json_encode([]); if(!isset($input['settings'])) $input['settings'] = json_encode(DefaultSettings::userSettings()); $this->replace($input); } }