I want to write a query using the Laravel Eloquent structure. I want to query these values after entering the min and max values. I have a product table. Column product table with discount (%) and price. I want to get min and max value according to the discounted value of the product.
I want this to be based on the query including the discount.
$products->where('price', '<=', $max)
->where('price', '>=', $min)
->orderByDesc('id')
->paginate(9);
Product migration:
Schema::create('products', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('upper_category_id')->index();
$table->unsignedBigInteger('category_id')->index();
$table->unsignedBigInteger('user_id')->index();
$table->string('name');
$table->longText('text');
$table->float('price')->index();
$table->integer('stock');
$table->float('discount');
$table->timestamps();
});
Thank you very much in advance.