learnlaravel5/.envDB_HOST=localhost DB_DATABASE=test DB_USERNAME=root DB_PASSWORD=Laravelartisanmodel **php artisan make:model Column**2016_04_14_095248_create_columns_ta"/> learnlaravel5/.envDB_HOST=localhost DB_DATABASE=test DB_USERNAME=root DB_PASSWORD=Laravelartisanmodel **php artisan make:model Column**2016_04_14_095248_create_columns_ta">
Home >Backend Development >PHP Tutorial >Lavarel basic practice - model, database models modem model no
data-id="1190000004940611">
1. Configure the database link in learnlaravel5/.env
<code>DB_HOST=localhost DB_DATABASE=test DB_USERNAME=root DB_PASSWORD=</code>
2. Use artisan in Laravel to create the model and database generation file
<code> **php artisan make:model Column**</code>
<code>示例自动生成2016_04_14_095248_create_columns_table。</code>
3. Modify the 2016_04_14_095248_create_columns_table file to add the required Field
<code> public function up() { Schema::create('columns', function(Blueprint $table) { $table->increments('id'); $table->string('name')->nullable(); $table->string('url')->nullable(); $table->text('intr'); $table->string('otherauthor'); $table->integer('copyinfo'); $table->timestamps(); }); }</code>
4. Generate database table
<code>php artisan migrate</code>
The above has introduced the basic practices of Lavarel - model, database, including model aspects. I hope it will be helpful to friends who are interested in PHP tutorials.