[英]how to handle foreign key with morph one to many files
我有這些表:
file:
id - path - meme_type
fileable:
id - file_id - fileable_id - fileable_type
ticket_bodies:
id - title
TickeBody
的每一行都有多個文件。 現在如何實現變形功能? (我不想將file
表與可歸檔表結合起來)
像這樣的東西?
App\Models\File
:
public function fileable(){
return $this->morphTo();
}
App\Models\TicketBody
:
public function files(){
return $this->morphMany(App\Models\File::class, 'fileable');
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.