likesistemas/eloquent-external

There is no license information available for the latest version (v1.3.0) of this package.

Using eloquent without linking with laravel framework.

v1.3.0 2024-10-28 12:25 UTC

This package is auto-updated.

Last update: 2024-11-28 12:45:21 UTC


README

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();