提交 bfb8bff1 编写于 作者: E eddy8

improve: ContentDeleted 事件参数调整

上级 3f650824
......@@ -5,21 +5,22 @@ namespace App\Events;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Collection;
class ContentDeleted
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $id;
public $contents;
/**
* Create a new event instance.
*
* @param array $id 内容ID
* @param Collection $contents 内容ID
* @return void
*/
public function __construct(array $id)
public function __construct(Collection $contents)
{
$this->id = $id;
$this->contents = $contents;
}
}
......@@ -253,8 +253,9 @@ class ContentController extends Controller
public function delete($entity, $id)
{
try {
$content = ContentRepository::findOrFail($id);
ContentRepository::delete($id);
event(new ContentDeleted([$id]));
event(new ContentDeleted(collect([$content])));
return [
'code' => 0,
......@@ -293,8 +294,9 @@ class ContentController extends Controller
$message = '';
switch ($type) {
case 'delete':
$contents = ContentRepository::model()->whereIn('id', $ids)->get();
ContentRepository::model()->whereIn('id', $ids)->delete();
event(new ContentDeleted($ids));
event(new ContentDeleted($contents));
break;
default:
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册