Reputation: 532
I have to arrays and I have to find difference values from it. Here is my Laravel Controller code
$product_list = Operation::where('kvit_id', $kvit->id)->pluck('product_id')->toArray();
$hamkor_products = ListProduct::where('user_id', $newkvit->user_id)->pluck('product_id')->toArray();
$operProductList = array_diff($product_list, $hamkor_products);
dd($product_list, $hamkor_products, $operProductList);
Here is result which I'm getting
What kind of mistake I made? $operProductList
is returns []
Upvotes: 0
Views: 425
Reputation: 1789
You must just change the order of parameters in array_diff()
, it must be like :
$product_list = Operation::where('kvit_id', $kvit->id)->pluck('product_id')->toArray();
$hamkor_products = ListProduct::where('user_id', $newkvit->user_id)->pluck('product_id')->toArray();
$operProductList = array_diff($hamkor_products, $product_list);
dd($product_list, $hamkor_products, $operProductList);
Upvotes: 1