Maro Paro
Maro Paro

Reputation: 111

Undefined property: Illuminate\Database\Eloquent\Builder

This strange thing is happening to me.I have the code below :

$state_image =States_Images::where('id_state', $id);
echo $delete_path=$state_image->name;

and the result is :

Undefined property: Illuminate\Database\Eloquent\Builder::$name

Someone help me pls :(

Upvotes: 1

Views: 17979

Answers (1)

Anže Časar
Anže Časar

Reputation: 404

You need to finish the query with get() or first(). In your case probably:

States_Images::where('id_state', $id)->first();

Upvotes: 8

Related Questions