I am trying to access variable outside laravel collection->each, but I get ..
Undefined variable: headers
Here's my code:
public function bulkCoding(Request $request) {
    Excel::load($request->file, function($reader) {
        $headers  = $reader->get()->first()->keys();
        // Loop through all sheets
        $reader->each(function($sheet) {
            $headers->each(function ($title) {
                dd($title);
            });
        });
    });
}
                You need to use the use() to pass variable inside the closure scope:
each(function($sheet) use($headers) {
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With