I am trying to show columns of two tables in my template, but I have not been successful
Template :
@foreach ($LatestSeeker_list_adv as $ads)
<span>ads id</span><span>{{ $ads->advertise->id }}</span>
<span>inf id</span><span>{{ $ads->information->id }}</span>
@endforeach
Controller :
public function SeekerLatest()
{
$LatestSeeker_list_adv = Advertise_Model::all();
return view('Users.Seeker.LatestAds.index',compact('LatestSeeker_list_adv','LatestSeeker_list_inf'));
}
Advertise Model :
public function Information()
{
return $this->hasOne('App\Information_Model');
}
Information Model :
public function Advertise()
{
return $this->belongsTo('App\Advertise_Model');
}
advertise migration :
Schema::table('advertise', function($table) {
$table->foreign('information_id')->references('id')->on('information');
});
EDIT :
error :
Trying to get property of non-object (View: C:\Users\Aghapesae\Desktop\barootesources\views\Users\Seeker\LatestAds\Index.blade.php)