DeleteAction   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 17
c 2
b 0
f 0
dl 0
loc 36
rs 10
ccs 18
cts 18
cp 1
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isAllowed() 0 8 3
A shouldRender() 0 7 2
A render() 0 12 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
        $isVisible = parent::shouldRender($model);
12 2
        if ($this->crud()->isSoftDeleteEnabled()) {
13 1
            $isVisible = !$model->trashed();
14
        }
15
16 2
        return view('jarboe::crud.actions.delete', [
17 2
            'crud' => $this->crud(),
18 2
            'model' => $model,
19 2
            'isVisible' => $isVisible,
20 2
            'action' => $this,
21
        ]);
22
    }
23
24 8
    public function isAllowed($model = null)
25
    {
26 8
        $isAllowed = parent::isAllowed($model);
27 8
        if ($this->crud()->isSoftDeleteEnabled()) {
28 6
            return $isAllowed && !$model->trashed();
29
        }
30
31 4
        return $isAllowed;
32
    }
33
34 2
    public function shouldRender($model = null)
35
    {
36 2
        if ($this->crud()->isSoftDeleteEnabled()) {
37 2
            return true;
38
        }
39
40 2
        return parent::shouldRender($model);
41
    }
42
}
43