Listen to the creating event.

@param \Illuminate\Database\Eloquent\Model $model
764250
public function creating(Model $model)
    {
        $count = method_exists($model, 'getCounter') ? $model->getCounter() : ($model::count() ?? 0);

        $column = method_exists($model, 'getReferenceColumn') ? $model->getReferenceColumn() : 'reference';

        $prefix = method_exists($model, 'referencePrefix') ? $model->referencePrefix() : config('document.prefix');

        if (Schema::hasColumn($model->getTable(), $column) && is_null($model->$column)) {
            $model->$column = generate_reference($prefix, $count);
        }
    }
738319
private function create($model)
    {
        $attrs = $this->getMutableAttributes($model);
        $this->db
            ->connect()
            ->insert($this->table, array_keys($attrs))
            ->execute(array_values($attrs));
        $model->{$this->key} = $this->db->lastInsertId();
    }
1180007
private function update($model)
    {
        $attrs = $this->getMutableAttributes($model);
        $values = array_values($attrs);
        $values[] = $model->{$this->key};
        $this->db
            ->connect()
            ->update($this->table, array_keys($attrs))
            ->where($this->key . ' = ?')
            ->execute($values);
    }
112538
public function deleting($model)
    {
        foreach ($this->relations as $relation) {
            if ($model->{$relation}()->count() > 0) {
                // Returning false from an Eloquent event listener will cancel the operation.
                return false;
            }
        }
    }
1348320
public function enforceModelRelationship($model)
    {
        // Fallback implementation.
        $listener = new TreeEnforcingListener();
        $listener->process(new EnforceModelRelationshipEvent($this->getEnvironment(), $model));
    }
639207
public function listen()
    {
        $this->connection->enableQueryLog();

        $this->connection->listen(function (QueryExecuted $event) {
            $this->logQuery($event->connectionName, $event->sql, $event->bindings, $event->time);
        });
    }
1213748
public function flush($model)
    {
        if (! $this->shouldMaintainIndex($model)) {
            return;
        }

        $indexColumn = $this->getIndexColumn($model);

        $this->database
            ->table($model->searchableAs())
            ->update([$indexColumn => null]);
    }
1018530
public function onActivityDetails(Model $model)
    {
        $this->onActivity();
        Breadcrumbs::register('logger-activity-details', function($breadcrumbs) use($model) {
            $breadcrumbs->parent('logger-activity');
            $breadcrumbs->push('Show Activity Log #' . $model->id, handles('antares::logger/activity/show/' . $model->id));
        });

        view()->share('breadcrumbs', Breadcrumbs::render('logger-activity-details'));
    }
571948
public function apply(Builder $builder, Model $model): void
    {
        if (empty($this->role)) {
            return;
        }

        $builder->whereHas('roles', function ($query) {
            $query->whereIn('name', (array) $this->role);
        });
    }
844741
public function creating(Model $model)
    {
        if (! $model->created_by) {
            $model->created_by = $this->getAuthenticatedUserId();
        }

        if (! $model->updated_by) {
            $model->updated_by = $this->getAuthenticatedUserId();
        }
    }
1122662
public function delete($model)
    {
        $this->db->connect()
            ->deleteFrom($this->table)
            ->where($this->key . ' = ?')
            ->execute([$model->{$this->key}]);
        $model->{$this->key} = null;
    }
479166
public function afterDelete(Model &$model)
    {
        /** @var \T4\Orm\Model $class */
        $class = get_class($model);
        $tableName = $class::getTableName();
        /** @var \T4\Dbal\Connection $connection */
        $connection = $class::getDbConnection();

        $query = (new Query())
            ->delete()
            ->table($tableName)
            ->where('__lft>:lft AND __rgt<:rgt')
            ->params([':lft' => $model->__lft, ':rgt' => $model->__rgt]);
        $connection->execute($query);

        $this->removeFromTreeByLftRgt($connection, $tableName, $model->__lft, $model->__rgt);

        $model->__lft = 0;
        $model->__rgt = 0;
        $model->__lvl = 0;
        $model->__prt = 0;
    }
1221260
public function creating(Model $model)
    {
        if ($model instanceof SingleSiteInterface) {
            $site = $this->router->getActiveSite() ?: $this->site->findDefault();

            $model->{SingleSiteInterface::ATTR_SITE} = ($site ? $site->getId() : null);
        }
    }
1169806
protected function setForeignAttributesForCreate(Model $model)
    {
        $property = $this->getPlainForeignKey();

        $model->{$property} = $this->getParentKey();

        //
        $property = $this->getPlainMorphType();

        $model->{$property} = $this->morphClass;
    }
391790
public static function insertModel($model)
    {
        foreach(AnnotationManager::getPropertiesAnnotations(BeanFactory::getObjectClass($model), RelationBase::class) as $propertyName => $annotations)
        {
            if(null === $model[$propertyName])
            {
                continue;
            }
            $annotation = $annotations[0];
            Insert::parse($model, $propertyName, $annotation);
        }
    }
664757
protected function prepareModel(Model $model)
    {
        if (is_callable($this->prepareModel)) {
            call_user_func($this->prepareModel, $model);
        } else {
            foreach ($model->attributes() as $attribute) {
                $value = Yii::$app->settings->get($this->getSection($model), $attribute);

                if (!is_null($value)) {
                    $model->{$attribute} = $value;
                }
            }
        }
    }
1083491
public function saved(Model $model)
    {
        if ($model::$__es_enable && $model->shouldIndex())
        {
            Queue::push('Iverberk\Larasearch\Jobs\ReindexJob', $this->findAffectedModels($model));
        }
    }