运用命令行
命令行创建中常见的几种:
php artisan key:generate 生成 App Key
php artisan make:controller 生成控制器
php artisan make:model 生成模型
php artisan make:policy 生成授权策略
php artisan make:seeder 生成 Seeder 文件
php artisan migrate 执行迁移
php artisan migrate:rollback 回滚迁移
php artisan migrate:refresh 重置数据库
php artisan db:seed 填充数据库
php artisan tinker 进入 tinker 环境
php artisan route:list 查看路由列表
数据库迁移:
php artisan migration create_teachers_table
php artisan migrate
添加数据
laravel框架的数据添加运用create方法:
title和content为数据表中的字段。
展示数据
laravel框架的数据添加运用get方法:
Teacher为模型层,定义一个$data来接受数据;然后向视图层发送查询的数据。