Passed
Push — develop ( b4818b...dcecff )
by Septianata
16:14
created

OrderResource   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 13
c 1
b 0
f 0
dl 0
loc 22
ccs 0
cts 12
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 14 2
1
<?php
2
3
namespace App\Http\Resources\DataTables\Report;
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
            'code' => view('components.datatables.link', [
22
                'url' => route('admin.order.show', $this->resource->code),
23
                'name' => $this->resource->code,
24
            ])->render(),
25
            'customer_fullname' => view('components.datatables.link', [
26
                'url' => route('admin.customer.edit', $this->resource->customer),
27
                'name' => $this->resource->customer->fullname,
28
            ])->render(),
29
            'created_at' => $this->resource->created_at->translatedFormat('d F Y H:i:s'),
0 ignored issues
show
Bug introduced by
The method translatedFormat() does not exist on DateTime. It seems like you code against a sub-type of said class. However, the method does not exist in pq\DateTime. Are you sure you never get one of those? ( Ignorable by Annotation )

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

29
            'created_at' => $this->resource->created_at->/** @scrutinizer ignore-call */ translatedFormat('d F Y H:i:s'),
Loading history...
30
            'schedule_date' => $this->resource->schedule_date ? $this->resource->schedule_date->translatedFormat('d F Y H:i:s') : trans('Unscheduled'),
31
            'status' => $this->resource->status->label,
32
        ];
33
    }
34
}
35