app->singleton('admin.menu', \App\Admin\Menu::class); } /** * Bootstrap any application services. */ public function boot() { JsonResource::withoutWrapping(); $this->definePolymorphicTypes(); Validator::extend('phone', function ($attribute, $value, $parameters, $validator) { return preg_match('/^1[\d]{10}$/', $value); }); } /** * 自定义多态类型 */ protected function definePolymorphicTypes(): void { Relation::enforceMorphMap( collect([ \App\Models\AdminUser::class, ])->mapWithKeys(fn ($model) => [(new $model)->getTable() => $model])->all() ); } }