Created
July 15, 2015 23:34
-
-
Save andyfleming/71d539cec6b2f762a9f5 to your computer and use it in GitHub Desktop.
Facade-less Database Access in Lumen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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