generated from liutk/owl-admin-base
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
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,
|
|
\App\Models\Employee::class,
|
|
\App\Models\EmployeeSignRepair::class,
|
|
\App\Models\HolidayApply::class,
|
|
\App\Models\OvertimeApply::class,
|
|
\App\Models\OfficalBusiness::class,
|
|
\App\Models\Ledger::class,
|
|
\App\Models\Reimbursement::class,
|
|
\App\Models\StoreMasterCommission::class,
|
|
\App\Models\EmployeePromotion::class,
|
|
])->mapWithKeys(fn ($model) => [(new $model)->getTable() => $model])->all()
|
|
);
|
|
}
|
|
}
|