I have one file which is constants inside this file i have one array i want to call that array key into another file,can you please help me to fix the issue..?
constants.php
<?php
namespace App\Ship\Constants;
class Constants
{
const USER_DEPT = 'MECH';
const STAFF_DEPT = 'Batch_1';
const USER_SECTION = 1;
const STAFF_SECTION =50;
const USER_TYPES = [
self::USER_DEPT => self::USER_SECTION,
self::STAFF_DEPT => self::STAFF_SECTION
];
}
Controller.php
//$field is either USER or STAFF based on request it's coming
public function check($field){
constants::USER_TYPES[$field.'_DEPT'];
}
Error undefined index USER_DEPT