1,创建用户表
php artisan make:migration create_user_table –create=user
更新表的操作( 相当于在 原有的字段上 追加新的字段 ):
php artisan make:migration update_temp_phone –create=temp_phone
创建位置在database/migration/
—–> 创建用户信息表
php artisan make:migration create_user_info_table –create=user_info
php artisan make:migration create_topic_table –create=topic
php artisan make:migration create_role_table –create=roles
php artisan make:migration create_carousel_figure_table –create=carousel_figures
执行迁移–> php artisan migrate
再在数据库添加测试的数据
2,创建表的模型
php artisan make:model Models\User
php artisan make:model Models\Admin\Weibo
php artisan make:model Models\Admin\Comment
php artisan make:model Models\UserInfo
创建位置在app/Models
3,创建用户发表文章的表
php artisan make:migration create_user_article_table –create=articles
执行迁移–> php artisan migrate
php artisan make:model Models\Article
4,多对多
php artisan make:migration create_role_table –create=roles
php artisan make:migration create_role_user_table –create=role_user
执行迁移–> php artisan migrate
php artisan make:model Models\Role
5,远层一对多
php artisan make:migration create_ Country _table –create=countries
执行迁移–> php artisan migrate
php artisan make:model Models\Country
6,多态关联
php artisan make:migration create_video_table –create=videos
执行迁移–> php artisan migrate
php artisan make:model Models\Video
php artisan make:migration create_comment_table –create=comments
执行迁移–> php artisan migrate
App\Models\Video
App\Models\Article
php artisan make:model Models\Comment
二, laravel 中.env丢失后的做法
.env丢失后的做法:
1,复制 .env. example
2,将 .env.example 重命名为.env ==> 【 cp .env.example .env 】 注意路径
3, cd 到安装laravel的根目录
E:\ wamp \www\framework\ Composer >cd mylaravel
4,输入 【 php artisan key:generate 】 来生成钥匙
E:\wamp\www\framework\Composer\mylaravel> php artisan key:generate
Application key [base64:wLF6uuvRoxrhi2UPjh+mYMAaPnwg0PvoyqeNZhEzNrM=] set successfully.
这时生成了key,可以了
三,在laravel中以域名的方式访问 ( wamp web+apache+mysql+php集成环境 )
1,配置Apche中的 httpd .conf:
通过Windows+R vhosts 来查找 Include 前是否有#(默认没有) :
www.page.dev
如果有,改为下面的:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
2,找到载入的虚拟主机的配置文件
E:\wamp\ bin \apache\apache2.4.18\conf\extra 下的httpd.vhosts.conf
将
<VirtualHost *:80>
ServerName localhost
DocumentRoot E:/wamp/www
< Directory “E:/wamp/www/”>
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
复制一份
更改 :
ServerName后的 localhost为域名
DocumentRoot与Directory 后的地址为laravel的地址:
E:/wamp/www/framework/Composer/mylaravel/public
3,通过 记事本 管理员权限来 打开 C:\Windows\System32\drivers\etc\hosts
复制一行# 127.0.0.1 localhost去掉#
将localhost改为你要的域名与wamp中的一致:
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 www.my_laraval.com
再重启wamp
最后在浏览器中验证,出现laravel的界面就成功了
四,laravel安装方法
1,在PhpStorm中使用 Terminal:
composer create-project laravel/laravel mylaravel 5.5.*
mylaravel ==》 本地目录(名字随便)
5.5.* 或者 5.5 ==》 是版本号
2,在Windows中使用cmd安装中国镜像/
( 为了安装 composer ,国外的资源加载比较慢 )
composer config -g repo.packagist composer