dimanche 29 septembre 2019

use dynamic value in a config file

i have config file for payments, its like this.. i should use dynamic value (that is loading from db) for merchant-id key:

in AppServiceProvider in boot method i write this

 $zarinpal = PaymentConfig::where('slug', 'zarinpal')->first();

        config()->set(['app.zarinpal' => ['merchant' => $zarinpal->merchant ?? 0]]);

but config('app.zarinpal')["merchant"] value is null there... how can i fix this issue?

return [

    //-------------------------------
    // Timezone for insert dates in database
    // If you want Gateway not set timezone, just leave it empty
    //--------------------------------
    'timezone' => 'Asia/Tehran',

    //--------------------------------
    // Zarinpal gateway
    //--------------------------------
    'zarinpal' => [
        'merchant-id'  => config('app.zarinpal')["merchant"],//'xx',
        'type'         => 'zarin-gate',             // Types: [zarin-gate || normal]
        'callback-url' => '/',
        'server'       => 'germany',                // Servers: [germany || iran || test]
        'email'        => 'email@gmail.com',
        'mobile'       => '09xxxxxxxxx',
        'description'  => 'description',
    ],


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire