Level 20
You return a json, so you can call it with Ajax, for example
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
This is Laravel API. I never used Laravel API before, I have tried using CI API.
BannerController.php
public function listBanner() {
$today = date("Y-m-d");
$banner = BannerModel::where('status', '1')
->where('expire_date', '>', $today)
->get();
return response()->json(array(
'status' => 200,
'message'=> 'Banner listed',
'data'=> $banner,
'path_banner' => asset('/banners')
), 200);
}
I wonder how do you call the API since it is in Json format. Any idea? I also wonder why the API is not in it's own server. This one is united with the front end.
Thanks in advance.
Please or to participate in this conversation.