Validate numbered array

Posted 10 months ago by movepixels

I have seen the other posts about array validation, but my case appears different.

return [
      '*.area_id'=> [
        'exists' => [
          'areas' => ['id']
        new UniqueToUser($queryModel = 'area_profiles'), 
        new BottomNode($queryModel = '\App\Models\Area')

as my array looks like:

[{sort: 1, area_id: 137}, {sort: 2, area_id: 86}, {sort: 3, area_id: 108}, {sort: 4, area_id: 268},…]

All the docs I have seen the array validation uses the field dot asterisk 'area_id.*' but for me its *.area_id which produces something like:

Column not found: 1054 Unknown column '0.area_id' in 'where clause' (SQL: select count(*) as aggregate from `area_profiles` where `0`.`area_id` = 268 and `profile_id` = 79195f1e-b9d9-11e7)"

Is there a simple way or am I stuck with a foreach loop?

Thanks, Dave

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.