| @@ 8-46 (lines=39) @@ | ||
| 5 | /** |
|
| 6 | * Class Save. |
|
| 7 | */ |
|
| 8 | class Destroy extends FormButton |
|
| 9 | { |
|
| 10 | protected $show = true; |
|
| 11 | protected $name = 'destroy'; |
|
| 12 | protected $iconClass = 'fa-ban'; |
|
| 13 | ||
| 14 | public function __construct() |
|
| 15 | { |
|
| 16 | $this->setText(trans('sleeping_owl::lang.table.destroy')); |
|
| 17 | } |
|
| 18 | ||
| 19 | /** |
|
| 20 | * Init Cancel Button. |
|
| 21 | */ |
|
| 22 | public function initialize() |
|
| 23 | { |
|
| 24 | parent::initialize(); |
|
| 25 | $this->setHtmlAttributes([ |
|
| 26 | 'type' => 'submit', |
|
| 27 | 'name' => 'next_action', |
|
| 28 | 'class' => 'btn btn-danger', |
|
| 29 | 'data-url'=>$this->getModelConfiguration()->getDestroyUrl($this->getModel()->getKey()), |
|
| 30 | 'data-redirect'=>$this->getModelConfiguration()->getDisplayUrl(), |
|
| 31 | ]); |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @return bool |
|
| 36 | */ |
|
| 37 | public function canShow() |
|
| 38 | { |
|
| 39 | if (is_null($this->getModel()->getKey()) || ! $this->show) { |
|
| 40 | return false; |
|
| 41 | } |
|
| 42 | ||
| 43 | $this->show = $this->isTrashed() && |
|
| 44 | $this->getModelConfiguration()->isDestroyable($this->getModel()); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 9-48 (lines=40) @@ | ||
| 6 | /** |
|
| 7 | * Class Save. |
|
| 8 | */ |
|
| 9 | class Restore extends FormButton |
|
| 10 | { |
|
| 11 | protected $show = true; |
|
| 12 | protected $name = 'restore'; |
|
| 13 | protected $iconClass = 'fa-reply'; |
|
| 14 | ||
| 15 | public function __construct() |
|
| 16 | { |
|
| 17 | $this->setText(trans('sleeping_owl::lang.table.restore')); |
|
| 18 | } |
|
| 19 | ||
| 20 | /** |
|
| 21 | * Init Cancel Button. |
|
| 22 | */ |
|
| 23 | public function initialize() |
|
| 24 | { |
|
| 25 | parent::initialize(); |
|
| 26 | ||
| 27 | $this->setHtmlAttributes([ |
|
| 28 | 'type' => 'submit', |
|
| 29 | 'name' => 'next_action', |
|
| 30 | 'class' => 'btn btn-warning', |
|
| 31 | 'data-url'=> $this->getModelConfiguration()->getRestoreUrl($this->getModel()->getKey()), |
|
| 32 | 'data-redirect'=> $this->getModelConfiguration()->getEditUrl($this->getModel()->getKey()), |
|
| 33 | ]); |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @return bool |
|
| 38 | */ |
|
| 39 | public function canShow() |
|
| 40 | { |
|
| 41 | if (is_null($this->getModel()->getKey()) || ! $this->show) { |
|
| 42 | return false; |
|
| 43 | } |
|
| 44 | ||
| 45 | $this->show = $this->isTrashed() && |
|
| 46 | $this->getModelConfiguration()->isRestorable($this->getModel()); |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||