| Conditions | 4 |
| Paths | 8 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace App\Modules\Reporting\Repositories; |
||
| 28 | public function renderReport($report, $conditions = [], $perPage = 0) |
||
| 29 | { |
||
| 30 | $report = ! is_int($report) ? $report : $this->find($report); |
||
| 31 | /** |
||
| 32 | * Fetch data from the report based on the given conditions. |
||
| 33 | */ |
||
| 34 | $report = \DB::table($report->view_name); |
||
| 35 | unset($conditions['page']); |
||
| 36 | if (count($conditions)) { |
||
| 37 | $conditions = $this->constructConditions($conditions, $this->model); |
||
| 38 | $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
||
| 39 | } |
||
| 40 | /** |
||
| 41 | * Paginate or all data. |
||
| 42 | */ |
||
| 43 | if ($perPage) { |
||
| 44 | return $report->paginate($perPage); |
||
| 45 | } else { |
||
| 46 | return $report->get(); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | } |
||
| 50 |
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.