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

OrderResource   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 16
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\Order $resource
9
 */
10
class OrderResource 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' => 'order_' . $this->resource->getKey(),
23
            ])->render(),
24
            'code' => $this->resource->code,
25
            'customer_fullname' => view('components.datatables.link', [
26
                'url' => route('customer.edit', $this->resource->customer),
27
                'name' => $this->resource->customer->fullname,
28
            ]),
29
            'schedule_date' => $this->resource->schedule_date,
30
            'status' => $this->resource->status,
31
            'action' => view('components.datatables.link', [
32
                'url' => route('order.edit', $this->resource),
33
                'name' => __('Details'),
34
                'class' => 'btn btn-primary',
35
            ])->render(),
36
        ];
37
    }
38
}
39