blog icon indicating copy to clipboard operation
blog copied to clipboard

一种 Laravel 中简单设置多态关系模型别名(Polymorphic Types)的方式 - overtrue

Open overtrue opened this issue 6 years ago • 0 comments

https://overtrue.me/articles/2019/10/a-easy-way-to-set-laravel-morph-map.html

作为 Laravel 的重度使用者肯定都对多态关系不默生,以官方文档为例,文章有标签,视频有标签,那么文章和视频这些模型与标签模型的关系就是多态多对多(Many To Many (Polymorphic)) 如果我们给 ID 为 1 的文章打上两个标签,数据库标签关系表的的存储结果就是这样子: > select * from taggables; +--------+-------------+---------------+ | tag_id | taggable_id | taggable_type | +--------+-------------+---------...

overtrue avatar Oct 10 '19 10:10 overtrue