1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Customers; |
4
|
|
|
|
5
|
|
|
use App\Http\Controllers\Controller; |
6
|
|
|
|
7
|
|
|
use App\Domains\Customers\GetCustomerFiles; |
8
|
|
|
use App\Domains\Customers\SetCustomerFiles; |
9
|
|
|
use App\Domains\FileTypes\GetCustomerFileTypes; |
10
|
|
|
|
11
|
|
|
use App\Http\Requests\CustomerFileNewRequest; |
12
|
|
|
use App\Http\Requests\CustomerFileUpdateRequest; |
13
|
|
|
|
14
|
|
|
class CustomerFilesController extends Controller |
15
|
|
|
{ |
16
|
22 |
|
public function __construct() |
17
|
|
|
{ |
18
|
22 |
|
$this->middleware('auth'); |
19
|
22 |
|
} |
20
|
|
|
|
21
|
|
|
// Index funtion will return an array of file types that can be assigned to a file |
22
|
|
|
public function index() |
23
|
|
|
{ |
24
|
|
|
return (new GetCustomerFileTypes)->execute(true); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
// Store a new customer file |
28
|
4 |
|
public function store(CustomerFileNewRequest $request) |
29
|
|
|
{ |
30
|
|
|
// Determine if a file is being uploaded still or not |
31
|
4 |
|
if((new SetCustomerFiles($request->cust_id))->createFile($request)) |
32
|
|
|
{ |
33
|
4 |
|
return response()->json(['success' => true]); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
return response()->json(['success' =>false]); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
// Get the files for the customer |
40
|
4 |
|
public function show($id) |
41
|
|
|
{ |
42
|
4 |
|
return (new GetCustomerFiles($id))->execute(); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
// Update the information of the file, but not the file itself |
46
|
4 |
|
public function update(CustomerFileUpdateRequest $request, $id) |
47
|
|
|
{ |
48
|
4 |
|
(new SetCustomerFiles($request->cust_id))->updateFile($request, $id); |
49
|
4 |
|
return response()->json(['success' => true]); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
// Remove a customer file |
53
|
2 |
|
public function destroy($id) |
54
|
|
|
{ |
55
|
2 |
|
(new SetCustomerFiles($id))->deleteCustFile($id); |
56
|
2 |
|
return response()->json(['success' => true]); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|