“I want to know if I have to use a string or an integer for a phone number”
If you want to do some calculations with the numbers
which you going to be storing (inserting), then you have to use int
(in Laravel migration: it is integer
) or any other data type such as double
etc. (as per your requirement to do such operations) as the data type of the field
.
However If you do not want to do some calculations with it, then use the data type as varchar
(in Laravel migration: it is string
) as the data type of the field.
So, when it comes to storing Phone numbers
, you can use the
varchar
data type as you do not have to do calculations with Phone
numbers.
So in this case, your validation should be this:
'phone' => 'required|string|min:8|max:11'