I created two migration files: ####1st migration fiie:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function(Blueprint $table)
{
$table->increments('id');
$table->string('username')->unique();
$table->string('password');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function(Blueprint $table)
{
//
});
}
}
####2nd migration code:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUrlsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('urls', function(Blueprint $table)
{
$table->increments('id');
$table->integer('user_id');
$table->string('url');
$table->string('description');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('urls', function(Blueprint $table)
{
//
});
}
}
Then I added a seeder code:
<?php
class UserTableSeeder extends Seeder {
public function run()
{
DB::table('users')->delete();
User::create(array(
'username' => 'firstuser',
'password' => Hash::make('first_password')
));
User::create(array(
'username' => 'seconduser',
'password' => Hash::make('second_password')
));
}
}
Then I caled it in databaseseeder.php file like this:
<?php
class DatabaseSeeder extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Eloquent::unguard();
$this->call('UserTableSeeder');
}
}
Then I ran this command:
php artisan migrate
And I got this error:
PHP Fatal error: Call to a member function compileTableExists() on a non-object in /home/ajay/Desktop/laravelprojects/restapp/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php error on line 49
How can I fix it?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community