Alright, so here\'s my migrations...
public function up()
{
Schema::create(\'instagrams\', function (Blueprint $table) {
$table->bigInteger(\'
It sounds like you're using a 32-bit version of PHP, where the max integer value is 2147483647.
The issue is that when the relationship query gets the key value of the Instagram
instance to query the users, it automatically casts that id value to the type defined by the $keyType
property on the model. This property is int
by default.
So, even though your Instagram
instance id is "3620243170"
, it is cast to an int, which in 32-bit PHP will turn it into 2147483647
.
There are a couple things you can try to mitigate this issue:
Use a 64-bit version of PHP. The max int size for 64-bit PHP matches the max int available for a signed bigint field. However, if you're using an unsigned bigint, you will run into this issue again once your ids exceed 9223372036854775807 (not likely).
Change the $keyType
property on your Instagram
model to float
, or possibly string
. This only affects Eloquent's casting of the variables in PHP, it does not affect how they are stored in the database.
Add protected $keyType = 'float';
to your Instagram
model.