saved() public static method

Register a saved model event with the dispatcher.
public static saved ( Closure | string $callback, integer $priority ) : void
$callback Closure | string
$priority integer
return void
Exemplo n.º 1
0
 public function process(Attachment $attachment)
 {
     $this->attachment = $attachment;
     $this->attach($attachment);
     $this->attachment->saved(function (Attachment $attachment) {
         $this->getFinder()->useDisk($attachment->disk);
         $this->apply($attachment);
     });
 }
Exemplo n.º 2
0
 /**
  * @param Dictionary $metaBag
  * @param Model      $parent
  */
 protected function registerMetaBagListeners(Dictionary $metaBag, Model $parent)
 {
     $parent->saved(function () use($metaBag) {
         if (empty($this->saveListeners)) {
             return;
         }
         $this->validateBag($metaBag);
         foreach ($this->saveListeners as $listener) {
             list($callback, $payload) = $listener;
             call_user_func_array($callback, $payload);
         }
     });
     $metaBag->updating(function ($key, $value) {
         $this->validateEntry($key, $value);
     });
     $metaBag->updated($this->enqueueSaveListener(function ($key, $value, $oldValue) {
         $this->updateEntry($key, $value);
     }));
     $metaBag->creating(function ($key, $value) {
         $this->validateEntry($key, $value);
     });
     $metaBag->created($this->enqueueSaveListener(function ($key, $value) {
         $this->createNewEntry($key, $value);
     }));
     $metaBag->deleting(function ($key) {
         $this->validateEntry($key, null);
     });
     $metaBag->deleted(function ($key) {
         $this->deleteEntry($key);
     });
 }