anish
0
Q:

show user only those products which he hasn't buyed laravel eloquent

$user_id = auth()->user()->id;

Product::where('status', 'active')
  ->whereNotIn('id', function($query) use ($user_id) {
    $query->select('product_id')->from(new OrderProduct->getTable())
      ->where('user_id', $user_id)->where('status', 'delivered')
		->pluck('product_id')->toArray();
  });
1
$user_id = auth()->user()->id;

Product::where('status', 'active')
  ->whereNotIn('id', function($query) use ($user_id) {
    $query->select('product_id')->from((new OrderProduct)->getTable())
      ->where('user_id', $user_id)->where('status', 'delivered')
		->pluck('product_id')->toArray();
  });
0

New to Communities?

Join the community