Skip to content

Commit

Permalink
Rename isRated to hasRated
Browse files Browse the repository at this point in the history
Signed-off-by: Shakil Alam <[email protected]>
  • Loading branch information
itxshakil committed Aug 14, 2021
1 parent 80a31fb commit 0fae9da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/RatingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RatingController extends Controller
*/
public function store(Product $product, StoreRating $request): Model|Response|Application|ResponseFactory
{
if ($request->user()->isRated($product)) {
if ($request->user()->hasRated($product)) {
return response('You have already added your review', 422);
}

Expand Down
9 changes: 1 addition & 8 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,7 @@ public function ratings(): HasMany
return $this->hasMany(Rating::class);
}

/**
* If User has rated the given product
*
* @param Product $product
*
* @return boolean
*/
public function isRated(Product $product): bool
public function hasRated(Product $product): bool
{
return $this->ratings()->where('product_id', $product->id)->exists();
}
Expand Down

0 comments on commit 0fae9da

Please sign in to comment.