spacemonkey
spacemonkey

Reputation: 2550

Laravel -Exception when running migration

I am attempting to run a migration but the following error is showing up:

{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Call to a member function increments() on a non-object","file":"/Applications/MAMP/htdocs/khadamat/app/database/migrations/2014_03_17_165445_create-users-table.php","line":16}}{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Call to a member function increments() on a non-object","file":"/Applications/MAMP/htdocs/khadamat/app/database/migrations/2014_03_17_165445_create-users-table.php","line":16}}

This is the code including line 16:

class CreateUsersTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {

        $table->increments('id');
        $table->string('firstname', 40);
        $table->string('lastname', 40);
        $table->string('dob', 40);
        $table->string('email', 150)->unique();
        $table->string('password', 64);
        $table->string('address', 200);
        $table->string('city', 40);
        $table->string('country', 100);
        $table->string('register_purpose', 40);
        $table->timestamps();

    }

any clear reason as to why this is happening? Thanks in advance

Upvotes: 0

Views: 2811

Answers (1)

Shakil Ahmed
Shakil Ahmed

Reputation: 1521

Better use artisan tool to generate migration... creating-migrations.. Some code from my projects migration table...

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateVideosTable extends Migration {

/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::create('videos', function(Blueprint $table) {
        $table->increments('id');
        $table->string('title');
        $table->text('description');
        $table->string('image');
        $table->text('embed');
        $table->timestamps();
    });
}


/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::drop('videos');
}

}

Upvotes: 2

Related Questions