'How to get two tables data in one single view in Laravel 8

I have two tables one is division and another is user_designations and I want to get these two tables' data on one single page. I'm new to Laravel so I can't find any way. I have tried the below method but it's not working

This is my controller code

public function createUser(){
        $data['divisions'] = Division::get(['division_name', 'id']);
        return view('admin.create_user', $data);
    }

    public function viewDesignation(){
        $designations = userDesignation::all();
        return view('admin.create_user', compact('designations'));
    }

This is my view page code

<select name="" id="">
    <option value="">Select Devision</option>
    @foreach ($divisions as $data)
    <option value="{{$data->id}}">{{$data->division_name}}</option>
</select>


<select name="" id="">
    <option value="">Select Designation</option>
    @foreach($designations as $data)
    <option value="{{$data->id}}">{{$data->designation_name}}</option>
</select>

When I tried this method I got an error, Please see attached the image Error



Solution 1:[1]

you have to pass all data through the same method you are calling from route

public function createUser(){
        $data['divisions'] = Division::get(['division_name', 'id']);
        $data['designations'] = userDesignation::all();
        return view('admin.create_user', $data);
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nishan Timsina