Passed
Push — master ( fabd45...a8694e )
by Ron
03:26 queued 11s
created

FileLinks::toArray()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 13
nc 8
nop 1
dl 0
loc 15
ccs 13
cts 13
cp 1
crap 4
rs 9.8333
c 1
b 0
f 0
1
<?php
2
3
namespace App\Http\Resources;
4
5
use App\Customers as Cust;
6
use Carbon\Carbon;
7
use Illuminate\Http\Resources\Json\JsonResource;
8
9
class FileLinks extends JsonResource
10
{
11
    /**
12
     * Transform the resource into an array.
13
     *
14
     * @param  \Illuminate\Http\Request  $request
15
     * @return array
16
     */
17 8
    public function toArray($request)
18
    {
19
        return [
20 8
            'link_id'      => $this->link_id,
21 8
            'user_id'      => $this->user_id,
22 8
            'cust_id'      => $this->cust_id,
23 8
            'cust_name'    => $this->cust_id ? Cust::find($this->cust_id)->name : 'None',
24 8
            'link_hash'    => $this->link_hash,
25 8
            'link_name'    => $this->link_name,
26 8
            'exp_format'   => Carbon::parse($this->expire)->format('M d, Y'),
27 8
            'expired'      => $this->expire < Carbon::now() ? 1 : 0,
28 8
            'exp_stamp'    => Carbon::parse($this->expire)->format('Y-m-d'),
29 8
            'allow_upload' => $this->allow_upload,
30 8
            'file_count'   => isset($this->file_link_files_count) ? $this->file_link_files_count : 0,
31 8
            'note'         => $this->note
32
        ];
33
    }
34
}
35