2019-11-16 10:21:14 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\BulkActions\Banking;
|
|
|
|
|
|
|
|
use App\Abstracts\BulkAction;
|
2019-12-22 15:58:48 +03:00
|
|
|
use App\Jobs\Banking\DeleteAccount;
|
|
|
|
use App\Jobs\Banking\UpdateAccount;
|
2019-11-16 10:21:14 +03:00
|
|
|
use App\Models\Banking\Account;
|
|
|
|
|
|
|
|
class Accounts extends BulkAction
|
|
|
|
{
|
|
|
|
public $model = Account::class;
|
|
|
|
|
|
|
|
public $actions = [
|
|
|
|
'enable' => [
|
|
|
|
'name' => 'general.enable',
|
|
|
|
'message' => 'bulk_actions.message.enable',
|
|
|
|
'permission' => 'update-banking-accounts'
|
|
|
|
],
|
|
|
|
'disable' => [
|
|
|
|
'name' => 'general.disable',
|
|
|
|
'message' => 'bulk_actions.message.disable',
|
|
|
|
'permission' => 'update-banking-accounts'
|
|
|
|
],
|
|
|
|
'delete' => [
|
|
|
|
'name' => 'general.delete',
|
|
|
|
'message' => 'bulk_actions.message.deletes',
|
|
|
|
'permission' => 'delete-banking-accounts'
|
|
|
|
]
|
|
|
|
];
|
|
|
|
|
|
|
|
public function disable($request)
|
|
|
|
{
|
|
|
|
$selected = $request->get('selected', []);
|
|
|
|
|
|
|
|
$accounts = $this->model::find($selected);
|
|
|
|
|
|
|
|
foreach ($accounts as $account) {
|
2019-12-22 15:58:48 +03:00
|
|
|
try {
|
|
|
|
$this->dispatch(new UpdateAccount($account, request()->merge(['enabled' => 1])));
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
return $e->getMessage();
|
2019-11-16 10:21:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function delete($request)
|
|
|
|
{
|
|
|
|
$this->destroy($request);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function destroy($request)
|
|
|
|
{
|
|
|
|
$selected = $request->get('selected', []);
|
|
|
|
|
|
|
|
$accounts = $this->model::find($selected);
|
|
|
|
|
|
|
|
foreach ($accounts as $account) {
|
2019-12-22 15:58:48 +03:00
|
|
|
try {
|
|
|
|
$this->dispatch(new DeleteAccount($account));
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
return $e->getMessage();
|
2019-11-16 10:21:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|