saksham's avatar

Identify User without login

I want to create coupon module in my e-commerce mobile application, i want to know how to identify applied coupon of unique device, when i am not logged in i am confused for this can anyone help me.

i want to use cache system but to identify what do?

0 likes
1 reply
AlexDemin's avatar

Let's suppose you have a $request->coupon_code and Eloquent relations (one to many) like User->coupons(), in this case, you can identify the user this way:

$user = User::whereHas('coupons', function ($query) {
    $query->where('coupon_code', request()->coupon_code);
})->firstOrFail();

Please or to participate in this conversation.