I have two tables: revisions_intervals and revisions. Revisions_intervals has many revisions and one revision belongs to one revisions_intervals. So, i my revision model:
public function revision_interval() {
return $this->belongsTo('App\Revision_interval');
}
and in my revision_interval model:
public function revisions() {
return $this->hasMany('App\Revision');
}
I have view "index" for revisions intervals, where for each one I want to show how many relations are related to specified revision interval. In my "index" blade:
@foreach($revision_intervals as $interval)
<tr>
<td>
/
</td>
</tr>
@endforeach
This "past()" method should be "scope" method for revision model, but this doesnt work. How to do it? ( Select specified revisions for collection )
I have "scopePast" method in my revision model:
public function scopePast($query) {
$date = \Carbon\Carbon::now()->format('Y-m-d');
$query->where('date_of_revision', '>', $date);
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire