dillingham / morphable
morphable functionality
1.0.1
2019-08-23 17:09 UTC
Requires (Dev)
- orchestra/testbench: ^3.8
- phpunit/phpunit: ^8.3
This package is auto-updated.
Last update: 2024-11-29 05:57:11 UTC
README
composer require dillingham/morphable
- Add
Morphable
to a model - Add
ResolveMorphs
to your base controller - Fill
$morphable
on a controller with model classes - Submit
type
andid
to 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(); } }