retrieve attribute label inside inline validation

i want to get attribute label inside inline validation so that I dont have to hard code it.

The code looks like this




    # {$attribute} returns me "percent can not be more than 100"

    public function validatePercent($attribute, $params)

    {

        $this->addError($attribute, "{$attribute} can not be more than 100");


        # I can do the below but looking for a cleaner way without hard code

        $this->addError($attribute, "Claiming Rule Percent can not be more than 100");

    }


    public function attributeLabels()

    {

        return [

            'percent' => 'Claiming Rule Percent',

        ];

    }






$this->addError($attribute, $this->getAttributeLabel($attribute) . ' can not be more than 100');



work like a charm. thanks