This returns a Collection, not an individual instance;
$assignment->grades->where('user_id',3)
if you expect an individual instance, then chain on the first() Collection method before score:
$assignment->grades->where('user_id',3)->first()->score
If you expect a Collection of Grades, then you will need to map over the Collection to get only the attributes you need:
$assignment->grades->where('user_id',3)->map(function ($grade) {
return [
'score' => $grade->score,
'feedback' => $grade->feedback,
];
});
You would need to iterate over the resulting collection to display each score/feedback in your view.
While all of the above is valid, I wonder why you are filtering a Collection by user_id in the first place . Is there an opportunity to use the query to return only the results you needed.