PHP code example of ablunier / laravel-database

1. Go to this page and download the library: Download ablunier/laravel-database library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ablunier / laravel-database example snippets


// config/app.php

'providers' => [
    '...',
    Ablunier\Laravel\Database\Manager\ModelManagerServiceProvider::class,
];

'aliases' => [
    '...',
    'ModelManager' => Ablunier\Laravel\Database\Manager\Facades\ModelManager::class,
];


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
        ]);
    }
}


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
        ]);
    }
}

php artisan vendor:publish