laravel eloquent integers returned as strings in mssql

前端 未结 1 1707
萌比男神i
萌比男神i 2021-02-20 02:39

i am running mssql2008 with laravel 5.0 and every time i retrieve data from DB seems like everything is been returned as string no matter which format i have it stored on the da

相关标签:
1条回答
  • 2021-02-20 03:15

    I use MySQL and also found same problem in some cases. Don't use mutator, use attribute casting instead.

    protected $casts = [
        'id' => 'integer',
        'owner_id' => 'integer',
        'is_local' => 'integer',
        'vessel_type_id' => 'integer',
        'registration_number' => 'integer',
        'gross_register_tonnage' => 'integer',
        'year_built' => 'integer',
    ];
    
    0 讨论(0)
提交回复
热议问题