Package Data | |
---|---|
Maintainer Username: | ablunier |
Maintainer Contact: | adrian.blunier@gmail.com (Adrián P. Blunier) |
Package Create Date: | 2015-07-03 |
Package Last Update: | 2017-05-23 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-01-13 15:05:36 |
Package Statistics | |
---|---|
Total Downloads: | 4,422 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 4 |
Total Forks: | 1 |
Total Open Issues: | 0 |
This package provides some utilities and patterns to work with Laravel databases
Note: This package is in active development and NOT ready for production.
Require this package with composer:
composer require ablunier/laravel-database
After updating composer, add the ServiceProvider and Facade (optional) to the app.php config file:
// config/app.php
'providers' => [
'...',
Ablunier\Laravel\Database\Manager\ModelManagerServiceProvider::class,
];
'aliases' => [
'...',
'ModelManager' => Ablunier\Laravel\Database\Manager\Facades\ModelManager::class,
];
Copy the package config to your local config with the publish command:
php artisan vendor:publish
<?php
namespace App\Http\Controllers;
use ModelManager;
use View;
class ExampleController extends Controller
{
public function index()
{
$repo = ModelManager::getRepository('App\User');
$users = $repo->all();
View::make('users.index', [
'users' => $users
]);
}
}
<?php
namespace App\Http\Controllers;
use Ablunier\Laravel\Database\Contracts\Manager\ModelManager;
use View;
class ExampleController extends Controller
{
protected $mm;
public function __construct(ModelManager $mm)
{
$this->mm = $mm;
}
public function index()
{
$repo = $this->mm->getRepository('App\User');
$users = $repo->all();
View::make('users.index', [
'users' => $users
]);
}
}
Visit the wiki for more information.
This software is published under the MIT License