Skip to content

get data after saving the excel file with an ID of saved #3727

Answered by yakovcohen4
yakovcohen4 asked this question in Q&A
Discussion options

You must be logged in to vote

I solved my problem. this is my answer:

I change the ToModel method to ToCollection method.

Because of the foreach in ToCollection method I can add each row to the data variable, and use the getImportedData function that returns the data

Import class:

class BankTransfersHistoryImport implements ToCollection, WithHeadingRow, WithValidation, WithEvents
{
    use Importable, RegistersEventListeners;

    private $data;

    public function __construct()
    {
        $this->data = collect();
    }

/**
 * @param array $row
 *
 * @return \Illuminate\Database\Eloquent\Model|null
 */
    public function collection(Collection $rows)
    {
        foreach ($rows as $row) {
            $bankTransf…

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@yakovcohen4
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by yakovcohen4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants