I have Category - Course pivot table. it's called Directions:
public $table = 'directions';
protected $fillable = [
'course_category_id','course_id'
];
category:
public function manyCourses()
{
return $this->belongsToMany(Direction::class, 'directions', 'course_category_id', 'course_id');
}
course:
public function manyCategories()
{
return $this->belongsToMany(Direction::class, 'directions', 'course_id', 'course_category_id');
}
and in blade i'm trying to get data from directions table but i'm getting error Syntax error or access violation: 1066 Not unique table/alias I searched error and it's telling that i have relationships problem... but i think i'm doing something wrong in blade...
<select class="many-course-category" name="categoryId" multiple="multiple">
@foreach ($c->manyCategories as $category)
<option value="{{ $category->pivot->course_category_id }}">
{{ $category->pivot->course_category_id->name }}
</option>
@endforeach
</select>
$c is my current course / course edit...
so whats i'm doing wrong ?