Anonymous
Ссылки не существуют в построителе запросов
Сообщение
Anonymous » 01 авг 2024, 02:28
Я получаю эту ошибку
Код: Выделить всё
Method Illuminate\Database\Eloquent\Collection::links does not exist.
когда я добавляю этот код
Код: Выделить всё
if ($request->has('colors')){
$colorproduct = ColorProduct::with("product")
->WhereIn('color_id',explode(',', request()->input('colors')))->get();
$colorproduct = array_unique($colorproduct->pluck("product_id")->toArray());
$products = $products
->whereIn('id',$colorproduct);
}
код для этого построителя запросов
Код: Выделить всё
$products = QueryBuilder::for(Product::class)
->allowedFilters([
AllowedFilter::exact('brand', 'brand_id'),
AllowedFilter::exact('wristlet', 'wristlet_id'),
AllowedFilter::exact('plate', 'plate_id'),
AllowedFilter::exact('accuracy', 'accuracy_id'),
AllowedFilter::exact('width', 'width_id'),
AllowedFilter::exact('frame', 'fram_id'),
AllowedFilter::exact('material', 'material_id'),
AllowedFilter::exact('framwidth', 'framwidth_id'),
AllowedFilter::exact('framweight', 'framweight_id'),
AllowedFilter::exact('lensheight', 'lensheight_id'),
AllowedFilter::exact('lenswidth', 'lenswidth_id'),
AllowedFilter::exact('lengthface', 'lengthface_id'),
AllowedFilter::exact('handlehinge', 'handlehinge_id'),
AllowedFilter::exact('faceform', 'faceform_id'),
AllowedFilter::exact('nasalwidth', 'nasalwidth_id'),
AllowedFilter::exact('original', 'original_id'),
AllowedFilter::exact('PD_range' ,'PD_range'),
AllowedFilter::scope('min_price' ),
AllowedFilter::scope('max_price' ),
AllowedFilter::scope('min_pd' ),
AllowedFilter::scope('max_pd' ),
AllowedFilter::scope('min_lens' ),
AllowedFilter::scope('max_lens' ),
])
->allowedSorts('price','created_at','available_id')
->defaultSort('price')
->with('category')->paginate('15')
->appends(request()->query());
if ($request->has('colors')){
$colorproduct = ColorProduct::with("product")
->WhereIn('color_id',explode(',', request()->input('colors')))->get();
$colorproduct = array_unique($colorproduct->pluck("product_id")->toArray());
$products = $products
->whereIn('id',$colorproduct);
}
цветной продукт представляет собой интерфейс таблицы, и при фильтровании продукта по идентификатору цвета возникает эта ошибка
Подробнее здесь:
https://stackoverflow.com/questions/707 ... ry-builder
1722468489
Anonymous
Я получаю эту ошибку [code]Method Illuminate\Database\Eloquent\Collection::links does not exist. [/code] когда я добавляю этот код [code]if ($request->has('colors')){ $colorproduct = ColorProduct::with("product") ->WhereIn('color_id',explode(',', request()->input('colors')))->get(); $colorproduct = array_unique($colorproduct->pluck("product_id")->toArray()); $products = $products ->whereIn('id',$colorproduct); } [/code] код для этого построителя запросов [code] $products = QueryBuilder::for(Product::class) ->allowedFilters([ AllowedFilter::exact('brand', 'brand_id'), AllowedFilter::exact('wristlet', 'wristlet_id'), AllowedFilter::exact('plate', 'plate_id'), AllowedFilter::exact('accuracy', 'accuracy_id'), AllowedFilter::exact('width', 'width_id'), AllowedFilter::exact('frame', 'fram_id'), AllowedFilter::exact('material', 'material_id'), AllowedFilter::exact('framwidth', 'framwidth_id'), AllowedFilter::exact('framweight', 'framweight_id'), AllowedFilter::exact('lensheight', 'lensheight_id'), AllowedFilter::exact('lenswidth', 'lenswidth_id'), AllowedFilter::exact('lengthface', 'lengthface_id'), AllowedFilter::exact('handlehinge', 'handlehinge_id'), AllowedFilter::exact('faceform', 'faceform_id'), AllowedFilter::exact('nasalwidth', 'nasalwidth_id'), AllowedFilter::exact('original', 'original_id'), AllowedFilter::exact('PD_range' ,'PD_range'), AllowedFilter::scope('min_price' ), AllowedFilter::scope('max_price' ), AllowedFilter::scope('min_pd' ), AllowedFilter::scope('max_pd' ), AllowedFilter::scope('min_lens' ), AllowedFilter::scope('max_lens' ), ]) ->allowedSorts('price','created_at','available_id') ->defaultSort('price') ->with('category')->paginate('15') ->appends(request()->query()); if ($request->has('colors')){ $colorproduct = ColorProduct::with("product") ->WhereIn('color_id',explode(',', request()->input('colors')))->get(); $colorproduct = array_unique($colorproduct->pluck("product_id")->toArray()); $products = $products ->whereIn('id',$colorproduct); } [/code] цветной продукт представляет собой интерфейс таблицы, и при фильтровании продукта по идентификатору цвета возникает эта ошибка Подробнее здесь: [url]https://stackoverflow.com/questions/70756007/links-does-not-exist-in-query-builder[/url]