Completed
Push — master ( 17739d...6c5d1a )
by Yaro
07:08
created

DeleteAction::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Yaro\Jarboe\Table\Actions;
4
5
class DeleteAction extends AbstractAction
6
{
7
    protected $ident = 'delete';
8
9 2
    public function render($model = null)
10
    {
11 2
        $crud = $this->crud();
12 2
        $isVisible = parent::shouldRender($model);
13 2
        if ($crud->isSoftDeleteEnabled()) {
14 1
            $isVisible = !$model->trashed();
15
        }
16
17 2
        return view('jarboe::crud.actions.delete', compact('crud', 'model', 'isVisible'));
18
    }
19
20 7
    public function isAllowed($model = null)
21
    {
22 7
        $isAllowed = parent::isAllowed($model);
23 7
        if ($this->crud()->isSoftDeleteEnabled()) {
24 5
            return $isAllowed && !$model->trashed();
25
        }
26
27 4
        return $isAllowed;
28
    }
29
30 2
    public function shouldRender($model = null)
31
    {
32 2
        if ($this->crud()->isSoftDeleteEnabled()) {
33 2
            return true;
34
        }
35
36 2
        return parent::shouldRender($model);
37
    }
38
}
39