Hi Sky,
First off all: great guide on the rebuild of Twitter with Laravel
However, something seems to be going wrong..
I have followed up until the Following & Followers step, but when i try to go to a different profile (while logged in) i am getting an SQL error:
(2/2) QueryException
SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘followers.followers_user_id’ in ‘field list’ (SQL: select `users`.*, `followers`.`followers_user_id` as `pivot_followers_user_id`, `followers`.`user_id` as `pivot_user_id`, `followers`.`created_at` as `pivot_created_at`, `followers`.`updated_at` as `pivot_updated_at` from `users` inner join `followers` on `users`.`id` = `followers`.`user_id` where `followers`.`followers_user_id` = 1 and `user_id` = 2 limit 1)
in Connection.php (line 647)
and
1/2) PDOException
SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘followers.followers_user_id’ in ‘field list’
This way i cannot check if the follow/unfollow button works and i can’t seem to figure it out..
Here are my migration files for users and followers:
<?phpuse Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;class CreateFollowersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('followers', function (Blueprint $table) {
$table->integer('user_id')->unsigned()->index();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->integer('follower_user_id')->unsigned()->index();
$table->foreign('follower_user_id')->references('id')->on('users')->onDelete('cascade');
$table->timestamps();
});
} /**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('followers');
}
}
And users :
<?phpuse Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('username', 15)->unique();
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
} /**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
Any help/suggestions are very welcome! would love to continue on your guide.
With kind regards,
Martijn
