I'm working with Laravel 9 and I have used this column at users
table for storing user mobile phone number:
$table->integer('usr_mobile_phone');
And at the factor, I tried this to fill out this column:
public function definition()
{
$fs = '091';
$ch = '1234567890';
$str = $fs.str_shuffle($ch);
return [
'usr_mobile_phone' => $str
...
];
}
But when I run php artisan db:seed
, I get this error:
So what's going wrong here?
How can I store the number properly at the user's mobile phone number column in the DB?
It's because integer
has a maximum range of 2147483647
and minimum -2147483648
if it is signed (- / +) and maximum of 4294967295
and minimum of 0
when it is not. So inserting a phone number that usually has a 11 digits exceed its maximum value and depends on how your number is formatted like @Amjad said you cannot put a string in an integer column so using a varchar
or $table->string()
in laravel is a good idea.
Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT