I created a custom file named ZibalRequest.php
in laravel Controllers directory and here is my file :
<?php
namespace AppHttpControllers;
class ZibalRequest
{
public function sendSmsOtp($amount , $invoice_name , $user_mobile)
{
return 'boo';
}
}
and called it in my controller this way :
$ee = new ZibalRequest();
$ee->sendSmsOtp( $amount,
$invoice_name,
$user_mobile
);
I think I named files and namespaces correctly but I’m getting this error :
Class "AppHttpControllersZibalRequest" not found
What’s wrong with laravel?
2
Answers
Extend controller class in defined controller, Like below
I tried the same code and tested it, and it’s working fine on my side.
Other Controller where you call the class.
It returns ‘boo’ when I hit the index() method from the router.
Please share more code.