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

FileLinks   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 23
ccs 13
cts 13
cp 1
rs 10
c 1
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 15 4
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