api-controller
БесплатноБез исполняемых скриптовНе проверенCreate a new Laravel API controller following this project's patterns. Use when creating new API endpoints, CRUD controllers, or backoffice controllers.
от diegosouzapw★ 68 звёзд на GitHubОб этом скилле
Create API Controller
Create a new Laravel API controller for $ARGUMENTS following this project's established patterns.
Project Patterns
Controller Location
- Public API controllers:
app/Http/Controllers/ - Auth controllers:
app/Http/Controllers/Auth/
Standard Controller Structure
<?php
namespace App\Http\Controllers;
use App\Models\{ModelName};
use App\Http\Resources\{ModelName}Resource;
use App\Http\Resources\{ModelName}Collection;
use App\Http\Requests\{ModelName}StoreRequest;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
class {ModelName}Controller extends Controller
{
// GET /api/{resource} - List all
public function index()
{
return new {ModelName}Collection({ModelName}::all());
}
// GET /api/{resource}/{id} - Show one
public function show($id)
{
return new {ModelName}Resource({ModelName}::findOrFail($id));
}
// POST /api/{resource} - Create
public function store({ModelName}StoreRequest $request)
{
$model = {ModelName}::create($request->validated());
// Invalidate cache if using caching
Cache::forget('{resource}-all');
return new {ModelName}Resource($model);
}
// PUT /api/{resource}/{id} - Update
public function update(Request $request, $id)
{
$model = {ModelName}::findOrFail($id);
$model->update($request->all());
Cache::forget('{resource}-all');
return new {ModelName}Resource($model);
}
// DELETE /api/{resource}/{id} - Delete
public function destroy($id)
{
{ModelName}::destroy($id);
Cache::forget('{resource}-all');
return response()->json(['success' => true]);
}
}
Caching Pattern (used in InventoryController, CategoryController)
public function all()
{
return Cache::remember('inventory-all', 60, function() {
return new InventoryCollection(Inventory::all());
});
}
Filtering Pattern (used in InvoiceController, SalesController)
use App\Models\Traits\Revenue; // or SalesRevenue, InventoryFilters
public function index(Request $request)
{
return Invoice::filter($request)->paginate(15);
}
Pusher Broadcasting (for real-time updates)
use Services\Pusher;
// After mutations that need real-time sync:
try {
Pusher::trigger('tables-update', []);
} catch (\Exception $e) {
\Log::error($e->getMessage());
}
Backoffice Controller Pattern
Backoffice routes are prefixed with /api/backoffice/ and may have different methods:
allBackoffice()- Admin-specific listing with more detailsexport()- Excel/CSV export functionality
Steps
- Create the controller in
app/Http/Controllers/ - Create corresponding Resource class in
app/Http/Resources/ - Create Collection class if needed
- Create FormRequest for validation in
app/Http/Requests/ - Add routes to
routes/api.php - Consider if caching is needed for read operations
- Add Pusher triggers if real-time updates are needed
Route Registration Pattern
// In routes/api.php
// Public routes
Route::get('{resources}', [{ModelName}Controller::class, 'index']);
Route::get('{resource}/{id}', [{ModelName}Controller::class, 'show']);
Route::post('{resources}', [{ModelName}Controller::class, 'store']);
// Backoffice routes (in the backoffice prefix group)
Route::prefix('/backoffice')->group(function () {
Route::put('/{resources}/{id}', [{ModelName}Controller::class, 'update']);
Route::delete('/{resources}/{id}', [{ModelName}Controller::class, 'destroy']);
});
Установить api-controller в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл api-controller?
Create a new Laravel API controller following this project's patterns. Use when creating new API endpoints, CRUD controllers, or backoffice controllers.
Как установить скилл api-controller?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл api-controller запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic