/** * Raise an event when a post is deleted. * * @return void */ public static function boot() { parent::boot(); static::deleted(function ($user) { $user->raise(new UserWasDeleted($user)); }); }
/** * Raise an event when a discussion is deleted. * * @return void */ public static function boot() { parent::boot(); static::deleted(function ($discussion) { $discussion->raise(new DiscussionWasDeleted($discussion)); $discussion->posts()->allTypes()->delete(); $discussion->readers()->detach(); }); }
public function setupModels() { Model::setForum($this->app['flarum.forum']); Model::setValidator($this->app['validator']); User::setHasher($this->app['hash']); User::setFormatter($this->app['flarum.formatter']); User::registerPreference('discloseOnline', 'boolval', true); User::registerPreference('indexProfile', 'boolval', true); }
/** * Create a new model instance according to the post's type. * * @param array $attributes * @return static|object */ public function newFromBuilder($attributes = [], $connection = null) { if (!empty($attributes->type)) { $type = $attributes->type; if (isset(static::$types[$type])) { $class = static::$types[$type]; if (class_exists($class)) { $instance = new $class(); $instance->exists = true; $instance->setRawAttributes((array) $attributes, true); $instance->setConnection($connection ?: $this->connection); return $instance; } } } return parent::newFromBuilder($attributes, $connection); }