Alright, so here's my migrations...
public function up()
{
Schema::create('instagrams', function (Blueprint $table) {
$table->bigInteger('id')->unsigned()->primary();
// ...
});
}
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->bigInteger('instagram_id')->unsigned()->nullable();
// ...
});
}
I have a user model, and an instagram model. Here's my instagram model:
class Instagram extends Model
{
public function user()
{
return $this->hasOne('App\User');
}
}
My problem is the instagram's relationship with the user isn't working. I can't access the user from an instagram, even when they're both in the database.
>>> $u = App\User::first()
=> App\User {#695
id: 1,
instagram_id: "3620243170",
}
>>> $i = App\Instagram::first()
=> App\Instagram {#696
id: "3620243170",
}
>>> $i->user
=> null
So, I spent a long time wracking my brain until I found these helpful tinker methods... here's what it's giving me:
>>> $i->user()->toSql()
=> "select * from `users` where `users`.`instagram_id` = ? and `users`.`instagram_id` is not null"
>>> $i->user()->getBindings()
=> [
2147483647,
]
Everything is in order except the ID is being maxed at the 32 bit limit by whatever code is hiding in laravel... the ID needs to be bigger than 32 bits because that's how instagram's IDs are stored. How can I get this relationship to work?