App\Http\Controllers\ExportController::returnXLS PHP Method

returnXLS() private method

private returnXLS ( $request, $fileName ) : mixed
$request
$fileName
return mixed
    private function returnXLS($request, $fileName)
    {
        $user = Auth::user();
        $data = $this->getData($request);
        return Excel::create($fileName, function ($excel) use($user, $data) {
            $excel->setTitle($data['title'])->setCreator($user->getDisplayName())->setLastModifiedBy($user->getDisplayName())->setDescription('')->setSubject('')->setKeywords('')->setCategory('')->setManager('')->setCompany($user->account->getDisplayName());
            foreach ($data as $key => $val) {
                if ($key === 'account' || $key === 'title' || $key === 'multiUser') {
                    continue;
                }
                if ($key === 'recurringInvoices') {
                    $key = 'recurring_invoices';
                }
                $label = trans("texts.{$key}");
                $excel->sheet($label, function ($sheet) use($key, $data) {
                    if ($key === 'quotes') {
                        $key = 'invoices';
                        $data['entityType'] = ENTITY_QUOTE;
                        $data['invoices'] = $data['quotes'];
                    }
                    $sheet->loadView("export.{$key}", $data);
                });
            }
        })->download('xls');
    }