hi,
it's possible to passing a param to a ToModel?
br
Max
Any additional information, configuration or data that might be necessary to reproduce the issue.
Just pass the param to the constructor of your import class and it should work.
E.g.
class UsersImport implements ToModel, WithHeadingRow
{
private $columnName;
public function __construct($param)
{
$this->columnName = $param;
}
public function model(array $row)
{
return new User([
'name' => $row[$this->columnName]
]);
}
}
very nice :)
Most helpful comment
Just pass the param to the constructor of your import class and it should work.
E.g.