2015-12-06 16:02:48 +00:00
|
|
|
<?php
|
2016-07-28 09:56:24 +00:00
|
|
|
|
2015-12-06 16:02:48 +00:00
|
|
|
namespace Nodes\CounterCache\Traits;
|
|
|
|
|
|
|
|
/**
|
2016-07-28 09:56:24 +00:00
|
|
|
* Trait CounterCacheUpdated.
|
2015-12-06 16:02:48 +00:00
|
|
|
*
|
|
|
|
* @trait
|
|
|
|
*/
|
|
|
|
trait CounterCacheUpdated
|
|
|
|
{
|
|
|
|
/**
|
2016-07-28 09:56:24 +00:00
|
|
|
* The "booting" of trait.
|
2015-12-06 16:02:48 +00:00
|
|
|
*
|
|
|
|
* @author Morten Rugaard <moru@nodes.dk>
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function bootCounterCacheUpdated()
|
|
|
|
{
|
2016-07-28 09:56:24 +00:00
|
|
|
static::updated(function ($model) {
|
2015-12-06 16:02:48 +00:00
|
|
|
app('Nodes\CounterCache\CounterCache')->count($model);
|
|
|
|
});
|
|
|
|
}
|
2016-07-28 09:56:24 +00:00
|
|
|
}
|