Passed
Push — develop ( 5f0aa7...736d84 )
by Septianata
04:40
created

BranchResource   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 17
c 1
b 0
f 0
dl 0
loc 26
ccs 0
cts 15
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 18 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
    public function toArray($request)
19
    {
20
        return [
21
            'checkbox' => view('components.datatables.checkbox', [
22
                'id' => 'branch_' . $this->resource->getKey(),
23
            ])->render(),
24
            'name' => $this->resource->name,
25
            'address' => $this->resource->address,
26
            'google_map_url' => view('components.datatables.link', [
27
                'url' => $this->resource->google_map_url,
28
                'name' => $this->resource->address_latitude . ' | ' . $this->resource->address_longitude,
29
                'is_new_tab' => true,
30
            ])->render(),
31
            'action' => view('components.datatables.link', [
32
                'url' => route('branch.edit', $this->resource),
33
                'name' => __('Details'),
34
                'class' => 'btn btn-primary',
35
            ])->render(),
36
        ];
37
    }
38
}
39