Passed
Branch beta (1b8e35)
by Jon
07:16
created

RoleAttribute   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDeleteButtonAttribute() 0 13 2
A getEditButtonAttribute() 0 3 1
A getActionButtonsAttribute() 0 3 1
1
<?php
2
3
namespace App\Models\Access\Role\Traits\Attribute;
4
5
/**
6
 * Class RoleAttribute.
7
 */
8
trait RoleAttribute
9
{
10
    /**
11
     * @return string
12
     */
13
    public function getEditButtonAttribute()
14
    {
15
        return '<a href="' . route('admin.access.role.edit', $this) . '" class="btn btn-xs btn-primary"><i class="fa fa-pencil" data-toggle="tooltip" data-placement="top" title="' . trans('buttons.general.crud.edit') . '"></i></a> ';
0 ignored issues
show
Bug introduced by
$this of type App\Models\Access\Role\T...Attribute\RoleAttribute is incompatible with the type array expected by parameter $parameters of route(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

15
        return '<a href="' . route('admin.access.role.edit', /** @scrutinizer ignore-type */ $this) . '" class="btn btn-xs btn-primary"><i class="fa fa-pencil" data-toggle="tooltip" data-placement="top" title="' . trans('buttons.general.crud.edit') . '"></i></a> ';
Loading history...
16
    }
17
18
    /**
19
     * @return string
20
     */
21
    public function getDeleteButtonAttribute()
22
    {
23
        //Can't delete master admin role
24
        if ($this->id != 1) {
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on App\Models\Access\Role\T...Attribute\RoleAttribute. Did you maybe forget to declare it?
Loading history...
25
            return '<a href="' . route('admin.access.role.destroy', $this) . '"
0 ignored issues
show
Bug introduced by
$this of type App\Models\Access\Role\T...Attribute\RoleAttribute is incompatible with the type array expected by parameter $parameters of route(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

25
            return '<a href="' . route('admin.access.role.destroy', /** @scrutinizer ignore-type */ $this) . '"
Loading history...
26
                data-method="delete"
27
                data-trans-button-cancel="' . trans('buttons.general.cancel') . '"
28
                data-trans-button-confirm="' . trans('buttons.general.crud.delete') . '"
29
                data-trans-title="' . trans('strings.backend.general.are_you_sure') . '"
30
                class="btn btn-xs btn-danger"><i class="fa fa-times" data-toggle="tooltip" data-placement="top" title="' . trans('buttons.general.crud.delete') . '"></i></a>';
31
        }
32
33
        return '';
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function getActionButtonsAttribute()
40
    {
41
        return $this->edit_button . $this->delete_button;
0 ignored issues
show
Bug Best Practice introduced by
The property edit_button does not exist on App\Models\Access\Role\T...Attribute\RoleAttribute. Did you maybe forget to declare it?
Loading history...
Bug Best Practice introduced by
The property delete_button does not exist on App\Models\Access\Role\T...Attribute\RoleAttribute. Did you maybe forget to declare it?
Loading history...
42
    }
43
}
44