Skip to content

Instantly share code, notes, and snippets.

@andyfleming
Created July 16, 2015 21:56
Show Gist options
  • Save andyfleming/fa66c28048767d2e5973 to your computer and use it in GitHub Desktop.
Save andyfleming/fa66c28048767d2e5973 to your computer and use it in GitHub Desktop.
Facade-less Database Access in Lumen using dependency injection
<?php
namespace App\Http\Controllers;
use Illuminate\Database\DatabaseManager as DB;
class DatabaseTestController extends Controller
{
/**
* @param DB $db
*
* @return array
*/
public function getUsers(DB $db)
{
$results = $db->select("SELECT * FROM users");
return [
"count" => count($results),
"data" => $results,
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment