I can not access to $ad->stats->todayImpressions();
in my detail view of an ads. How can access to a filter relationship? When I try to dump this:
dd($ad->stats->todayImpressions());
I get this error:
Method todayImpressions does not exist.
These are the two model involved:
class Ad extends Model
{
/**
* The stats that belong to the ads.
*/
public function stats(){
return $this->hasMany('App\Models\Stats', 'ad', 'id');
}
}
class Stats extends Model
{
/**
* The # of the today impressions for the current stats.
*/
public function scopeTodayImpressions($query) {
$todayTime = strtotime('today midnight');
return $query->where('thetime', $todayTime);
}
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2y5XhyY
via IFTTT
Aucun commentaire:
Enregistrer un commentaire