后盾网lavarel视频项目---1、数据迁移
生活随笔
收集整理的這篇文章主要介紹了
后盾网lavarel视频项目---1、数据迁移
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
后盾網lavarel視頻項目---1、數據遷移
一、總結
一句話總結:
1、lavarel的數據遷移比較簡單,就是用php來創建數據表
2、創建遷移文件:php artisan make:migration create_hd_table --create=hd
3、將遷移文件創建為表:php artisan migrate
?
1、安裝barryvdh/laravel-ide-helper增加代碼提示:https://packagist.org中搜barryvdh?
1、composer require --dev barryvdh/laravel-ide-helper
2、Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
3、php artisan ide-helper:generate
1、Require this package with composer using the following command: composer require --dev barryvdh/laravel-ide-helper 2、After updating composer, add the service provider to the providers array in config/app.php Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class, 3、You can now re-generate the docs yourself (for future updates) php artisan ide-helper:generate?
?
2、上傳代碼到github的時候,vendor目錄下的沒有必要提交,下載項目的時候怎么恢復?
直接composer install 即可,用的就是composer.json的配置
?
3、laravel中的數據庫遷移的原理是什么?
使用php來操作數據庫
?
4、lavarel中如何做數據庫遷移操作?
1、創建migrant文件:php artisan make:migration create_hd_table --create=hd
2、執行database\migrations中的文件:php artisan migrate
執行完第二步就會創建出來表了
?
5、mysql5.7版本和之前版本的字符集常見區別是什么?
mysql5.7用了utf8mb4字符集,而不是utf8
?
6、phper只會一個框架夠用么?
只會一個框架其實不是很好找工作,一般要會多個,都很類似,觸類旁通,很簡單的
?
7、web.php路由中引入admin文件夾路由web.php?
include:include __DIR__.'/admin/web.php';
routes/web.php routes/admin/web.php?
?
8、lavarel中database文件夾中的factories是做什么的?
配合tinker可以生產大量數據庫數據
核心步驟:
D:\software\coding\php\phpstudy\PHPTutorial\WWW\legend3\legend3>php artisan tinker Psy Shell v0.9.9 (PHP 7.2.1 — cli) by Justin Hileman >>> factory(App\Model\Admin::class,3)->create();核心代碼
$factory->define(\App\Model\Admin::class, function (Faker $faker) {static $password;return ['username' => $faker->name,'password' => $password ?: $password=bcrypt('admin888'), // secret ]; });?
?
9、lavarel數據庫遷移的各個字段如何寫?
自己按照需求改就可以了:比如$table->string('username')->unique();
public function up() {Schema::create('admins', function (Blueprint $table) {$table->increments('id');$table->timestamps();$table->string('username')->unique();$table->string('password');}); }?
?
10、創建模型的時候順便創建表?
php artisan make:model Model/Admin -m:-m是migration(也就是數據遷移的遷移)的意思
?
?
?
二、內容在總結中
【編程開發】最新laravel5+vue.js實戰演練視頻播放移動客戶端+桌面端多平臺 項目實戰_嗶哩嗶哩 (゜-゜)つロ 干杯~-bilibili
https://www.bilibili.com/video/av41501829/?p=8
1、lavarel中database文件夾中的factories是做什么的?
配合tinker可以生產大量數據庫數據
?
?
?
?
?
?
$factory->define(\App\Model\Admin::class, function (Faker $faker) {static $password;return ['username' => $faker->name,'password' => $password ?: $password=bcrypt('admin888'), // secret ]; });?
命令行中運行php artisan tinker開啟tinker
factory(App\Model\Admin::class,3)->create();表示這tinker中執行database中的factories中的App\Model\Admin::class這個工廠 D:\software\coding\php\phpstudy\PHPTutorial\WWW\legend3\legend3>php artisan tinker Psy Shell v0.9.9 (PHP 7.2.1 — cli) by Justin Hileman >>> factory(App\Model\Admin::class,3)->create(); => Illuminate\Database\Eloquent\Collection {#3006all: [App\Model\Admin {#3002username: "Jody Goldner",password: "$2y$10$ir53CAjYlmbSSvi64TJP8u9yRp.rhDJHkVwwDSXUECUYYZjosmVsW",updated_at: "2019-09-10 09:53:05",created_at: "2019-09-10 09:53:05",id: 1,},App\Model\Admin {#2997username: "Quincy Dietrich",password: "$2y$10$ir53CAjYlmbSSvi64TJP8u9yRp.rhDJHkVwwDSXUECUYYZjosmVsW",updated_at: "2019-09-10 09:53:15",created_at: "2019-09-10 09:53:15",id: 2,},App\Model\Admin {#2999username: "Janae Harber",password: "$2y$10$ir53CAjYlmbSSvi64TJP8u9yRp.rhDJHkVwwDSXUECUYYZjosmVsW",updated_at: "2019-09-10 09:53:15",created_at: "2019-09-10 09:53:15",id: 3,},],}?
?
?
?數據庫中生成了這三條記錄
?
?
?
?
?
?
?
?
?
?
?
?
轉載于:https://www.cnblogs.com/Renyi-Fan/p/11495943.html
總結
以上是生活随笔為你收集整理的后盾网lavarel视频项目---1、数据迁移的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 后盾网lavarel视频项目---php
- 下一篇: SweetAlert2模态窗的使用