Я работаю над сводной таблицей с laravel отношением "многие ко многим"
public function filterByProducts()
{
return $this->belongsToMany(
CartRuleConditionProduct::class, 'cart_rule_condition_products',
'product_id', 'condition_id'
);
}
Я могу использовать attach, detach и syn c, как обычно
$cartRuleCondition->filterByProduct()->sync(Product::find($request->get('product_filtered')))
Вот мой код для вызова отношений
<select multiple class="form-control rounded-0" name="product_filtered[]" size="10">
@foreach($condition->filterByProducts as $filteredProduct)
<option value="{{ $filteredProduct }}">{{ $filteredProduct }}</option>
@endforeach
</select>
Вот ошибка
SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'cart_rule_condition_products' (SQL: select `cart_rule_condition_products`.*, `cart_rule_condition_products`.`condition_id` as `pivot_condition_id`, `cart_rule_condition_products`.`product_id` as `pivot_product_id` from `cart_rule_condition_products` inner join `cart_rule_condition_products` on `cart_rule_condition_products`.`id` = `cart_rule_condition_products`.`product_id` where `cart_rule_condition_products`.`condition_id` = 1)
Пожалуйста, помогите ~.
Спасибо.