Which data type supports Integer that start with 0
In migration which method should i set to support numbers that start with 0 ? for example 000012329
Either use a string column or use integer and add the leading zeroes after getting them from the database
use regular integer, then create an accessor in eloquent model
public function getSupportNoAttribute()
{
return sprintf("%09d", $this->supportNo);
}
replace supportNo with your column name
If the column is also a primary key, you should give this accessor a different name
@snapey When i using regular integer column i dont know why php converts my number to another number for example 00001231231 will be 340633
when you do what with it? Its not going to just change itself. Show some code?
in posts migration:
$table->integer('number');
creating post by relation ship:
$user->posts()->create(['number' =>00001231231]);
But php converts that number to 340633 in database
Please or to participate in this conversation.