jeudi 5 septembre 2019

How can i get value from config file and set in $attribute variable in laravel model file?

I want to assign a default value in Laravel model but the value should come from the config file.

I am writing below code but its giving me error

    protected $attributes = [
        'is_generation'    => true,
        'price'       => config('test.MY_PRICE'),
    ];

it's showing me an error like Constant expression contains invalid operations

How can I get value from config file and set in $attribute variable in Laravel model file?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire