Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dacapo:make:models command #197

Merged
merged 1 commit into from
Mar 27, 2022
Merged

Add dacapo:make:models command #197

merged 1 commit into from
Mar 27, 2022

Conversation

ucan-lab
Copy link
Owner

@ucan-lab ucan-lab commented Mar 22, 2022

close #196

Description

$ php artisan dacapo:make:models -h
Description:
  Generate models class from schemas.

Usage:
  dacapo:make:models [options]

Options:
      --force           Create the class even if the model already exists
  -c, --controller      Create a new controller for the model
  -f, --factory         Create a new factory for the model
      --policy          Create a new policy for the model
  -s, --seed            Create a new seeder for the model
  -p, --pivot           Indicates if the generated model should be a custom intermediate table model
  -r, --resource        Indicates if the generated controller should be a resource controller
      --api             Indicates if the generated controller should be an API controller
  -R, --requests        Create new form request classes and use them in the resource controller
      --test            Generate an accompanying PHPUnit test for the Model
      --pest            Generate an accompanying Pest test for the Model
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --env[=ENV]       The environment the command should run under
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Example

database/schemas/example.yml

members:
  columns:
    id:
    name: string
    email:
      type: string
      unique:
    email_verified_at:
      type: timestamp
      nullable:
    password: string
    rememberToken:
    timestamps:

instructors:
  columns:
    id:
    name: string

lessons:
  columns:
    id:
    instructor_id: unsignedBigInteger
    studio_id: unsignedBigInteger
    name: string
    capacity: unsignedInteger
    strength: string
    started_at: dateTime
    minutes: unsignedInteger
    timestamps:
  indexes:
    - columns: started_at
      type: index
  foreign_keys:
    - columns: instructor_id
      references: id
      table: instructors
    - columns: studio_id
      references: id
      table: studios

stores:
  columns:
    id:
    name: string
    address: string
    phone_number: string
    timestamps:

studios:
  columns:
    id:
    store_id: unsignedBigInteger
    name: string
    timestamps:
  foreign_keys:
    - columns: store_id
      references: id
      table: stores

reserved_lessons:
  columns:
    id:
    member_id: unsignedBigInteger
    lesson_id: unsignedBigInteger
    timestamps:
  foreign_keys:
    - columns: member_id
      references: id
      table: members
    - columns: lesson_id
      references: id
      table: lessons

canceled_lessons:
  columns:
    id:
    member_id: unsignedBigInteger
    lesson_id: unsignedBigInteger
    timestamps:
  foreign_keys:
    - columns: member_id
      references: id
      table: members
    - columns: lesson_id
      references: id
      table: lessons

completed_lessons:
  columns:
    id:
    member_id: unsignedBigInteger
    lesson_id: unsignedBigInteger
    timestamps:
  foreign_keys:
    - columns: member_id
      references: id
      table: members
    - columns: lesson_id
      references: id
      table: lessons
$ php artisan dacapo:make:models
php artisan make:model Member
Model created successfully.
php artisan make:model Instructor
Model created successfully.
php artisan make:model Lesson
Model created successfully.
php artisan make:model Store
Model created successfully.
php artisan make:model Studio
Model created successfully.
php artisan make:model ReservedLesson
Model created successfully.
php artisan make:model CanceledLesson
Model created successfully.
php artisan make:model CompletedLesson
Model created successfully.

@ucan-lab ucan-lab changed the base branch from main to 5.2 March 27, 2022 05:55
@ucan-lab ucan-lab merged commit 5cd2ba2 into 5.2 Mar 27, 2022
@ucan-lab ucan-lab deleted the topic-196 branch March 27, 2022 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add dacapo:make:models command
1 participant