| Conditions | 7 |
| Paths | 33 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 7 |
| Changes | 0 | ||
| 1 | <?php namespace Distilleries\Expendable\States; |
||
| 38 | 10 | public function postExport(Request $request) |
|
| 39 | { |
||
| 40 | |||
| 41 | 10 | $form = FormBuilder::create($this->export_form, [ |
|
| 42 | 10 | 'model' => $this->model |
|
| 43 | ]); |
||
| 44 | |||
| 45 | |||
| 46 | 10 | if ($form->hasError()) |
|
| 47 | { |
||
| 48 | 6 | return $form->validateAndRedirectBack(); |
|
| 49 | } |
||
| 50 | |||
| 51 | |||
| 52 | 4 | $data = $request->all(); |
|
| 53 | 4 | $dateStart = !empty($data['range']) && !empty($data['range']['start']) ? $data['range']['start'] : Carbon::now()->format('Y-m-d'); |
|
| 54 | 4 | $dateEnd = !empty($data['range']) && !empty($data['range']['end']) ? $data['range']['end'] : Carbon::now()->format('Y-m-d'); |
|
| 55 | 4 | $type = !empty($data['type']) ? $data['type'] : 'csv'; |
|
| 56 | 4 | $filename = $dateStart . ' ' . $dateEnd . '.' . $type; |
|
| 57 | |||
| 58 | 4 | return (new BaseExport($this->model, $data))->export($filename); |
|
| 59 | } |
||
| 60 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: