When I set 3 implementations like below, there was an error: Class AppExportsJobsExport contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MaatwebsiteExcelConcernsWithColumnFormatting::columnFormats)
.
<?php
namespace AppExports;
use AppModelsJob;
use MaatwebsiteExcelConcernsFromCollection;
use MaatwebsiteExcelConcernsWithHeadings;
use MaatwebsiteExcelConcernsWithColumnFormatting;
class JobsExport implements FromCollection, WithHeadings, WithColumnFormatting
{
/**
* @return IlluminateSupportCollection
*/
public function collection()
{
$downloadColumns = Job::select(
"id",
"created_at",
"updated_at",
"deleted_at",
)->get();
return $downloadColumns;
}
public function headings(): array
{
return config("job.csv_header");
}
}
Is there a way to set more than 3?
Related question
How to use multiple implements in laravel model
2
Answers
AS I put a comment, the cause is quite simple. I didn't add a method which is provided by WithColumnFormatting interface.
Now I found I could add more than 3 interfaces now, thank you so much for answer&comment.
Your class could be implementing any number of interfaces. There’s no limit on that.
All you need to do for the program to work properly is just to implement all the methods declared in all the interfaces your class implements.
The error you’re getting means you just have one method missing in your class.
By the way, the code you provided is not the class that causes the error.