Skip to content
Discussion options

You must be logged in to vote

Hi @eminkokdemir try this

'currencies' =>[ 'nullable', 'array', new KeyExists(Currency::class)],
'currencies.*' =>[ 'nullable', 'array' ],
'currencies.*.is_primary' => 'required_with:currencies.*|boolean'

Before that make sure to write custom rule

php artisan make:rule KeyExists

<?php

namespace App\Rules;

use Illuminate\Contracts\Validation\Rule;

class KeyExists implements Rule
{

    private string $class;
    private string $message;
    private string $column;

    public function __construct($class, $column = 'id', $message = null)
    {
        $this->class = $class;
        $this->column = $column;
        $this->setMessage($message);
    }

    /**
     * Determine if the val…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by eminkokdemir0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants