123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace App\Admin\Actions\Grid;
- use App\Admin\Forms\InquiryAssignment as InquiryAssignmentForm;
- use App\Admin\Repositories\DistAdminDistributor;
- use App\Admin\Repositories\DistAppearance;
- use App\Admin\Repositories\DistAppearanceBak;
- use Dcat\Admin\Grid\BatchAction;
- use Dcat\Admin\Widgets\Modal;
- use Illuminate\Http\Request;
- class InitAppearance extends BatchAction
- {
-
- protected $title = '';
- public function __construct()
- {
- $this->title = admin_trans_label('init_appearance');
- }
-
- public function confirm()
- {
-
-
- return ['The data will be restored to its original version. Do you want to continue?', ''];
- }
-
- public function handle(Request $request)
- {
- $keys = $request->input('_key');
- if (is_array($keys) && count($keys) > 0) {
- if (count($keys) > 1) {
- return $this->response()->error('Only one row at a time')->refresh();
- }
- $baseDistId = config('dictionary.base_dist_id');
- if ($baseDistId == $keys[0]) {
- return $this->response()->error('The base distribution cannot be initialized')->refresh();
- }
-
- $row = DistAdminDistributor::getOneById($keys[0]);
- if ($row) {
-
- DistAppearanceBak::backupData($row->appearance_id, $row->id);
-
- DistAppearance::initTheme($row->appearance_id, $row->id);
- return $this->response()->success('Success')->refresh();
- }
- return $this->response()->error('Data does not exist')->refresh();
- } else {
- return $this->response()->error('No data selected!')->refresh();
- }
- }
-
- public function getModalScript(){
- $warning = __('No data selected!');
- return <<<JS
- var key = {$this->getSelectedKeysScript()}
- $('#inquiryIds').val(key);
- JS;
- }
- public function getSelectedKeysScript()
- {
- return "Dcat.grid.selected('{$this->parent->getName()}')";
- }
- }
|