Skip to content
Development
Skill

/laravel12

Laravel 12 framework development assistant. Use when the user needs to: (1) Create Laravel controllers, (2) Create Laravel models, (3) Create Laravel commands, (4) Create middleware, (5) Create facades, (6) Implement services, (7) Configure routes, (8) Use dependency injection,

From plugin
awesome-skills
306 skills

Claude Code

$ npx -y skills add fanqingxuan/awesome-skills --skill laravel12 --agent claude-code

SKILL.md

laravel12.SKILL.md
name: laravel12
description: "Laravel 12 framework development assistant. Use when the user needs to: (1) Create Laravel controllers, (2) Create Laravel models, (3) Create Laravel commands, (4) Create middleware, (5) Create facades, (6) Implement services, (7) Configure routes, (8) Use dependency injection, (9) Handle validation, (10) Work with Eloquent ORM, or any other Laravel 12 development tasks. Triggers on phrases like \"创建 Laravel 控制器\", \"生成模型\", \"创建命令\", \"创建中间件\", \"创建门面\", \"生成中间件\", \"生成门面\", \"Laravel 开发\", \"Laravel 12\"."

Laravel 12 开发指南

Laravel 12 框架开发助手,专注于控制器、模型、命令行工具、服务层的快速开发。

常用 Artisan 命令

# 生成控制器
php artisan make:controller UserController

# 生成资源控制器(RESTful)
php artisan make:controller UserController --resource

# 生成 API 控制器
php artisan make:controller API/UserController --api

# 生成模型
php artisan make:model User

# 生成模型 + 迁移文件
php artisan make:model User -m

# 生成模型 + 迁移 + 工厂 + 控制器
php artisan make:model User -mcf

# 生成命令
php artisan make:command ImportDataCommand

# 生成中间件
php artisan make:middleware CheckUserRole

# 生成服务提供者(用于注册门面)
php artisan make:provider PaymentServiceProvider

# 生成请求验证类
php artisan make:request StoreUserRequest

# 生成迁移文件
php artisan make:migration create_users_table

# 执行迁移
php artisan migrate

# 回滚迁移
php artisan migrate:rollback

# 生成 Seeder
php artisan make:seeder UserSeeder

# 执行 Seeder
php artisan db:seed

# 清除缓存
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear

# 启动开发服务器
php artisan serve

快速示例

控制器

<?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;

class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index(): JsonResponse
    {
        $users = User::all();

        return response()->json([
            'success' => true,
            'data' => $users
        ]);
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(Request $request): JsonResponse
    {
        $validated = $request->validate([
            'name' => 'required|string|max:255',
            'email' => 'required|email|unique:users',
        ]);

        $user = User::create($validated);

        return response()->json([
            'success' => true,
            'data' => $user
        ], 201);
    }

    /**
     * Display the specified resource.
     */
    public function show(User $user): JsonResponse
    {
        return response()->json([
            'success' => true,
            'data' => $user
        ]);
    }

    /**
     * Update the specified resource in storage.
     */
    public function update(Request $request, User $user): JsonResponse
    {
        $validated = $request->validate([
            'name' => 'sometimes|string|max:255',
            'email' => 'sometimes|email|unique:users,email,' . $user->id,
        ]);

        $user->update($validated);

        return response()->json([
            'success' => true,
            'data' => $user
        ]);
    }

    /**
     * Remove the specified resource from storage.
     */
    public function destroy(User $user): JsonResponse
    {
        $user->delete();

        return response()->json([
            'success' => true,
            'message' => 'User deleted successfully'
        ]);
    }
}

模型(Eloquent ORM)

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class User extends Model
{
    use HasFactory, SoftDeletes;

    /**
     * The table associated with the model.
     */
    protected $table = 'users';

    /**
     * The attributes that are mass assignable.
     */
    protected $fillable = [
        'name',
        'email',
        'password',
    ];

    /**
     * The attributes that should be hidden for serialization.
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * The attributes that should be cast.
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
        'password' => 'hashed',
    ];

    /**
     * Get the posts for the user.
     */
    public function posts()
    {
        return $this->hasMany(Post::class);
    }

    /**
     * Get the user's profile.
     */
    public function profile()
    {
        return $this->hasOne(Profile::class);
    }
}

命令(Artisan Command)

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\User;

class ImportDataCommand extends Command
{
    /**
     * The name and signature of the console command.
     */
    protected $signature = 'import:data {file} {--force}';

    /**
     * The console command description.
     */
    protected $description = 'Import data from file';

    /**
     * Execute the console command.
     */
    public function handle(): int
    {
        $file = $this->argument('file');
        $force = $this->option('force');

        $this->info("Processing file: {$file}");

        if ($force) {
            $this->warn('Force mode enabled');
        }

        // 处理逻辑
        $bar = $this->output->createProgressBar(100);
        $bar->start();

        for ($i = 0; $i < 100; $i++) {
            // 处理数据
            $bar->advance();
        }

        $bar->finish();
        $this->newLine();

        $this->info('Import completed successfully!');

        return Command::SUCCESS;
    }
}

中间件(Middleware)

<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class CheckUserRole
{
    /**
     * Handle an incoming request.
     */
    public function handle(Request $request, Closure $next, string $role): Response
    {
        if (!$request->user() || !$request->user()->hasRole($role)) {
            abort(403,
Read more
@fanqingxuan
Ships withawesome-skills

Agent Skills for modern software development frameworks with best practices and coding standards.

Stars on GitHub

Momentum

stars in total
30
Star history of fanqingxuan/awesome-skills on GitHub, a chart by star-history.com

Other skills on awesome-skills.

eino

eino

Eino LLM/AI application development framework assistant (Golang). Use when the user needs to: (1) Build AI agents, (2) Create LLM…

gorm

gorm

GORM (Go ORM) development assistant. Use when the user needs to: (1) Create GORM models, (2) Define database schemas, (3) Perform…

hyperf

hyperf

Hyperf 3.1 framework development assistant. Use when the user needs to: (1) Create Hyperf controllers, (2) Create Hyperf models,…

webman

webman

Webman framework development assistant. Use when the user needs to: (1) Create Webman controllers, (2) Create Webman models, (3)…

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills12d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc2w293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react3d252k
@facebook@facebookInstall Skill

Questions about laravel12.

Which coding agents can use laravel12?
laravel12 installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.