Passed
Push — develop ( f66249...fa3cec )
by Septianata
04:23
created

DenominationResource::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 15
ccs 0
cts 13
cp 0
rs 9.8333
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace App\Http\Resources\DataTables;
4
5
use Illuminate\Http\Resources\Json\JsonResource;
6
7
/**
8
 * @property \App\Models\Denomination $resource
9
 */
10
class DenominationResource 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' => 'denomination_' . $this->resource->getKey(),
23
            ])->render(),
24
            'name' => $this->resource->name,
25
            'value' => $this->resource->value,
26
            'type' => $this->resource->type->label,
27
            'quantity_per_bundle' => $this->resource->quantity_per_bundle,
28
            'action' => view('components.datatables.link', [
29
                'url' => route('denomination.edit', $this->resource),
30
                'name' => __('Details'),
31
                'class' => 'btn btn-primary',
32
            ])->render(),
33
        ];
34
    }
35
}
36