1
가 나는 동안이 같은 열망로드 갤러리이점점 오류 열망로드
$user = User::where('username', $username)->first();
$favorites = Favorite::with('gallery')->where('user_id', $user->id)->get();
dd($favorites->gallery);
이 오류 메시지가 점점 :
이Undefined property: Illuminate\Database\Eloquent\Collection::$gallery
즐겨 찾기 클래스는 다음과 같습니다
class Favorite extends Model
{
protected $table = 'favorites';
public function user(){
return $this->belongsTo(User::class, 'user_id');
}
public function gallery(){
return $this->belongsTo(Gallery::class, 'gallery_id');
}
}
을 그러나 내가 이것을하면
$user = User::where('username', $username)->first();
$favorites = Favorite::with('gallery')->where('user_id', $user->id)->get();
dd($favorites);