generated from liutk/owl-admin-base
38 lines
810 B
PHP
38 lines
810 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\Relation;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
$this->app->singleton('admin.menu', \App\Admin\Menu::class);
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot()
|
|
{
|
|
$this->definePolymorphicTypes();
|
|
}
|
|
|
|
/**
|
|
* 自定义多态类型
|
|
*/
|
|
protected function definePolymorphicTypes(): void
|
|
{
|
|
Relation::enforceMorphMap(
|
|
collect([
|
|
\App\Models\AdminUser::class,
|
|
])->mapWithKeys(fn ($model) => [(new $model)->getTable() => $model])->all()
|
|
);
|
|
}
|
|
}
|