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

DeleteAction   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 93.33%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 34
ccs 14
cts 15
cp 0.9333
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 10 2
A isAllowed() 0 9 3
A shouldRender() 0 8 2
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