-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathComments.php
53 lines (43 loc) · 1.32 KB
/
Comments.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace Modules\MyBlog\BulkActions;
use App\Abstracts\BulkAction;
use Modules\MyBlog\Exports\Comments as Export;
use Modules\MyBlog\Jobs\DeleteComment;
use Modules\MyBlog\Models\Comment;
class Comments extends BulkAction
{
public $model = Comment::class;
public $text = 'my-blog::general.comments';
public $path = [
'group' => 'my-blog',
'type' => 'comments',
];
public $actions = [
'delete' => [
'name' => 'general.delete',
'message' => 'bulk_actions.message.delete',
'permission' => 'delete-my-blog-comments',
],
'export' => [
'name' => 'general.export',
'message' => 'bulk_actions.message.export',
'type' => 'download',
],
];
public function destroy($request)
{
$comments = $this->getSelectedRecords($request);
foreach ($comments as $comment) {
try {
$this->dispatch(new DeleteComment($comment));
} catch (\Exception $e) {
flash($e->getMessage())->error()->important();
}
}
}
public function export($request)
{
$selected = $this->getSelectedInput($request);
return $this->exportExcel(new Export($selected), trans_choice('my-blog::general.comments', 2));
}
}