%PDF- %PDF-
Direktori : /var/www/html/sljcon/app/Providers/ |
Current File : /var/www/html/sljcon/app/Providers/MorphableName.php |
<?php namespace App\Providers; use App\Models\Project; use App\Models\Section; use App\Models\Testimonial; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Support\ServiceProvider; class MorphableName extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { Relation::morphMap([ 'Project' => Project::class, 'Section' => Section::class, 'Testimonial' => Testimonial::class ]); } /** * Register any application services. * * @return void */ public function register() { // } public static function forClass($model) { $result = array_search($model, Relation::morphMap()); if (!$result) { throw new \Exception("Model '$model' is not mapped in Relation::morphMap()"); } return $result; } }