New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

zeuxisoo/slim-eloquent

PHP laravel eloquent on slim framework
1,274 5
Install
composer require zeuxisoo/slim-eloquent
Latest Version:0.1.0
Laravel:5
License:BSD-2-Clause
Last Updated:May 28, 2015
Links: GitHub  ·  Packagist
Maintainer: zeuxisoo

Installing

  • Install the composer
curl -sS https://getcomposer.org/installer | php
  • Edit composer.json
{
    "require": {
        "zeuxisoo/slim-eloquent": "0.1.0"
    }
}
  • Install/update your dependencies
php composer.phar install

Usage

  • Create database config
$app->config('databases', [
    'default' => [
        'driver'    => 'mysql',
        'host'      => 'localhost',
        'database'  => 'production',
        'username'  => 'root',
        'password'  => '',
        'charset'   => 'utf8',
        'collation' => 'utf8_general_ci',
        'prefix'    => ''
    ]
]);
  • Add the middleware into slim application
$app->add(new Zeuxisoo\Laravel\Database\Eloquent\ModelMiddleware);

Note

  • If you want multiple database connection, you can change the config like:
$app->config('databases', [
    'default' => [
       'driver'    => 'mysql',
       'host'      => 'localhost',
       'database'  => 'production',
       'username'  => 'root',
       'password'  => '',
       'charset'   => 'utf8',
       'collation' => 'utf8_general_ci',
       'prefix'    => ''
   ],
   'testing' => [
       'driver'    => 'mysql',
       'host'      => 'localhost',
       'database'  => 'testing',
       'username'  => 'root',
       'password'  => '',
       'charset'   => 'utf8',
       'collation' => 'utf8_general_ci',
       'prefix'    => ''
   ]
]);
  • In the application, You can set the connection like:
// Default connection
$connectionDefault     = $app->db->getConnection();
$connectionDefaultUser = $connectionDefault->table('user')->find(1);

// Testing connection
$connectionTesting     = $app->db->getConnection('testing');
$connectionTestingUser = $connectionTesting->table('user')->find(1);

// Model like
$modelDefaultUser = User::find(1);
$modelTestingUser = User::on('testing')->find(1);

Want more information? Please see the examples directory.

Related Packages

laragear/meta-model

Let other developers customize your package model and migrations

2,068,438 1
tusimo/embed-relation

a relation for laravel

10,959 3
pdphilip/opensearch

An OpenSearch implementation of Laravel's Eloquent ORM

480,696 0
designmynight/laravel-elasticsearch

Use Elasticsearch as a database in Laravel to retrieve Eloquent models and perfo...

45,696 30
friendsofcat/laravel-couchbase

A Couchbase based Eloquent model and Query builder for Laravel

31,062 14

Version History

Version Released Laravel License
0.1.0 ^5.0 BSD-2-Clause