I'm trying to create a simple relationship between tables :
- attribute_type -
id
name
- category -
id
name
description
So I created a pivot table to link them :
- attribute_type_category -
attribute_type_id
category_id
There is the model relationships :
On AttributeType.php
public function category() {
return $this->belongsToMany('App\AttributeTypeCategory', 'attribute_type_category', 'attribute_type_id', 'category_id');
}
On AttributeTypeCategory.php
public function category() {
return $this->belongsToMany('App\Category');
}
All seems to be fine, but I get the following error :
SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'attribute_type_category' (SQL: select
attribute_type_category.*,attribute_type_category.attribute_type_idaspivot_attribute_type_id,attribute_type_category.category_idaspivot_category_idfromattribute_type_categoryinner joinattribute_type_categoryonattribute_type_category.id=attribute_type_category.category_idwhereattribute_type_category.attribute_type_id= 1)
Do you have any idea ? Thank you !