mardi 29 janvier 2019

Why application hungs when using 'count' keyword as localScope function name

I have class Reservation in php Laravel 5. I create localScope query. When i use special word count, which is aggregate for sum in scope function name, my application hang up. When i change function name to something not like keyword like total, everything works fine. Why application hangs when i use special keyword ? How does process works. Stackoverflow ?

class Reservation extends Model { public function scopecount($query){ return $query->count(); }

I return it as:

$count = Reservation::currentMonth()->count();

My function currentMonth:

public function scopecurrentMonth($query){ return $query->where('date_from','>=', Carbon::now()->startOfMonth()) ->where('date_to','<=', Carbon::now()->endOfMonth()); } So why it hungs? When i change name count to total:

public function scopetotal($query){ return $query->count(); }

and

$count = Reservation::currentMonth()->total();

everything works fine.

So why it hungs ?



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2sVQgMd
via IFTTT

Aucun commentaire:

Enregistrer un commentaire