-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathPosts.php
63 lines (53 loc) · 1.65 KB
/
Posts.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
54
55
56
57
58
59
60
61
62
63
<?php
namespace Modules\MyBlog\BulkActions;
use App\Abstracts\BulkAction;
use Modules\MyBlog\Exports\Posts as Export;
use Modules\MyBlog\Jobs\DeletePost;
use Modules\MyBlog\Models\Post;
class Posts extends BulkAction
{
public $model = Post::class;
public $text = 'my-blog::general.posts';
public $path = [
'group' => 'my-blog',
'type' => 'posts',
];
public $actions = [
'enable' => [
'name' => 'general.enable',
'message' => 'bulk_actions.message.enable',
'permission' => 'update-my-blog-posts',
],
'disable' => [
'name' => 'general.disable',
'message' => 'bulk_actions.message.disable',
'permission' => 'update-my-blog-posts',
],
'delete' => [
'name' => 'general.delete',
'message' => 'bulk_actions.message.delete',
'permission' => 'delete-my-blog-posts',
],
'export' => [
'name' => 'general.export',
'message' => 'bulk_actions.message.export',
'type' => 'download',
],
];
public function destroy($request)
{
$posts = $this->getSelectedRecords($request, 'comments');
foreach ($posts as $post) {
try {
$this->dispatch(new DeletePost($post));
} 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.posts', 2));
}
}