I have a page sending the parameter to this code, after which it performs a selection from the numbers database but also displays all posts including those that are not published, and then the question was raised how exactly the second parameter would be given which would not be given published info

Here is my code at the moment, but unfortunately it just leads to an error =)

public function search(){ /* $numb = Numbers::where("nmb_title",Request::input('nmb_title').'-'.Request::input('nmb_title1').'-'.Request::input('nmb_title2'))->get();*/ $nmb = Request::input('nmb_title').'-'.Request::input('nmb_title1').'-'.Request::input('nmb_title2'); $posta = Posts::where("published",1)-> $numb = Numbers::where('nmb_title',$nmb)->get(); /*$numb = Numbers::where('nmb_title',$nmb) -> Posts::where("published",1) ->get();*/ dd($numb); return view('search', compact('numb','posta')); 
  • wtf $ posta = Posts :: where ("published", 1) -> $ numb = Numbers :: where ('nmb_title', $ nmb) -> get (); ` - apelsinka223
  • , it was just the last idea =) - Rovshan Agaev

1 answer 1

Anyway, a couple of day experiences led me to use join to check the parameters in my case.

 $nmb = Request::input('nmb_title').'-'.Request::input('nmb_title1').'-'.Request::input('nmb_title2'); $numb =Posts::join('numbers','posts.id','=','numbers.posts_id')->where('numbers.nmb_title','=',$nmb)->where('posts.published',1)->get();