Closed dillingham closed 2 years ago
Lets make a export feature
Route::formation(PostFormation::class)->asExport()
GET /posts/export
Also support passing a columns parameter to only include specific columns:
columns
GET /posts/export?columns=id,title
Add a default a formation export method to use index() fields:
public function export(): array { return $this->index() }
So the developer can override the method like so:
public function export() { return [ Field::make('id'), Field::make('title'), Field::make('author_name', 'author.name'), ]; }
Loop over fields in the export to get relationships to eagerload like I do here
Lets mimic how Import works, making a default $export class on Formation
And use the formation information to make the export work like imports does
(it sets the formation on the route using ->defaults())
Lets write some tests to insure it works as expected.
Lets make a export feature
Also support passing a
columns
parameter to only include specific columns:Add a default a formation export method to use index() fields:
So the developer can override the method like so:
Loop over fields in the export to get relationships to eagerload like I do here
Lets mimic how Import works, making a default $export class on Formation
And use the formation information to make the export work like imports does
(it sets the formation on the route using ->defaults())
Lets write some tests to insure it works as expected.