dillingham / morphable
morphable functionality
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/dillingham/morphable
Requires (Dev)
- orchestra/testbench: ^3.8
 - phpunit/phpunit: ^8.3
 
This package is auto-updated.
Last update: 2025-10-29 03:03:09 UTC
README
composer require dillingham/morphable
- Add 
Morphableto a model - Add 
ResolveMorphsto your base controller - Fill 
$morphableon a controller with model classes - Submit 
typeandidto a controller - adds 
->forMorph($model)to fill object_type, object_id 
<?php class CommentController extends Controller { use ResolveMorphs; public $morphable = [ \App\Post::class ]; public function store() { $model = $this->resolveMorph(); $comment = new Comment; $comment->forMorph($model); $comment->save(); } }