pbnskd
1 week ago
61
12
Laravel

How to get the latest entry as per product id

Posted 1 week ago by pbnskd

I want get the data of latest entry as per product_id entry

Table: stockins

 ID Product_id QTY create_at
1   1   10 2019-08-20 16:22:03
2   2   10 2019-08-20 16:22:03
3   1   10 2019-08-20 16:22:03
4   3   10 2019-08-20 16:22:03 

need Output

 ID Product_id QTY create_at
1   1   10 2019-08-20 16:22:03
2   2   10 2019-08-20 16:22:03
4   3   10 2019-08-20 16:22:03

Code

 $stockin = DB::table('stockins')->latest('created_at')->first();

Please sign in or create an account to participate in this conversation.