[英]how can i store the expired products in laravel 8
#這是controller中的代碼#
public function index()
{
$expired_product = Product::select('expiry_date')
->whereNotNull('expiry_date', "<", Now())->get();
return $expired_product;
}
要獲得過期產品,您可以使用 basic where :
$expired_product = Product::where('expiry_date', "<", Now())->get();
return $expired_product;
use Carbon\Carbon;
要獲取過期產品,您可以使用WhereDate
public function index()
{
$expired_product = Product::select('expiry_date')->WhereDate('expiry_date', '>=', Carbon::now()->format('Y-m-d'))->get();
return $expired_product;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.