alijumaan / laravel-ecommerce

142 stars 71 forks source link

Refactor for can't re-used code. #3

Closed Muneebkh2 closed 3 years ago

Muneebkh2 commented 3 years ago

https://github.com/alijumaan/Laravel-Ecommerce/blob/0fd727565de50cd3063262d7738a53a2f539cc8a/app/Repositories/Frontend/ProductRepository.php#L71

you just need to save auth user id in var to reuse in method. you also use this in line 76. AuthUserId = auth()->user()->id

Loafer19 commented 3 years ago

also you can use relation like this auth()->user()->ratings()->where('product_id', $product->id)->first() or add a scope for getting one project from relation

alijumaan commented 3 years ago

Your second comment I think beter for use

I user relationship so, in this case, no need to call auth user_id again.

Thank you for your review.