1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Customers; |
4
|
|
|
|
5
|
|
|
use App\Domains\Customers\GetCustomerContacts; |
6
|
|
|
use App\Domains\Customers\SetCustomerContacts; |
7
|
|
|
use App\Domains\PhoneNumbers\GetPhoneNumberTypes; |
8
|
|
|
use App\Http\Controllers\Controller; |
9
|
|
|
use App\Http\Requests\Customers\CustomerContactRequest; |
10
|
|
|
use Illuminate\Http\Request; |
11
|
|
|
use Illuminate\Support\Facades\Auth; |
12
|
|
|
use Illuminate\Support\Facades\Log; |
13
|
|
|
|
14
|
|
|
class CustomerContactsController extends Controller |
15
|
|
|
{ |
16
|
|
|
// Get the types of phone numbers that can be assigned to a contact |
17
|
2 |
|
public function index() |
18
|
|
|
{ |
19
|
2 |
|
return (new GetPhoneNumberTypes)->execute(); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
// Store a new customer contact |
23
|
2 |
|
public function store(CustomerContactRequest $request) |
24
|
|
|
{ |
25
|
|
|
|
26
|
2 |
|
(new SetCustomerContacts)->createNewContact($request, $request->cust_id); |
27
|
|
|
|
28
|
2 |
|
return response()->json(['success' => true]); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
// Pull all contacts for the customer |
32
|
2 |
|
public function show($id) |
33
|
|
|
{ |
34
|
2 |
|
return (new GetCustomerContacts)->execute($id); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
// Downlod a specific contact as a V-Card |
38
|
|
|
public function download($id) |
39
|
|
|
{ |
40
|
|
|
$contact = (new GetCustomerContacts)->getOneContact($id); |
41
|
|
|
return $contact->download(); |
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
// Update an existing contact |
45
|
2 |
|
public function update(CustomerContactRequest $request, $id) |
46
|
|
|
{ |
47
|
2 |
|
(new SetCustomerContacts)->updateExistingContact($request, $id); |
48
|
2 |
|
return response()->json(['success' => true]); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
// Delete a contact |
52
|
2 |
|
public function destroy($id) |
53
|
|
|
{ |
54
|
2 |
|
(new SetCustomerContacts)->deleteContact($id); |
55
|
2 |
|
Log::notice('Customer Contact ID '.$id.' deleted by '.Auth::user()->full_name); |
56
|
2 |
|
return response()->json(['success' => true]); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.