You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/basic-usage/model-export.md
-31Lines changed: 0 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,37 +119,6 @@ class UsersExport extends ModelExport
119
119
}
120
120
```
121
121
122
-
## Formatting a specific attribute
123
-
124
-
To format a specific attribute in the exported file, override the `formatValue` method. Remember to call `parent::formatValue` to still maintain formatting for other attributes.
125
-
126
-
```php
127
-
<?php
128
-
129
-
namespace App\Exports;
130
-
131
-
use Javaabu\Exports\ModelExport;
132
-
use App\Models\User;
133
-
134
-
class UsersExport extends ModelExport
135
-
{
136
-
137
-
public function modelClass(): string
138
-
{
139
-
return User::class;
140
-
}
141
-
142
-
public function formatValue(string $attribute, mixed $value): mixed
143
-
{
144
-
if ($attribute == 'role' && $value instance of \App\Models\Role::class) {
145
-
return $value->description;
146
-
}
147
-
148
-
return parent::formatValue($attribute, $value);
149
-
}
150
-
}
151
-
```
152
-
153
122
## Modifying the headings
154
123
155
124
To modify the headings, override the `headings` method. Remember to include all the headings in the correct order and to include a heading for each allowed attribute.
0 commit comments