<?php

namespace Clevercherry\Backslash4\Traits;

trait observable
{	
	/**
	 * Run actions on a models update or create
	 */
    public static function bootObservable()
    {
        static::created(function ($model) {
        	if($model->searchCache()) {
            	$model->buildCache();
        	}
        });

        static::updated(function ($model) {
        	if($model->searchCache()) {
            	$model->buildCache();
        	}
        });
    }
}