Skip to content

Instantly share code, notes, and snippets.

@andyfleming
Created July 15, 2015 23:34
Show Gist options
  • Save andyfleming/71d539cec6b2f762a9f5 to your computer and use it in GitHub Desktop.
Save andyfleming/71d539cec6b2f762a9f5 to your computer and use it in GitHub Desktop.
Facade-less Database Access in Lumen
<?php
namespace App\Http\Controllers;
use \Illuminate\Database\Connection;
class DatabaseTestController extends Controller
{
/**
* @return array
*/
public function getUsers()
{
// Resolve dependencies out of container
/** @var Connection $db */
$db = app('db');
// Do "work"
$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