In Laravel 6, the attribute type conversion of Eloquent-based modifiers, replace (bool)
1. In the API response, the field: “Processing”: False, . as shown in Figure 1
2. The type of field processing is tinyint(1). Its value is 0, 1. as shown in Figure 2
3. The original implementation is as follows
/**
* 模型的默认属性值。
*
* @var array
*/
protected $attributes = [
'processing' => 1,
// ...
];
$wpTheme['processing'] = (bool) $wpTheme['theme_installation']['processing'];
4. The $casts property in the model provides a convenient way to convert attributes to common data types. The adjusted implementation is as follows, no longer need to explicitly manually convert attribute types.
/**
* 模型的默认属性值。
*
* @var array
*/
protected $attributes = [
'processing' => true,
// ...
];
/**
* 这个属性应该被转换为原生类型.
*
* @var array
*/
protected $casts = [
'processing' => 'boolean',
// ...
];
$wpTheme['processing'] = $wpTheme['theme_installation']['processing'];
5. The value in the table is 0 , and the value of the response API is FALSE. in line with expectations. as shown in Figure 3


