Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Using exists validation rule for embedded models #2307

Unanswered
gmedaglia asked this question in Q&A
Discussion options

Is it possible to use the exists validation rule when using embedded models?

Let's say I have my Foo model which EmbedsMany Bar models. In my DB I have something like this:

{
 "_id": "...",
 "foo_attr": "val",
 "bars": [
 {
 "_id": "...",
 "bar_attr": "val"
 },
 // More bars...
 ]
}

Is there a way I could use Laravel's exists rule for validating a bar id? Maybe something like this?

'bar_id' => 'exists:foos.bars,_id'
You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /