Cache model dates

This commit is contained in:
Toby Zerner 2015-07-27 10:59:24 +09:30
parent 0f140bd9d6
commit 372a159521

View File

@ -38,11 +38,17 @@ abstract class Model extends Eloquent
*/
public function getDates()
{
$dates = $this->dates;
static $dates = [];
event(new ModelDates($this, $dates));
$class = get_class($this);
return $dates;
if (! isset($dates[$class])) {
event(new ModelDates($this, $this->dates));
$dates[$class] = $this->dates;
}
return $dates[$class];
}
/**