Add product view tracking and related functionality
- Implemented product view tracking in ProductController to log user views. - Added a relationship for viewed products in the User model. - Introduced a method in ProductRepository to filter products viewed by a user. - Updated API routes to include endpoint for retrieving viewed products. - Commented out SMS notification logic in SendOrderCreatedNotification. - Removed CreateOrderServiceTest as it is no longer needed.
This commit is contained in:
@@ -150,6 +150,20 @@ class ProductRepository
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter by viewed by user
|
||||
*/
|
||||
public function applyViewedBy($user): self
|
||||
{
|
||||
$this->queryBuilder
|
||||
->join('product_views', 'products.id', '=', 'product_views.product_id')
|
||||
->where('product_views.user_id', $user->id)
|
||||
->orderBy('product_views.updated_at', 'desc')
|
||||
->select('products.*');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* "Where IN" clause
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user