mirror of
https://github.com/flarum/framework.git
synced 2025-02-06 15:13:00 +08:00
parent
a5b70d5175
commit
ae409751c1
|
@ -55,13 +55,13 @@ abstract class AbstractModel extends Eloquent
|
|||
{
|
||||
parent::boot();
|
||||
|
||||
static::saved(function (AbstractModel $model) {
|
||||
static::saved(function (self $model) {
|
||||
foreach ($model->releaseAfterSaveCallbacks() as $callback) {
|
||||
$callback($model);
|
||||
}
|
||||
});
|
||||
|
||||
static::deleted(function (AbstractModel $model) {
|
||||
static::deleted(function (self $model) {
|
||||
foreach ($model->releaseAfterDeleteCallbacks() as $callback) {
|
||||
$callback($model);
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ class Discussion extends AbstractModel
|
|||
{
|
||||
parent::boot();
|
||||
|
||||
static::deleting(function (Discussion $discussion) {
|
||||
static::deleting(function (self $discussion) {
|
||||
Notification::whereSubjectModel(Post::class)
|
||||
->whereIn('subject_id', function ($query) use ($discussion) {
|
||||
$query->select('id')->from('posts')->where('discussion_id', $discussion->id);
|
||||
|
@ -106,13 +106,13 @@ class Discussion extends AbstractModel
|
|||
->delete();
|
||||
});
|
||||
|
||||
static::deleted(function (Discussion $discussion) {
|
||||
static::deleted(function (self $discussion) {
|
||||
$discussion->raise(new Deleted($discussion));
|
||||
|
||||
Notification::whereSubject($discussion)->delete();
|
||||
});
|
||||
|
||||
static::saving(function (Discussion $discussion) {
|
||||
static::saving(function (self $discussion) {
|
||||
$event = new GetModelIsPrivate($discussion);
|
||||
|
||||
$discussion->is_private = static::$dispatcher->until($event) === true;
|
||||
|
|
|
@ -712,7 +712,7 @@ class Application extends Container implements ApplicationContract
|
|||
public function registerCoreContainerAliases()
|
||||
{
|
||||
$aliases = [
|
||||
'app' => [\Flarum\Foundation\Application::class, \Illuminate\Contracts\Container\Container::class, \Illuminate\Contracts\Foundation\Application::class, \Psr\Container\ContainerInterface::class],
|
||||
'app' => [self::class, \Illuminate\Contracts\Container\Container::class, \Illuminate\Contracts\Foundation\Application::class, \Psr\Container\ContainerInterface::class],
|
||||
'blade.compiler' => [\Illuminate\View\Compilers\BladeCompiler::class],
|
||||
'cache' => [\Illuminate\Cache\CacheManager::class, \Illuminate\Contracts\Cache\Factory::class],
|
||||
'cache.store' => [\Illuminate\Cache\Repository::class, \Illuminate\Contracts\Cache\Repository::class],
|
||||
|
|
|
@ -62,7 +62,7 @@ class Group extends AbstractModel
|
|||
{
|
||||
parent::boot();
|
||||
|
||||
static::deleted(function (Group $group) {
|
||||
static::deleted(function (self $group) {
|
||||
$group->raise(new Deleted($group));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -92,19 +92,19 @@ class Post extends AbstractModel
|
|||
// When a post is created, set its type according to the value of the
|
||||
// subclass. Also give it an auto-incrementing number within the
|
||||
// discussion.
|
||||
static::creating(function (Post $post) {
|
||||
static::creating(function (self $post) {
|
||||
$post->type = $post::$type;
|
||||
$post->number = ++$post->discussion->post_number_index;
|
||||
$post->discussion->save();
|
||||
});
|
||||
|
||||
static::saving(function (Post $post) {
|
||||
static::saving(function (self $post) {
|
||||
$event = new GetModelIsPrivate($post);
|
||||
|
||||
$post->is_private = static::$dispatcher->until($event) === true;
|
||||
});
|
||||
|
||||
static::deleted(function (Post $post) {
|
||||
static::deleted(function (self $post) {
|
||||
$post->raise(new Deleted($post));
|
||||
|
||||
Notification::whereSubject($post)->delete();
|
||||
|
|
|
@ -115,13 +115,13 @@ class User extends AbstractModel
|
|||
parent::boot();
|
||||
|
||||
// Don't allow the root admin to be deleted.
|
||||
static::deleting(function (User $user) {
|
||||
static::deleting(function (self $user) {
|
||||
if ($user->id == 1) {
|
||||
throw new DomainException('Cannot delete the root admin');
|
||||
}
|
||||
});
|
||||
|
||||
static::deleted(function (User $user) {
|
||||
static::deleted(function (self $user) {
|
||||
$user->raise(new Deleted($user));
|
||||
|
||||
Notification::whereSubject($user)->delete();
|
||||
|
|
Loading…
Reference in New Issue
Block a user