Level 104
THis is the way to achieve what you're looking to do:
defined('User::MYCONST')
If necessary, include the full namespace, e.g.
defined('\App\Models\User::MYCONST')
1 like
Hello Team.
if(defined(User::MYCONST)){
run my code here.....
}
The problem, i still get the error "Undefinded" Constant in the User model. But why, i check if is defined or not. Many thanks.
You can get the class of the variable using get_class($user), e.g.
defined( get_class($user).'::MYCONST')
Please or to participate in this conversation.