Completed
Branch master (17739d)
by Yaro
01:52
created

DeleteAction::isAllowed()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

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