| Conditions | 4 |
| Paths | 3 |
| Total Lines | 25 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | public function __invoke($contID) |
||
| 18 | { |
||
| 19 | $contact = CustomerContact::findOrFail($contID); |
||
| 20 | $customer = Customer::find($contact->cust_id); |
||
| 21 | $name = explode(' ', $contact->name); |
||
| 22 | |||
| 23 | // Build the VCard |
||
| 24 | $vcard = new VCard(); |
||
| 25 | $vcard->addName(isset($name[1]) ? $name[1] : null, $name[0]); |
||
| 26 | $vcard->addCompany($customer->name); |
||
| 27 | $vcard->addAddress(null, null, $customer->address, $customer->city, $customer->state, $customer->zip, null); |
||
| 28 | |||
| 29 | // Add phone numbers to the VCard |
||
| 30 | foreach($contact->CustomerContactPhone as $phone) |
||
| 31 | { |
||
| 32 | $number = $phone->readable; |
||
| 33 | if($phone->extension) |
||
| 34 | { |
||
| 35 | $number .= ', '.$phone->extension; |
||
| 36 | } |
||
| 37 | $vcard->addPhoneNumber($number, $phone->type_name); |
||
| 38 | } |
||
| 39 | |||
| 40 | event(new CustomerContactDownloadedEvent($customer, $contact)); |
||
| 41 | return $vcard->download(); |
||
| 42 | } |
||
| 44 |