I wnat to get my parameters from $request in class import. what should i do ?
this is my controller
this is my class import
Any additional information, configuration or data that might be necessary to reproduce the issue.
You can import data from controller by
(new FileImport($request->month))
and get it in Import file as function __contruct
protected $_month = null;
public function __contruct($month) {
$_month = $month;
}
You can import data from controller by
(new FileImport($request->month))
and get it in Import file as function __contruct
protected $_month = null; public function __contruct($month) { $_month = $month; }
can you explain more, please? I face the same problem
Hi
In Controller
$data = Excel::toArray(new FileImport($request->month), $file);
and in Import class
namespace App\Imports;
class OrderImport extends BaseImport
{
protected $_month = null;
public function __construct($month) {
$_month = $month;
}
public function model(array $row) {
$m = $this->_month;
}
}
Thanks @RibikiH! I hope @abdrozak20 has enough information now. Closing this ticket.
Thanks, Why isn't all this in the docs?
@notflip it鈥檚 in the docs: https://laravel-excel.maatwebsite.nl/3.1/architecture/objects.html#constructor
Thanks @patrickbrouwers!
Hi
In Controller
$data = Excel::toArray(new FileImport($request->month), $file);
and in Import classnamespace App\Imports;
class OrderImport extends BaseImport
{
protected $_month = null;public function __construct($month) { $_month = $month; } public function model(array $row) { $m = $this->_month; }}
there is a error, to fix use:
public function __construct($month) {
$this->_month = $month;
}
nice!
Most helpful comment
Hi
In Controller
$data = Excel::toArray(new FileImport($request->month), $file);and in Import class
namespace App\Imports;
class OrderImport extends BaseImport
{
protected $_month = null;
}