Package Data | |
---|---|
Maintainer Username: | eimihar |
Maintainer Contact: | newrehmi@gmail.com (Rahimie Ahmad) |
Package Create Date: | 2016-05-30 |
Package Last Update: | 2019-07-29 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:18:15 |
Package Statistics | |
---|---|
Total Downloads: | 41 |
Monthly Downloads: | 3 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
An out of Laravel Eloquent 5.1 extended use, and as a provider to different microframeworks.
Install through composer
composer require offworks/laraquent
Prepare the eloquent capsule using it's very own documentation https://github.com/illuminate/database
table() method may now be used to listen to existing database, to perform either create or alter table, it will make changes to database accordingly.
$connection = $capsule->getConnection();
$connection->useDefaultSchemaGrammar();
$schema = new \Laraquent\Schema($connection);
$schema->table('Book', function($table) {
$table->increments('id');
$table->string('title');
$table->string('isbn');
$table->timestamps();
});
Relation method now is to be prefixed with 'relate'. Example :
class Article extends \Laraquent\Base
{
public function relateAuthor()
{
return $this->hasOne('\App\Entity\Author', 'author_id');
}
}
Provide as a service to different microframeworks
Basically the provider will instatiate the eloquent capsule, and register a service with name 'eloquent'.
$app->config->set('db', array(
'host' => 'localhost',
'name' => 'my_db',
'user' => 'root',
'password' => 'password'
));
$app->provider->add(\Laraquent\Support\Exedra\Provider::class);
$app->config->set('db.schema_path', 'database/schema.php');
database/schema.php file will be loaded, with an extracted $schema variable.
$schema->table('Author', function() {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
Command use (assuming console access name is 'wizard') :
php wizard model:migrate
Special thanks to Taylor Otwell, and Laravel communities for making an awesome framework, and for making it possible to use eloquent outside of larevel.