Fatal error: Uncaught Error: Class "Response" not found code
<?php
class Response{
const NOT_FOUND = 404;
const FORBIDDEN = 403;
}
?>
calling it
if ($note['user_id'] != $currentUserId) {
return abort(Response::FORBIDDEN);
}
That's PHP basics.
When you want to use a class, you need to declare it.
use Response;
...
if ($note['user_id'] != $currentUserId) {
return abort(Response::FORBIDDEN);
}
To avoid any conflict, I would probably use another class name because response is already used in the framework.
Thanks it worked. I just added require 'response.php' to code
@shivamyadav Try this code
namespace your_file_path;
class Response{
const NOT_FOUND = 404;
const FORBIDDEN = 403;
}
namespace like be
namespace App\services\Response;
And where you want to use this class use namespace path like
use App\services\Response;
@amitsolanki24_ It's not a good idea to use exactly the same name Response than the one already included in Laravel. Furthermore is it a response or a service ? Are you sure it's good idea to put this code inside the Services folder ?
@amitsolanki24_ You should give realistic examples, otherwise it will be difficult to help you ;).
Please sign in or create an account to participate in this conversation.