class Controller extends BaseController
{
public function __construct(Request $request)
{
if ( 1 == 1 ) {
return response()->json([
'error' => true,
'message' => 'foo'
], 400);
}
}
I have set up some logic in my main controller __construct method for every pages to extend and I need to return response to page
but I have test this and it is not working, anyone know where is the problem?
You don't return from constructors, you return the response from controller methods.
Create an index method or similar in you main controller and then setup routes through the controllers inheriting from main. This will give you a default shared response.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With