Boot model events
13612
protected static function boot()
    {
        parent::boot();

        static::addGlobalScope(new MailingScope);

        static::creating(function ($node)
        {
            if (empty($node->published_at))
            {
                $node->published_at = Carbon::now();
            }

            $node->fireNodeEvent('creating');
        });

        static::created(function ($node)
        {
            $node->propagateIdToSources(false);

            $node->fireNodeEvent('created');
        });

        static::saving(function ($node)
        {
            $node->validateCanHaveParentOfType();

            $node->fireNodeEvent('saving');
        });

        foreach (['updating', 'updated', 'deleting', 'deleted', 'saved'] as $event)
        {
            static::$event(function ($node) use ($event)
            {
                $node->fireNodeEvent($event);
            });
        }
    }
1286051
public static function bootRevisionableTrait()
    {
        static::saving(function ($model) {
            $model->preSave();
        });

        static::saved(function ($model) {
            $model->postSave();
        });

        static::created(function ($model) {
            $model->postCreate();
        });

        static::deleted(function ($model) {
            $model->preSave();
            $model->postDelete();
        });
    }
497835
protected static function boot()
    {
        parent::boot();

        static::deleting(function ($model) {
            $model->roles()->detach();

            $model->permissions()->detach();
        });
    }
329945
protected static function boot() {
        parent::boot();

        if (config('filer.cleanup_on_delete')) {
            static::deleting(function ($file) {
                $path = config('filer.path.absolute') . "{$file->path}/{$file->filename}";

                if (is_file($path)) {
                    unlink($path);
                }
            });
        }

        // Whenever a new model is created in the database, we add a hash
        static::creating(function ($model) {
            $model->hash = $model->generateHash();
        });
    }
1331890
protected static function bootModifyBy()
	{
		static::creating(function ($model)
		{
			$model->created_by = user()->id;
			$model->updated_by = user()->id;
		});

		static::updating(function ($model)
		{
            // if cronjob / no user
            if(user()->id >= 1) {
                $model->updated_by = user()->id;
            }
		});

		static::deleting(function ($model)
		{
			$model->deleted_by = user()->id;
			$model->save();
		});
	}
839901
public function boot()
    {
        $this->setFingerprint(mt_rand());

        $this->setArguments($this->getMessages());
        $this->setSingular($this->getArgument('title'));
        $this->setPlural($this->getArgument('title'));
        // $this->setValue($this->getArgument('default'));

        $this->manager->boot($this);
    }
404539
protected function bootIfNotBooted()
    {
        if ( ! isset(static::$booted[get_class($this)]))
        {
            static::$booted[get_class($this)] = true;

            static::boot();

        }
    }
1336099
public function boot()
    {
        $this->loader->loadManifest();

        foreach ($this->extensions as $extension) {
            try {
                $this->eventDispatcher->dispatch(new Booted($extension));

                $name = $extension->getPackage()->getName();

                $this->eventDispatcher->dispatch('extension.started', [$name, []]);
                $this->eventDispatcher->dispatch('extension.started: {$name}', [[]]);
                $this->eventDispatcher->dispatch(new ComponentStarted($name));

                $this->eventDispatcher->dispatch('extension.booted', [$name, []]);
                $this->eventDispatcher->dispatch('extension.booted: {$name}', [[]]);
                $this->eventDispatcher->dispatch(new ComponentBooted($name));
            } catch (Exception $e) {
                throw $e;
            }
        }

        $this->eventDispatcher->dispatch(new BootedAll());
        $this->eventDispatcher->dispatch('antares.extension: booted');
        $this->eventDispatcher->dispatch(new ComponentsBooted());

        $this->loader->writeManifest();
        $this->booted = true;
    }
450485
public function boot()
    {
        parent::boot();
        $this->bootTwig();
        $this->bootDatabase();
        $this->bootForm();
        $this->bootTranslation();
        $this->bootSwiftmailer();
        $this->registerControllers();
        $this->registerRoutes();
    }
889044
protected static function boot()
    {
        parent::boot();

        self::saving(
            function ($theme) {
                Event::fire('theme:saving', [$theme]);
            }
        );

        self::saved(
            function ($theme) {
                Event::fire('theme:saved', [$theme]);
            }
        );

        self::updating(
            function ($theme) {
                Event::fire('theme:updating', [$theme]);
            }
        );

        self::creating(
            function ($theme) {
                Event::fire('theme:creating', [$theme]);
            }
        );

        self::created(
            function ($theme) {
                Event::fire('theme:created', [$theme]);
            }
        );

        self::updated(
            function ($theme) {
                Event::fire('theme:updated', [$theme]);
            }
        );

        self::deleting(
            function ($theme) {
                Event::fire('theme:deleting', [$theme]);
            }
        );

        self::deleted(
            function ($theme) {
                Event::fire('theme:deleted', [$theme]);
            }
        );
    }
976158
public static function boot()
    {
        parent::boot();

        self::creating(function ($invite) {
            if (!$invite->code) {
                $invite->code = Str::random(20);
            }
        });
    }
846148
public function boot()
    {
        View::share('users', User::all());
        View::share('comments', Comment::all());
        View::share('comment', Comment::first());
    }
1345138
public function boot()
    {
        $this->commands([
            MakeContractCommand::class,
            MakeExceptionCommand::class,
            MakeModelCommand::class,
            MakeObserverCommand::class,
            MakePresenterCommand::class,
            MakeProcessorCommand::class,
            MakeServiceCommand::class,
            MakeTraitCommand::class,
            MakeTransformerCommand::class,
        ]);
    }
879376
final public function bootstrap() : void
    {
        foreach ([SIGINT, SIGTERM] as $sig) {
            SWProcess::signal($sig, function (int $sig) {
                $this->backend->shutdown($sig);
            });
        }
    }
32573
public static function boot()
    {
        parent::boot();

        static::created(function(ApiKey $apiKey) {
            self::logApiKeyAdminEvent($apiKey, self::EVENT_NAME_CREATED);
        });

        static::updated(function($apiKey) {

            $changed = $apiKey->getDirty();

            if (isset($changed) && $changed['active'] === 1) {
                self::logApiKeyAdminEvent($apiKey, self::EVENT_NAME_ACTIVATED);
            }

            if (isset($changed) && $changed['active'] === 0) {
                self::logApiKeyAdminEvent($apiKey, self::EVENT_NAME_DEACTIVATED);
            }

        });

        static::deleted(function($apiKey) {
            self::logApiKeyAdminEvent($apiKey, self::EVENT_NAME_DELETED);
        });
    }
1300588
private function boot()
    {
        $messages = [];
        foreach ($this->messaging as $message) {
            $receiveMessage = new ReceiveMessage(Arr::get($message, 'recipient.id'), Arr::get($message, 'sender.id'));
            // is payload
            if (Arr::has($message, 'postback.payload') || Arr::has($message, 'message.quick_reply.payload')) {
                $receiveMessage
                    ->setMessage(Arr::get($message, 'message.text'))
                    ->setReferral(Arr::get($message, 'postback.referral', []))
                    ->setPostback(Arr::get(
                        $message,
                        'postback.payload',
                        Arr::get(
                            $message,
                            'message.quick_reply.payload'
                        )
                    ))
                    ->setPayload(true);
            } else {
                $receiveMessage
                    ->setMessage(Arr::get($message, 'message.text'))
                    ->setReferral(Arr::get($message, 'referral', []))
                    ->setSkip(
                        Arr::has($message, 'delivery') ||
                        Arr::has($message, 'message.is_echo') ||
                        (!Arr::has($message, 'message.text') && !Arr::has($message, 'message.attachments') && !Arr::has($message, 'referral'))
                    )
                    ->setAttachments(Arr::get($message, 'message.attachments', []))
                    ->setNlp(Arr::get($message, 'message.nlp', []));
            }

            $messages[] = $receiveMessage;
        }

        $this->collection = new ReceiveMessageCollection($messages);

        if ($this->filterSkip) {
            $this->collection = $this->collection->filterSkip();
        }
    }
242381
public static function boot() {
        parent::boot();

        $myself   = get_called_class();
        $hooks    = array('before' => 'ing', 'after' => 'ed');
        $radicals = array('sav', 'validat', 'creat', 'updat', 'delet');

        foreach ($radicals as $rad) {
            foreach ($hooks as $hook => $event) {
                $method = $hook.ucfirst($rad).'e';
                if (method_exists($myself, $method)) {
                    $eventMethod = $rad.$event;
                    self::$eventMethod(function($model) use ($method){
                        return $model->$method($model);
                    });
                }
            }
        }
    }