When I create a new plugin php artisan create:plugin Winson.Test, after that I create a model with php artisan create:model Winson.Test posts, and run php artisan plugin:refresh Winson.Test, mysql can't see the table winson_test_posts.
How can I create the table?
First, it is better to create models in the singular, in your case Post
Secondly, in order for the migrations to work, you need to add them to updates/version.yml:
1.0.1:
聽聽 - Run table migrations
聽聽 - create_posts_table.php
procedure:
php artisan october:up or update it php artisan plugin:refresh Winson.Test@yinglau creating the model doesn't automatically add its migration file to the version.yaml file (required for the migration to be run). See https://octobercms.com/docs/plugin/updates#migration-seed-files
As a side note, models should always be named with a singular name (i.e. Post) and tables and controllers with the plural form of that name.
First, it is better to create models in the singular, in your case Post
Secondly, in order for the migrations to work, you need to add them toupdates/version.yml:1.0.1: 聽聽 - Run table migrations 聽聽 - create_posts_table.phpprocedure:
- php artisan create: plugin Winson.Test
- php artisan create: model Winson.Test Post
- add your table to the migration file
- Raise the version of the plugin
php artisan october:upor update itphp artisan plugin:refresh Winson.Test
@jexme
Thanks guy, cool.
Most helpful comment
First, it is better to create models in the singular, in your case Post
Secondly, in order for the migrations to work, you need to add them to
updates/version.yml:procedure:
php artisan october:upor update itphp artisan plugin:refresh Winson.Test