Add two events for closet

This commit is contained in:
Pig Fang 2018-09-10 21:32:42 +08:00
parent 8ee01b7adb
commit ab34d7aa4f
3 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,15 @@
<?php
namespace App\Events;
use App\Models\Closet;
class ClosetWasFiltered extends Event
{
public $closet;
public function __construct(Closet $closet)
{
$this->closet = $closet;
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\Events;
use App\Models\Closet;
class ClosetWillBeFiltered extends Event
{
public $closet;
public function __construct(Closet $closet)
{
$this->closet = $closet;
}
}

View File

@ -3,6 +3,7 @@
namespace App\Models;
use DB;
use App\Events;
use Illuminate\Support\Collection;
class Closet
@ -54,6 +55,8 @@ class Closet
true
));
event(new Events\ClosetWillBeFiltered($this));
// Traverse items in the closet
$removedCount = $this->textures->filter(function ($texture) use ($uid) {
$t = Texture::find($texture['tid']);
@ -72,6 +75,8 @@ class Closet
$this->remove($texture['tid']);
})->count();
event(new Events\ClosetWasFiltered($this));
// Return scores if the texture was deleted or set as private
if (option('return_score')) {
app('users')->get($uid)->setScore(