JaguarJack / export
Install for your project team
Run this command in your project directory to install the skill for your entire team:
mkdir -p .claude/skills/export && curl -L -o skill.zip "https://fastmcp.me/Skills/Download/2862" && unzip -o skill.zip -d .claude/skills/export && rm skill.zip
Project Skills
This skill will be saved in .claude/skills/export/ and checked into git. All team members will have access to it automatically.
Important: Please verify the skill by reviewing its instructions before using it.
Generate Excel export class for CatchAdmin module.
0 views
0 installs
Skill Content
---
name: export
description: Generate Excel export class for CatchAdmin module.
---
# Step 7: Generate Export Class
创建数据导出类。
## File Location
```
modules/{Module}/Export/{Model}.php
```
## Template
```php
<?php
namespace Modules\{Module}\Export;
use Catch\Support\Excel\Export;
class {Model} extends Export
{
protected array $header = [
'ID', 'Name', 'Created At'
];
public function array(): array
{
return \Modules\{Module}\Models\{Model}::query()
->select('id', 'name', 'created_at')
->get()
->toArray();
}
}
```
## Header Mapping
| Field | Header |
|-------|--------|
| id | ID |
| name | Name |
| email | Email |
| status | Status |
| created_at | Created At |
## With Relationships
```php
public function array(): array
{
return {Model}::query()
->with('category')
->get()
->map(fn ($item) => [
$item->id,
$item->name,
$item->category?->name ?? '-',
$item->created_at,
])
->toArray();
}
```
## Controller Usage
```php
public function export(): mixed
{
return {Model}::query()
->select('id', 'name', 'created_at')
->get()
->download(['ID', 'Name', 'Created At']);
}
```