Код: Выделить всё
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