mardi 17 décembre 2019

laravel 5.7 eloquent save digits as string

I am using laravel 5.7.

I have a field on database set as below

$table->string('last_no', 5)

and I want to save the "last_no" will save digits as string. just like

Model::create( [ "last_no" => "00351"] );

but I don't know why it will save "351" to DB not "00351".

I have already try set as below but still have this issue.

protected $casts = [
    'last_no' => "string"
];

How can I fix it?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire