Is there a way to cast a json column key?
For example I have a payload json column and the payload has a value of {'price': 200}
How do I cast it using float? I tried using
protected $casts = ['payload.price' => 'float'];
The only way I am aware of is casting your field to a Value Object which defines the type of each property: https://github.com/jessarcher/laravel-castable-data-transfer-object
There is nothing available in native laravel casting a JSON, So you must have to create a custom attribute to cast a JSON column key you can check this out: http://laravel.com/docs/5.1/eloquent-serialization#appending-values-to-json
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community