php - Multiple API data sent to blade
Get the solution ↓↓↓I am trying to send 3 API data to blade.
$data['dataList'] = Http::get(Config::get('apis.section.readAll'))->json();
$company['companyList'] = Http::get(Config::get('apis.company.readAll'))->json();
$department['departmentList'] = Http::get(Config::get('apis.department.readAll'))->json();
return view('section.section', $data, $department, $company);
In this way I can't access company data, but first two variables can be accessed.
return view('section.section', compact('data', 'department', 'company'));
In this way, when I loop through each variable:
@foreach($company['companyList'] as $com)
@foreach($com as $k => $comp)
<option value="{{ $comp['company_id'] }}">{{ $comp['comp_name'] }}</option>
@endforeach
@endforeach
It shows the following error:Illegal string offset 'company_id'
.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: apache/2.4.52 (win64) openssl/1.1.1m php/8.1.2 server at localhost port 80
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.