标签:修改 control code 参考 cti migration host name schema
1 cat .env 2 3 DB_CONNECTION=mysql 4 DB_HOST=127.0.0.1 5 DB_PORT=3306 6 DB_DATABASE=demo 7 DB_USERNAME=root 8 DB_PASSWORD=
1 2.1 生成model文件 2 php artisan make:model User --migration 3 4 2.2 修改migration文件 5 cat 6 database/migrations/2018_12_08_105758_create_user_table.php 7 8 Schema::create(‘users‘, function (Blueprint $table) { 9 $table->increments(‘id‘); 10 $table->string("username",50); 11 $table->string("age",3); 12 $table->string("email",50); 13 $table->timestamps(); 14 }); 15 16 2.3 refresh 表结构 17 php artisan migrate:refresh
1 cat app/User.php 2 3 <?php 4 5 namespace App; 6 7 use Illuminate\Database\Eloquent\Model; 8 9 class User extends Model 10 { 11 //要显示哪些列 12 protected $fillable = [ 13 ‘username‘,‘age‘,‘email‘ 14 ]; 15 16 17 }
1 cat WelcomeController.php 2 3 use App\User; //引入User 4 5 6 public function hello() 7 { 8 9 $user = User::find(1); // id=1 10 11 return $user ; 12 13 } 14 15
cat router/web.php
Route::get("/hello","welcomeController@hello");
参考文档: https://docs.golaravel.com/docs/5.0/eloquent/
标签:修改 control code 参考 cti migration host name schema
原文地址:https://www.cnblogs.com/nika86/p/10090797.html