Cache model dates

This commit is contained in:
Toby Zerner 2015-07-27 10:59:24 +09:30
parent 2422643de6
commit b04e7f96c8

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];
}
/**