I have 3 tables
1 Advertiser
2 Adverts
- id
Advertiser can have multiple adverts
3 instances
- id
- ad_id
- date
Adverts can have multiple date - date is the column in instances table
$input = Input::get('fullname'); // fullname is the id of adverstiser
// input is the advertiser id
$adverts = DB::table('adverts')->where('a_id',$input)->get();
return view('adverts.index', compact( 'adverts'));
This query will give me all adverts data related to advertiser.
fine with that.
in my adverts.index
@foreach($adverts as $advert)
<div class="caption">
<ul>
<li><i class="fa fa-picture-o"></i> {{$advert->height}}x{{$advert->height}}</li>
<li><i class="fa fa-file"></i> {{$advert->finfo}}</li>
<li><i class="fa fa-eye"></i> Last seen:</li>
<li><i class="fa fa-link"></i> {{$advert->domain}}</li>
<li><i class="fa fa-link"></i> <a href="{{$advert->src}}" target="_blank">Visit full ad</a></li>
</ul>
</div>
@endforeach
I would like to get the last seen date from the instance table.
SELECT MAX(date) AS "Last seen date" FROM instances WHERE ad_id =1
ad_id is the primary key id from adverts table
I would like to pass the value of this query to them same view as above adverts.index
Is the loop must be done in view?
Or something else I am missing.


$advertshould have its own "last seen date"? Also, do you have models defined for these tables?