| Total Complexity | 7 |
| Total Lines | 70 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class BaseExport implements FromQuery, WithHeadings, ExportContract |
||
| 11 | { |
||
| 12 | use Exportable; |
||
|
|
|||
| 13 | |||
| 14 | /** |
||
| 15 | * @var \Distilleries\Expendable\Models\BaseModel |
||
| 16 | */ |
||
| 17 | private $model; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var Carbon |
||
| 21 | */ |
||
| 22 | private $start; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var Carbon |
||
| 26 | */ |
||
| 27 | private $end; |
||
| 28 | |||
| 29 | 6 | public function __construct($model, $data) |
|
| 30 | { |
||
| 31 | 6 | $this->setModel($model); |
|
| 32 | 6 | $this->setRange($data); |
|
| 33 | } |
||
| 34 | |||
| 35 | 6 | public function export($fileName) |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @return \Illuminate\Database\Query\Builder |
||
| 42 | */ |
||
| 43 | 6 | public function query() |
|
| 44 | { |
||
| 45 | 6 | return $this->model->betweenCreate($this->start, $this->end); |
|
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param mixed $model |
||
| 50 | * @return $this |
||
| 51 | */ |
||
| 52 | 6 | public function setModel($model) |
|
| 53 | { |
||
| 54 | 6 | $this->model = $model; |
|
| 55 | |||
| 56 | 6 | return $this; |
|
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @param array $data |
||
| 61 | * @return $this |
||
| 62 | */ |
||
| 63 | 6 | public function setRange($data) |
|
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @inheritdoc |
||
| 76 | */ |
||
| 77 | 6 | public function headings(): array |
|
| 80 | } |
||
| 81 | } |