I have a polymorphic relation between organizations and ratings. My ratings table is set up like so:
id - integer
user_id - integer
score - integer
ratable_type - text
ratable_id - integer
Calling $org->ratings will retrieve an array with all ratings associated with that specific org. However, I only want to see if there is a rating with a specific user_id value.
Basically, I want to retrieve the rating with user_id = Auth::user()->id. Is this possibly without looping through all the ratings to see when $org->rating->user_id == Auth::user()->id?
Rating::where('user_id', '=', Auth::user()->id)->where('ratable_type', '=', 'Org')->where('ratable_id', '=', $org->id)->first(), but is there a more succinct way to do this?