예제 #1
0
파일: User.php 프로젝트: Qiang1234/core
 /**
  * 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));
     });
 }
예제 #2
0
 /**
  * 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();
     });
 }
예제 #3
0
 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);
 }
예제 #4
0
파일: Post.php 프로젝트: Qiang1234/core
 /**
  * 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);
 }