My question is simple, is it possible to get the value of the row on validation ?
Thank you by advance.
Currently not. You could always do the validation yourself inside the collection/onEachRow/Model method if you need that kind of control.
Okay thank you, I'm going to do this in the model method, is there a way to find the row index ?
For now I added it with a global variable in my import class
private $startRow;
public function __construct()
{
$this->startRow = 2;
}
public function model(array $row)
{
$this->startRow++;
}
@HamzaDevz that's for current release the best option yes, however our next release will have a trait that does this for you automatically.
Sorry again @patrickbrouwers is it the proper way to add manually a failure ?
Here is what I did :
public function model(array $row)
{
$this->startRow++;
$purchaseRequestProduct = $this->purchaseRequest->purchaseRequestProducts()->whereSku($row['ean'])->first();
if (!isset($purchaseRequestProduct))
{
$this->failures[] = new Failure($this->startRow, 'ean', [ 'This product does not exist.' ], $row);
return;
}
}
Thank you.
I think so yes