I have a Laravel API project where I want to hardcode response messages and to reuse them in any controller, How can I achieve this?
I have created response.php under APPTraits folder which has below code:
<php
return = [ 'success' => 'Response successfull!!!', 'error' => 'Error Authenticating']
?>
In my controller I tried to import via construct function, its now working:
use AppTraitsresponse;
public function __construct( response $response) {
$this->response = $respose;
}
$this->response->success; // outputs message
Please help me. I wanted to understand how do we import such files, JSONs or any other utility function to reuse?