* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing */ public function get($model, string $key, $value, array $attributes): array { // phpcs:enable return \collect(\json_decode($value, true))->map(function ($input) use ($model, $key, $attributes) { $inputCast = new AsDiscount(); return $inputCast->get($model, $key, \json_encode($input), $attributes); })->all(); } /** * Prepare the given value for storage. * * @param \Illuminate\Database\Eloquent\Model $model * @param string $key * @param \App\Lib\Discount $value * @param array $attributes * @return string Json encoded array<\App\Lib\Discount> * @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing */ public function set($model, string $key, $value, array $attributes) { // phpcs:enable return \json_encode(\collect($value)->map(function ($input) use ($model, $key, $attributes) { $inputCast = new AsDiscount(); return \json_decode($inputCast->set($model, $key, $input, $attributes)); })->all()); } }