Passed
Push — develop ( c3d6a0...515348 )
by Septianata
14:35
created

RoleResource::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 18
ccs 14
cts 14
cp 1
rs 9.7666
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace App\Http\Resources\DataTables;
4
5
use Illuminate\Http\Resources\Json\JsonResource;
6
7
/**
8
 * @property \App\Models\Role $resource
9
 */
10
class RoleResource extends JsonResource
11
{
12
    /**
13
     * Transform the resource into an array.
14
     *
15
     * @param  \Illuminate\Http\Request  $request
16
     * @return array
17
     */
18 1
    public function toArray($request)
19
    {
20
        return [
21 1
            'checkbox' => view('components.datatables.checkbox', [
22 1
                'value' => $this->resource->getKey(),
23 1
            ])->render(),
24 1
            'name' => $this->resource->name,
25 1
            'guard_name' => $this->resource->guard_name,
26 1
            'action' => view('components.datatables.button-group', [
27
                'elements' => [
28 1
                    view('components.datatables.link-show', [
29 1
                        'url' => route('admin.role.edit', $this->resource),
30 1
                    ])->render(),
31 1
                    view('components.datatables.link-destroy', [
32 1
                        'url' => route('admin.role.destroy', $this->resource),
33 1
                    ])->render(),
34
                ],
35 1
            ])->render(),
36
        ];
37
    }
38
}
39