(1)生成Auth所需文件
打开phpstorm的命令行:
php artisan make:auth
生成成功后,打开web.php,
发现多了如下代码:
Auth::routes();Route::get('/home', 'HomeController@index')->name('home');然后访问 localhost/laravel/public/home就可以看到登录页面,
如果样式不正常,需要修改layouts/app.blade.php的css路径。
php artisan migrate
会生成数据表,就可以注册登录了。
(2)数据迁移
方法一、新建一个teachers表迁移文件
php artisan make:migration create_teachers_table
示例:php artisan make:migration create_teachers_table --create=teachers
在database目录下的migrations目录下会多一个文件
2018_05_23_091955_create_teachers_table.php然后打开这个文件,修改up方法,编辑表结构: public function up(){ Schema::create('teachers', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->integer('age')->unsigned()->default(0); $table->integer('sex')->unsigned()->default(1); $table->integer('create_at')->unsigned()->default(0); $table->integer('update_at')->unsigned()->default(0); });}然后执行迁移文件php artisan migrate,数据库就会多出来一个数据表。
方法二、生成模型的同时生成迁移文件
php artisan make:model School -m
示例:php artisan make:model School -m
在database目录下的migrations目录下会多一个文件
2018_05_23_092252_create_schools_table.php
(3)数据填充
创建一个填充文件,并完善填充文件
php artisan make:seeder StudentTableSeeder
执行单个填充文件
php artisan db:seed --class=StudentTableSeeder
批量执行填充文件
php artisan db:seed
转载于:https://www.cnblogs.com/gyfluck/p/9077642.html
相关资源:垃圾分类数据集及代码