2019-11-16 10:21:14 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\BulkActions\Common;
|
|
|
|
|
|
|
|
use App\Abstracts\BulkAction;
|
|
|
|
use App\Exports\Common\Items as Export;
|
2019-12-23 12:46:00 +03:00
|
|
|
use App\Jobs\Common\DeleteItem;
|
2019-11-16 10:21:14 +03:00
|
|
|
use App\Models\Common\Item;
|
|
|
|
|
|
|
|
class Items extends BulkAction
|
|
|
|
{
|
|
|
|
public $model = Item::class;
|
|
|
|
|
|
|
|
public $actions = [
|
|
|
|
'enable' => [
|
|
|
|
'name' => 'general.enable',
|
|
|
|
'message' => 'bulk_actions.message.enable',
|
2020-09-22 00:37:00 +03:00
|
|
|
'path' => ['group' => 'common', 'type' => 'items'],
|
|
|
|
'type' => '*',
|
2019-12-23 12:46:00 +03:00
|
|
|
'permission' => 'update-common-items',
|
2019-11-16 10:21:14 +03:00
|
|
|
],
|
|
|
|
'disable' => [
|
|
|
|
'name' => 'general.disable',
|
|
|
|
'message' => 'bulk_actions.message.disable',
|
2020-09-22 00:37:00 +03:00
|
|
|
'path' => ['group' => 'common', 'type' => 'items'],
|
|
|
|
'type' => '*',
|
2019-12-23 12:46:00 +03:00
|
|
|
'permission' => 'update-common-items',
|
2019-11-16 10:21:14 +03:00
|
|
|
],
|
2019-12-23 12:46:00 +03:00
|
|
|
'delete' => [
|
|
|
|
'name' => 'general.delete',
|
|
|
|
'message' => 'bulk_actions.message.delete',
|
|
|
|
'permission' => 'delete-common-items',
|
2019-11-16 10:21:14 +03:00
|
|
|
],
|
|
|
|
'export' => [
|
|
|
|
'name' => 'general.export',
|
2019-12-23 12:46:00 +03:00
|
|
|
'message' => 'bulk_actions.message.export',
|
2020-09-22 00:37:00 +03:00
|
|
|
'type' => 'download',
|
2019-12-27 15:42:22 +03:00
|
|
|
],
|
2019-11-16 10:21:14 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
public function destroy($request)
|
|
|
|
{
|
2019-12-23 12:46:00 +03:00
|
|
|
$items = $this->getSelectedRecords($request);
|
2019-11-16 10:21:14 +03:00
|
|
|
|
|
|
|
foreach ($items as $item) {
|
2019-12-23 12:46:00 +03:00
|
|
|
try {
|
|
|
|
$this->dispatch(new DeleteItem($item));
|
|
|
|
} catch (\Exception $e) {
|
2021-02-12 19:26:38 +03:00
|
|
|
flash($e->getMessage())->error()->important();
|
2019-11-16 10:21:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function export($request)
|
|
|
|
{
|
2019-12-23 12:46:00 +03:00
|
|
|
$selected = $this->getSelectedInput($request);
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2021-05-23 17:13:13 +03:00
|
|
|
return $this->exportExcel(new Export($selected), trans_choice('general.items', 2));
|
2019-11-16 10:21:14 +03:00
|
|
|
}
|
|
|
|
}
|