merge([ 'newValues' => json_decode($this->input('jsonValue'), true), ]); } /** * Get the validation rules that apply to the request. */ public function rules(): array { $currentMeat = request('meat'); return [ 'jsonValue' => 'json', 'newValues' => 'required|array', 'newValues.*' => 'required|array', 'newValues.*.id' => 'required|exists:submeats,id', 'newValues.*.meat_id' => function (string $attribute, mixed $value, \Closure $fail) use ($currentMeat) { if ($value !== $currentMeat->getKey()) { $fail("The {$attribute} is invalid."); } }, ]; } }