userBasic Usage

Create a YAML file (e.g., post.yaml) in your project:

model: Post
primaryKey:
    name: id
    type: id # id, uuid, ulid
fields:
    - { name: title, type: string, nullable: false }
    - { name: content, type: text, nullable: true }
    - { name: status, type: enum, nullable: true, options: ['active', 'inactive'] }
timestamps: true
softDeletes: false
relationships:
    - { foreignKey: user_id, type: belongsTo, model: User, ownerKey: id }

Generate files using artisan command:

php artisan sketch:generate --file=post.yaml

By default, this will generate:

  • Model file at app/Models/Post.php

  • Migration file at database/migrations/[timestamp]_create_posts_table.php

  • Action file at app/Actions/Post/PostAction.php

  • Request files at:

    • app/Http/Requests/Post/PostCreateRequest.php

    • app/Http/Requests/Post/PostUpdateRequest.php

Command Options

Option
Description

--file

Path to your YAML file (Required)

--force

Override existing files if they already exist

Example using force option:

Last updated