Add two events for closet
This commit is contained in:
parent
8ee01b7adb
commit
ab34d7aa4f
15
app/Events/ClosetWasFiltered.php
Normal file
15
app/Events/ClosetWasFiltered.php
Normal 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;
|
||||
}
|
||||
}
|
15
app/Events/ClosetWillBeFiltered.php
Normal file
15
app/Events/ClosetWillBeFiltered.php
Normal 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;
|
||||
}
|
||||
}
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user