Skip to content

Usando o Eloquent sem nenhuma dependecia com o Laravel Framework.

License

Notifications You must be signed in to change notification settings

likesistemas/eloquent-external

Repository files navigation

[Eloquent] Using Eloquent without any dependency on Laravel Framework CI

Installation

composer require likesistemas/eloquent-external

How to use

Using class ConfigBean

use Illuminate\Container\Container;
use Like\Database\Config;
use Like\Database\ConfigBean;
use Like\Database\Eloquent;

$config = new ConfigBean(
  'host',
  'user',
  'password',
  'db_name'
);
$config->setFactoryFolder(__DIR__ . "/./factories/"); # Folder where all the Eloquent factories are.
$config->addFakerProvider(ProdutoProvider::class); # Optional. Use to add new providers to Faker. Note: you can add as many as you like.

# If you are configuring the settings in the same file that will start, you can pass the config by parameter.
Eloquent::init($config);

# Or set using `illuminate\container` and run init without parameter.
Container::getInstance()->instance(Config::class, $config);
# Then call `init` wherever you think is best, without having to pass parameters.
Eloquent::init();