dillingham / morphable
morphable功能
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-08-29 05:07:08 UTC
README
composer require dillingham/morphable
- 将
Morphable
添加到模型中 - 将
ResolveMorphs
添加到您的基控制器中 - 在控制器中填充
$morphable
与模型类 - 向控制器提交
type
和id
- 添加
->forMorph($model)
以填充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(); } }