show user only those product which he hasn 27t buyed laravel eloquest

Solutions on MaxInterview for show user only those product which he hasn 27t buyed laravel eloquest by the best coders in the world

showing results for - "show user only those product which he hasn 27t buyed laravel eloquest"
Luka
29 Feb 2016
1$user_id = auth()->user()->id;
2
3Product::where('status', 'active')
4  ->whereNotIn('id', function($query) use ($user_id) {
5    $query->select('product_id')->from(new OrderProduct->getTable())
6      ->where('user_id', $user_id)->where('status', 'delivered')
7		->pluck('product_id')->toArray();
8  });
Valeria
26 Feb 2018
1$user_id = auth()->user()->id;
2
3Product::where('status', 'active')
4  ->whereNotIn('id', function($query) use ($user_id) {
5    $query->select('product_id')->from((new OrderProduct)->getTable())
6      ->where('user_id', $user_id)->where('status', 'delivered')
7		->pluck('product_id')->toArray();
8  });