Laravel 5 Tutorial (02) :: Make database,model and define table

In last tutorial series i have described how to install laravel 5 in windows. If you followed the tutorial and successfully installed laravel 5, you will see the laravel home screen when you browse http://localhost/todo/public. Today we will create a database with name TODO and connect database with laravel 5.

You can read previous posts


Follow the steps:

  1. Goto your phpMyAdmin and create a database name with TODO
  2. Now go to your project directory in htdocs folder and open database.php file from config folder.
  3. In database.php file please put the database name, username and password

Ok, our database connection finished!

Now we will create a model for our table. Our table name will be todo. So that we’ll create our model name like as table name. Let’s see how can we will create a model in laravel 5.

Follow the steps:

  1. Goto your htdocs folder and right click on TODO folder by pressing ctrl+shift key and open command window
  2. Now type php artisan make:model Todo  and press enter.

Our model has been created. Now we’ll define our table. A file will be automatically create in your Database/Migrations folder. Please open the 2015_07_11_060123_create_todos_table.php file and define the table properties.

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTodosTable extends Migration
    public function up(){
        Schema::create('todo', function (Blueprint $table) {


    public function down(){

Now type in command window and press enter php artisan migrate
If ask confirmation type Y and press enter.

If all working procedure has been successfully done a table(table name : todo ) will be create in your database with id,work,status field. In next tutorial i will show you how to create a form for insert data into your table

Tags : , , , , , , , , , ,

Share on :

One Response to “Laravel 5 Tutorial (02) :: Make database,model and define table”

  1. shakib says:

    Nice tutorials with minimal expression. thanks.

Leave a Reply

− six = 2