Ad
Using The Config File In Laravel Schedule Job
Can I load the config file when the scheduling job starts?
I tried to use a local variable customerName
in Schedule Class and it already defined in the Config folder as named customerInfo
.
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use Config;
class Checkout extends Command
{
***
public function handle()
{
***
$customerName = Config::get('customerInfo.customer_name'); //test code
\Log::info($customerName); // for error check in log file
***
}
}
but it was not worked.
Do I have to declare it in the constructor
or have to use '\'
as '\Config'
even if already declared alias as use Config;
?
What is the best simple solution to use custom variable in Config when schedule job is running start?
Ad
Answer
You are getting this error because you have not defined in what namespace PHP can find the Config
class.
You need to either include the Config
facade in your usings on top of the class:
use Config;
Or use the config helper function:
config('customerInfo.customer_name');
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms
Ad