You're getting this error because your Eloquent query is using the get() method, which is designed for getting multiple records. In your case, you're getting one record back, but because you're using get(), it's wrapping it inside an array which is why you can't access the name variable directly (when dealing with multiple records you'd normally loop through the returned collection).
However - in your case, you should use first() instead of get(), as you just want one record (the first match).
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community