| Total Complexity | 5 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class GetCustomerFiles |
||
| 11 | { |
||
| 12 | protected $custID; |
||
| 13 | |||
| 14 | 4 | public function __construct($custID) |
|
| 17 | 4 | } |
|
| 18 | |||
| 19 | // Get all notes that are assigned to the customer |
||
| 20 | 4 | public function execute() |
|
| 21 | { |
||
| 22 | 4 | $hasParent = Customers::findOrFail($this->custID)->parent_id; |
|
| 23 | 4 | $files = $this->getLocalFiles(); |
|
| 24 | |||
| 25 | 4 | if($hasParent) |
|
| 26 | { |
||
| 27 | 2 | $parentFiles = $this->getParentFiles($hasParent); |
|
| 28 | 2 | return $files->merge($parentFiles); |
|
| 29 | } |
||
| 30 | 2 | return $files; |
|
| 31 | } |
||
| 32 | |||
| 33 | // Retrieve any notes attached to the customer |
||
| 34 | 4 | protected function getLocalFiles() |
|
| 35 | { |
||
| 36 | 4 | $files = CustomerFiles::where('cust_id', $this->custID) |
|
| 37 | 4 | ->with('Files') |
|
| 38 | 4 | ->with('CustomerFileTypes') |
|
| 39 | 4 | ->with('User') |
|
| 40 | 4 | ->get(); |
|
| 41 | |||
| 42 | 4 | Log::debug('Customer Notes Query completed for customer ID '.$this->custID.'. Results - ', array($files)); |
|
| 43 | 4 | return $files; |
|
| 44 | } |
||
| 45 | |||
| 46 | // Retrieve any notes attached to the parent customer |
||
| 47 | 2 | protected function getParentFiles($parentID) |
|
| 58 | } |
||
| 59 | } |
||
| 60 |