Benim Program ve Tag modelim var bunlar n-n ilişkiye sahip ve ara tablo program_tags
Ben id si [1,2,3] tag id numarasına sahip programları çekmek isityorum.
Program::whereHas('tags',function ($q) use ($userTags){
$q->whereIn('id',$userTags);
})->get(['id','title','description','minute','image_url','thumbnail']);
Program da tags
public function tags(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(Tag::class,'program_tags','tag_id');
}
Tag da programs
public function programs(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(Program::class,'program_tags','program_id');
}
şeklinde ama
Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous (SQL: select id
, title
, description
, minute
, image_url
, thumbnail
from programs
where exists (select * from tags
inner join program_tags
on tags
.id
= program_tags
.tag_id
where programs
.id
= program_tags
.tag_id
and id
= 1)) in file E:\laragon\www\faceyo\vendor\laravel\framework\src\Illuminate\Database\Connection.php on line 692
bu hatayı alıyorum