i am getting data from API to show in blade
controller:
public function index()
{
$response = Http::post('http://example.com/authenticate', [
'Username' => 'ADMIN',
'Password' => 'ADMIN',
'Token' => 'FK98DL..',
]);
$token = json_decode($response, true);
$apiURL = 'http://example.com/api/SalesOrder/';
$headers = [
'Content-Type' => 'application/json',
'Authorization' => $token,
];
$response2 = Http::withHeaders($headers)->get($apiURL);
$data = $response2->json();
return view('api.auth.orders.index', compact('data'));
}
blade view:
@foreach ($data as $item)
<tr>
<td>{{$item['DocDate']}}</td>
</tr>
@endforeach
Output:
now my question is, how can i show the above data for the past 2 months of the current year (August and July of 2022)?
i tried to use Carbon in my previous question: how to display data in table for the past 3 months only in laravel?
but it ignore the year, is there any other approach for this problem?
