mardi 1 octobre 2019

Laravel Excel passing arguement

I'm trying to pass argument to filter the data I want to export to excel. Below is my code :

class UnitExport implements FromCollection
{
    public function collection($proj_id)
    {
        return Unit::where('project_id', $proj_id);
    }
}


class UnitController extends Controller
{
    public function index($proj_id)
    {

        return view('dev-admin.projects.units.index', ['proj_id' => $proj_id]);

    }

    public function unitExcelExport($proj_id)
    {

        return Excel::download(new UnitExport($proj_id), 'Unit.xlsx');

    }
}

When try this it says i receive an error says:

Declaration of App\Http\Controllers\Developer\Admin\UnitExport::collection($proj_id) must be compatible with Maatwebsite\Excel\Concerns\FromCollection::collection()



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire