Add lowest price first draft.
This commit is contained in:
@@ -11,10 +11,10 @@ final class IndexController extends BaseController
|
||||
#[Route('/', name: 'app_home')]
|
||||
public function __invoke(): Response
|
||||
{
|
||||
if($this->cache->getItem('list_all')->isHit()) {
|
||||
return $this->render('productList.html.twig', ['listType' => 'all']);
|
||||
}
|
||||
$products = Product::with(['currentStock', 'price'])
|
||||
// if($this->cache->getItem('list_all')->isHit()) {
|
||||
// return $this->render('productList.html.twig', ['listType' => 'all']);
|
||||
// }
|
||||
$products = Product::with(['currentStock', 'price', 'lowestPrice'])
|
||||
->orderByDesc('starred')
|
||||
->orderByDesc('created_by')
|
||||
->get();
|
||||
|
||||
@@ -41,6 +41,11 @@ class Product extends Model
|
||||
return $this->hasOne(Price::class)->latestOfMany('created_at');
|
||||
}
|
||||
|
||||
public function lowestPrice(): HasOne
|
||||
{
|
||||
return $this->hasOne(Price::class)->ofMany('price', 'MIN');
|
||||
}
|
||||
|
||||
public function stock(): HasMany
|
||||
{
|
||||
return $this->hasMany(Stock::class);
|
||||
|
||||
Reference in New Issue
Block a user