ardent
ardent copied to clipboard
initialization of the static variable Ardent::$rules
Hi, not a bug but a needed feature.
I would like to define some Ardent::$rules with concatenation of constants. But Php5.6 does not want concatenation in declaration of static variables.
class Abc extends Ardent
{
const NAME_LENGTH_MAX = 40 ;
public static $rules = array (
// Here, wants to replace 40 by Abc::NAME_LENGTH_MAX
'name' => ['required','between:3,40', 'regex:/^[[:word:] \-]+$/u'],
// Syntax error :
'name' => ['required','between:3,'.Abc::NAME_LENGTH_MAX, 'regex:/^[[:word:] \-]+$/u'],
);
Is there another way,place where we can initialize Ardent::$rules values ?
Cheers
This could be bad memory block in my brain as I'm not accessing the
source now, but have you tried adding a rules() method?
If that does not work, that's probably how it would be implemented hmmm, with the method returning the static var by default and replacing all variable calls. On 6 Feb 2016 09:05, "Cyrille Giquello" [email protected] wrote:
Hi, not a bug but a needed feature
I would like to define some Ardent::$rules with concatenation of constants But Php56 does not want concatenation in declaration of static variables
class Abc extends Ardent{ const NAME_LENGTH_MAX = 40 ; public static $rules = array ( // Here, wants to replace 40 by Abc::NAME_LENGTH_MAX 'name' => ['required','between:3,40', 'regex:/^[[:word:] -]+$/u'], // Syntax error : 'name' => ['required','between:3,'Abc::NAME_LENGTH_MAX, 'regex:/^[[:word:] -]+$/u'], );
Is there another way,place where we can initialize Ardent::$rules values ?
Cheers
— Reply to this email directly or view it on GitHub https://github.com/laravel-ardent/ardent/issues/292.