Keep only specific id Laravel - development

Keep only specific id Laravel

I have a table Foo

id

1 
2 
3 
4 
5

i have a table Bar

foo_id = 1 test = 1
foo_id = 2 test = 0
foo_id = 4 test = 1
foo_id = 5 test = 1

I want to retrieve id from foo where bar test = 0 or not exist in bar.

I have

$id = Foo::with('bar')->whereHas('bar', function ($q)
  {$q->where('test', '=', 0)
  ->orWhereNull(foo_id???????);})
->get();

How can i write this down?



from Laravel Questions and Answers https://laravelquestions.com/laravel/keep-only-specific-id-laravel/
via Lzo Media

Comments

Popular posts from this blog

ng-show doesn’t work correct with value boolean

Using PHP and MySQL data to generate PDF letters like in MS Word mailmerge functionality - development

ng-include of inline SVG does not display gradient except in Chrome