1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Customers; |
4
|
|
|
|
5
|
|
|
use App\Http\Controllers\Controller; |
6
|
|
|
use App\Http\Requests\Customers\CustomerFileRequest; |
7
|
|
|
use App\Models\CustomerFile; |
8
|
|
|
use App\Models\CustomerFileType; |
9
|
|
|
use App\Models\FileUploads; |
10
|
|
|
use App\Traits\FileTrait; |
11
|
|
|
use Illuminate\Http\Request; |
12
|
|
|
use Illuminate\Support\Facades\Log; |
13
|
|
|
|
14
|
|
|
class CustomerFilesController extends Controller |
15
|
|
|
{ |
16
|
|
|
use FileTrait; |
17
|
|
|
|
18
|
|
|
protected $disk; |
19
|
|
|
|
20
|
|
|
public function __construct() |
21
|
|
|
{ |
22
|
|
|
$this->disk = 'customers'; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Display a listing of the resource. |
27
|
|
|
* |
28
|
|
|
* @return \Illuminate\Http\Response |
29
|
|
|
*/ |
30
|
|
|
public function index() |
31
|
|
|
{ |
32
|
|
|
// |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Show the form for creating a new resource. |
37
|
|
|
* |
38
|
|
|
* @return \Illuminate\Http\Response |
39
|
|
|
*/ |
40
|
|
|
public function create() |
41
|
|
|
{ |
42
|
|
|
// |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Upload a new file |
47
|
|
|
*/ |
48
|
|
|
public function store(CustomerFileRequest $request) |
49
|
|
|
{ |
50
|
|
|
// Process the chunk of file being uploaded |
51
|
|
|
$status = $this->getChunk($request, $this->disk, $request->cust_id); |
52
|
|
|
|
53
|
|
|
// If the file upload is completed, save to database |
54
|
|
|
if($status['done'] === 100) |
55
|
|
|
{ |
56
|
|
|
$newFile = FileUploads::create([ |
57
|
|
|
'disk' => $this->disk, |
58
|
|
|
'folder' => $request->cust_id, |
59
|
|
|
'file_name' => $status['filename'], |
60
|
|
|
'public' => false, |
61
|
|
|
]); |
62
|
|
|
|
63
|
|
|
CustomerFile::create([ |
64
|
|
|
'file_id' => $newFile->file_id, |
65
|
|
|
'file_type_id' => CustomerFileType::where('description', $request->type)->first()->file_type_id, |
66
|
|
|
'cust_id' => $request->cust_id, |
67
|
|
|
'user_id' => $request->user()->user_id, |
68
|
|
|
'shared' => filter_var($request->shared, FILTER_VALIDATE_BOOL), |
69
|
|
|
'name' => $request->name, |
70
|
|
|
]); |
71
|
|
|
|
72
|
|
|
return response()->noContent(); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
// If upload is still in progress, send current status of upload |
76
|
|
|
return response($status); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Display the specified resource. |
81
|
|
|
* |
82
|
|
|
* @param int $id |
83
|
|
|
* @return \Illuminate\Http\Response |
84
|
|
|
*/ |
85
|
|
|
public function show($id) |
|
|
|
|
86
|
|
|
{ |
87
|
|
|
// |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Show the form for editing the specified resource. |
92
|
|
|
* |
93
|
|
|
* @param int $id |
94
|
|
|
* @return \Illuminate\Http\Response |
95
|
|
|
*/ |
96
|
|
|
public function edit($id) |
|
|
|
|
97
|
|
|
{ |
98
|
|
|
// |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Update the specified resource in storage. |
103
|
|
|
* |
104
|
|
|
* @param \Illuminate\Http\Request $request |
105
|
|
|
* @param int $id |
106
|
|
|
* @return \Illuminate\Http\Response |
107
|
|
|
*/ |
108
|
|
|
public function update(Request $request, $id) |
|
|
|
|
109
|
|
|
{ |
110
|
|
|
// |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Remove the specified resource from storage. |
115
|
|
|
* |
116
|
|
|
* @param int $id |
117
|
|
|
* @return \Illuminate\Http\Response |
118
|
|
|
*/ |
119
|
|
|
public function destroy($id) |
|
|
|
|
120
|
|
|
{ |
121
|
|
|
// |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.