Skip to content
Discussion options

You must be logged in to vote

Thanks @patrickbrouwers for clearing up the contstructor mystery! This made me come up with a really simple solution now:

namespace App\Imports;

use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToCollection;

class FirstSheetImport implements ToCollection
{
    protected $once = false;
    
    public function collection(Collection $rows)
    {
        $this->runOnce();
        
        // do the import in here
    }
    
    private function runOnce()
    {
        if ($this->once) {
            return;
        }
        
        // My logoc in here has access to the session now!
        
        $this->once = true;
    }
}

Thanks again for this great package and awesom…

Replies: 4 comments 5 replies

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
5 replies
@patrickbrouwers
Comment options

@stefro
Comment options

@patrickbrouwers
Comment options

@stefro
Comment options

@patrickbrouwers
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by stefro
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