Passed
Push — develop ( 3db2fb...b27e40 )
by Septianata
05:11
created

BranchResource   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 21
c 1
b 0
f 0
dl 0
loc 31
ccs 18
cts 18
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 23 1
1
<?php
2
3
namespace App\Http\Resources\DataTables;
4
5
use Illuminate\Http\Resources\Json\JsonResource;
6
7
/**
8
 * @property \App\Models\Branch $resource
9
 */
10
class BranchResource 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
            'address' => $this->resource->address,
26 1
            'google_map_url' => view('components.datatables.link', [
27 1
                'url' => $this->resource->google_map_url,
28 1
                'name' => $this->resource->address_latitude . ' | ' . $this->resource->address_longitude,
29
                'is_new_tab' => true,
30 1
            ])->render(),
31 1
            'action' => view('components.datatables.button-group', [
32
                'elements' => [
33 1
                    view('components.datatables.link-show', [
34 1
                        'url' => route('admin.branch.edit', $this->resource),
35 1
                    ])->render(),
36 1
                    view('components.datatables.link-destroy', [
37 1
                        'url' => route('admin.branch.destroy', $this->resource),
38 1
                    ])->render(),
39
                ],
40 1
            ])->render(),
41
        ];
42
    }
43
}
44