| Total Complexity | 5 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class BaseImport implements ToModel, WithHeadingRow, ImportContract |
||
| 10 | { |
||
| 11 | use Importable; |
||
|
|
|||
| 12 | |||
| 13 | /** |
||
| 14 | * @var \Distilleries\Expendable\Models\BaseModel |
||
| 15 | */ |
||
| 16 | private $model; |
||
| 17 | |||
| 18 | 4 | public function __construct($model) |
|
| 19 | { |
||
| 20 | 4 | $this->setModel($model); |
|
| 21 | } |
||
| 22 | |||
| 23 | 4 | public function importFromFile($filepath) |
|
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @inheritdoc |
||
| 30 | */ |
||
| 31 | 4 | public function model(array $row) |
|
| 32 | { |
||
| 33 | 4 | $data = []; |
|
| 34 | 4 | foreach ($this->model->getFillable() as $value) |
|
| 35 | { |
||
| 36 | 4 | $data[$value] = $row[$value]; |
|
| 37 | } |
||
| 38 | 4 | return new $this->model($data); |
|
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @param mixed $model |
||
| 43 | * @return $this |
||
| 44 | */ |
||
| 45 | 4 | public function setModel($model) |
|
| 50 | } |
||
| 51 | } |