|
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
|
|
|
* @property integer $link_id |
|
16
|
|
|
* @property integer $user_id |
|
17
|
|
|
* @property integer $cust_id |
|
18
|
|
|
* @property string $cust_name |
|
19
|
|
|
* @property string $link_hash |
|
20
|
|
|
* @property string $link_name |
|
21
|
|
|
* @property string $exp_format |
|
22
|
|
|
* @property string $expired |
|
23
|
|
|
* @property string $exp_stamp |
|
24
|
|
|
* @property string $allow_upload |
|
25
|
|
|
* @property integer $file_count |
|
26
|
|
|
* @property string $note |
|
27
|
|
|
* @property string $expire |
|
28
|
|
|
* @property integer $file_link_files_count |
|
29
|
|
|
* @return array |
|
30
|
|
|
*/ |
|
31
|
6 |
|
public function toArray($request) |
|
32
|
|
|
{ |
|
33
|
|
|
// return parent::toArray($request); |
|
34
|
|
|
return [ |
|
35
|
6 |
|
'link_id' => $this->link_id, |
|
|
|
|
|
|
36
|
6 |
|
'user_id' => $this->user_id, |
|
|
|
|
|
|
37
|
6 |
|
'cust_id' => $this->cust_id, |
|
|
|
|
|
|
38
|
6 |
|
'cust_name' => $this->cust_id ? Cust::find($this->cust_id)->name : 'None', |
|
|
|
|
|
|
39
|
6 |
|
'link_hash' => $this->link_hash, |
|
|
|
|
|
|
40
|
6 |
|
'link_name' => $this->link_name, |
|
|
|
|
|
|
41
|
6 |
|
'exp_format' => Carbon::parse($this->expire)->format('M d, Y'), |
|
|
|
|
|
|
42
|
6 |
|
'expired' => $this->expire < Carbon::now() ? 1 : 0, |
|
43
|
6 |
|
'exp_stamp' => Carbon::parse($this->expire)->format('Y-m-d'), |
|
44
|
6 |
|
'allow_upload' => $this->allow_upload, |
|
|
|
|
|
|
45
|
6 |
|
'file_count' => isset($this->file_link_files_count) ? $this->file_link_files_count : 0, |
|
|
|
|
|
|
46
|
6 |
|
'note' => $this->note |
|
|
|
|
|
|
47
|
|
|
]; |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|