Friday, June 30, 2017

Laravel 5: How to set and get config variable in Controller | Use of Application Config in Controller

use Illuminate\Contracts\Foundation\Application;
use Illuminate\Config\Repository;

public function __construct(Application $app, Repository $config) {}

So now you can $app and $config from the above reference.

Below is a sample usage of $config:

$config->set("database.connections.mysql.database", "test");

No comments:

Post a Comment