Created
July 16, 2015 21:56
-
-
Save andyfleming/fa66c28048767d2e5973 to your computer and use it in GitHub Desktop.
Facade-less Database Access in Lumen using dependency injection
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\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