簡體   English   中英

我如何將過期產品存儲在 laravel 8

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM