(1)生成Auth所需文件php
打开phpstorm的命令行:css
php artisan make:authlaravel
生成成功后,打开web.php,web
发现多了以下代码:数据库
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
而后访问 localhost/laravel/public/home就能够看到登陆页面,app
若是样式不正常,须要修改layouts/app.blade.php的css路径。phpstorm
php artisan migratespa
会生成数据表,就能够注册登陆了。命令行
(2)数据迁移orm
方法1、新建一个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,
数据库就会多出来一个数据表。
方法2、生成模型的同时生成迁移文件
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