i have a favorite list in my website for the users and they can add their favorite house to the wishlist
it goes well but he can not see the wishlist page and an error comes like this:
Trying to get property 'image' of non-object
it's my relations
class Home extends Model {
protected $guarded = [];
public function favorite(){
return $this->hasMany(favorite::class,'house_id');
}
}
class favorite extends Model {
protected $guarded = [];
public function house(){
return $this->belongsTo(home::class);
}
}
my index function in controller:
public function index() {
$favorite=favorite::where('user_id',auth()->user()->id)->get();
return view('favorite.index',compact('favorite'));
}
my index:
@foreach($favorite as $fav)
<tr>
<td>
<a href="property-detail.html"><img src="" alt=""
width="100"></a>
</td>
<td><a href="property-detail.html"></a></td>
<td>خانه خانواده</td>
<td>اجاره</td>
<td>
<div class="price"><span></span><strong>تومان</strong>
</div>
</td>
<td>
<a href="#" class="action-button"><i class="fa fa-ban"></i> <span>حذف</span></a>
</td>
</tr>
@endforeach
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire