php - Variable type changes after retrieving from Eloquent model in Laravel 5.2 -


i have table named marital_status in database. contains 2 columns user_id (of type integer) , column named is_married (of type boolean).

therefore, when retrieve marital status of user via eloquent model, except boolean.

   auth::user()->maritalstatus // equals string not boolean. 

results correct, instead of boolean getting string '0' or '1'. can explain?

you can address in model:

protected $casts = [     'is_married' => 'boolean' ]; 

https://laravel.com/docs/5.2/eloquent-mutators#attribute-casting


Comments