I'm trying to have constants everywhere in my code so I don't have to just stick numbers, I know that's bad practice.
So in my root folder I put a class constants, like this:
namespace App;
class Constants{
public const FREE_TIER = 0;
}
So I include the "use App\Constants;" in my repository class.
Here is the function I try to access my constants class in:
use App\Constants; /* earlier on */
/**
* @param User $user
* @return array
*/
public function countFreeTiers() : array
{
$qb = $this->createQueryBuilder('t');
$qb->select('COUNT(t.tierNumber)')
->where('t.tierNumber = :freeTier')
->groupBy('t.tierNumber')
->orderBy('t.tierNumber', 'ASC')
->setParameter('freeTier', Constants::FREE_TIER /* error here */)
->setParameter('true', true);
$query = $qb->getQuery();
return $query->getResult();
}
This is the error I get:
Attempted to load class "Constants" from namespace "App".
Did you forget a "use" statement for another namespace?
Am I not allowed to just use the "App" namespace?