I want to use DB class for transaction with IoC Container.
use Illuminate\Database\Connection as DB;
public function __construct(DB $db)
{
$this->db = $db;
}
But when use db class,i got an error.
Unresolvable dependency resolving [Parameter #0 [ <required> $dsn ]] in class PDO
I know, must bind something but i don't know what?
You need to change
use Illuminate\Database\Connection as DB;
into
use Illuminate\Database\DatabaseManager as DB;
I thought you can use DB
facade here but in fact you can't. You need to explicitly pass here class that is behind the facade looking at http://laravel.com/docs/4.2/facades#facade-class-reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With