1

I am trying to get the constant defined inside the helper file inside private function. My helper file is inside app\Helpers\Report\ . This is the code I tried. But I am getting error as:

Use of undefined constant CONDITION_A - assumed 'CONDITION_A' 

What I have done wrong?

ReportHelper.php

namespace App\Helpers\Report;

class ReportHelper 
{
    const CONDITION_A = "A";
    const CONDITION_B = "B";

    .....
}

MyController

<?php
namespace App\Http\Controllers;

use App\Helpers\Report\ReportHelper;

class MyController extends Controller
{
    private function _test() {
        echo ReportHelper::CONDITION_A;
    }
}
nas
  • 2,289
  • 5
  • 32
  • 67
  • Possibly relevant: https://stackoverflow.com/questions/42155536/what-is-the-best-practice-for-adding-constants-in-laravel-long-list – Tim Biegeleisen Dec 25 '18 at 04:07
  • @TimBiegeleisen I could not call the const defined inside private function. Outside private function it is working fine.. I have tried calling it inside contruct – nas Dec 25 '18 at 04:09
  • check the PHP manual http://php.net/manual/en/language.oop5.constants.php – Sayed Mohd Ali Dec 25 '18 at 04:21

0 Answers0