[英]Call two relational tables in a singe id in Laravel. (check photos)
嘿,最好使用 Eloquent 關系,就像如果你有Author
Model 和AuthorProfile
Model 所以你把下面的方法放在 Author Model
public function Authorprofile(){
return $this->belongsTo(AuthorProfile::class, 'authorprofile_id');
}
然后在 Controller 中使用。
public function show($id){
$author = Author::with('Authorprofile')->find($id)
}
希望它可能會有所幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.