Home > Backend Development > PHP Tutorial > Lavarel basic practice - model, database models modem model no

Lavarel basic practice - model, database models modem model no

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 08:53:30
Original
1642 people have browsed it

data-id="1190000004940611">

1. Configure the database link in learnlaravel5/.env

<code>DB_HOST=localhost
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=</code>
Copy after login

2. Use artisan in Laravel to create the model and database generation file

<code>   **php artisan make:model Column**</code>
Copy after login
<code>示例自动生成2016_04_14_095248_create_columns_table。</code>
Copy after login

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>
Copy after login

4. Generate database table

<code>php artisan migrate</code>
Copy after login

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.

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template