Create or merge fields when exporting a model
0
Hi,
If you want to merge fields on export you can do the following:
-
Change your models/ModelExport.php
class YourmodelExport extends ExportModel { public $table = 'your_table'; protected $appends = [ 'full_name' ]; public function exportData($columns, $sessionKey = null) { $result = self::make() ->get() ->toArray(); return $result; } public function getFullNameAttribute() { return $this->firstname . ' ' . $this->lastname; }
}
2. Add the fields to your models/yourmodelexport/columns.yaml
columns: ... full_name: Full name
There are no comments yet
Be the first one to comment