1 year ago

getting data using parameters from one table to another table

Posted 1 year ago by icelander

i have two tables in my database. the first one contains all the categories like brakes, engine, tyres. the second table has the categoryID which is the id of the categories table aforementioned. now, i want to get the problems of that categoryID and display it in a view. this is my controller where i get the id of the category and store it in a session

 public function next(Request $request){

        $maincategory = $request->input('category');
        Session::put('main', $maincategory);

        return redirect()->route('select');

next is the other controller to the next page where i want it to show the problems associated to that categoryID. but its not showing those problems .

public function select(){ $maincategorys = Session::get('main');

    $catid = DiscoveredProblem::all()->where('categoryID',$maincategorys);
    $verifiedproblems = DiscoveredProblem::all()->where('categoryID',$catid);

    return view('select-problems',['verifiedcar'=>$verifiedproblems]);

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