Controller
DevelopmentcontrollerController is an Agent Skill for development published in the JaguarJack/catch-admin repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Generate CRUD controller for CatchAdmin module.
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/JaguarJack/catch-admin/blob/HEAD/.claude/skills/04-controller/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/controller, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Step 4: Generate Controller
创建 CRUD 控制器。
File Location
modules/{Module}/Http/Controllers/{Model}Controller.php
Template
<?php
namespace Modules\{Module}\Http\Controllers;
use Catch\Base\CatchController as Controller;
use Illuminate\Http\Request;
use Modules\{Module}\Http\Requests\{Model}Request;
use Modules\{Module}\Models\{Model};
use Modules\{Module}\Import\{Model} as {Model}Import;
class {Model}Controller extends Controller
{
public function __construct(
protected readonly {Model} $model
) {}
/**
* List with pagination
*/
public function index()
{
return $this->model->getList();
}
/**
* Create
*/
public function store({Model}Request $request)
{
return $this->model->storeBy($request->all());
}
/**
* Show
*/
public function show($id): mixed
{
return $this->model->firstBy($id);
}
/**
* Update
*/
public function update($id, {Model}Request $request): mixed
{
return $this->model->updateBy($id, $request->all());
}
/**
* Delete
*/
public function destroy($id)
{
return $this->model->deleteBy($id);
}
/**
* Toggle status
*/
public function enable($id)
{
return $this->model->toggleBy($id);
}
/**
* Export
*/
public function export(): mixed
{
return {Model}::query()
->select('id', 'name', 'created_at')
->get()
->download(['ID', 'Name', 'Created At']);
}
/**
* Import
*/
public function import(Request $request, {Model}Import $import)
{
return $import->import($request->file('file'));
}
}
CatchController Methods
| Method | Purpose |
|---|---|
getList() | 分页列表 (使用 $searchable) |
storeBy() | 创建记录 (使用 $form) |
firstBy() | 获取单条 |
updateBy() | 更新记录 |
deleteBy() | 软删除 |
toggleBy() | 切换状态 |