repository icon indicating copy to clipboard operation
repository copied to clipboard

how to use without injection

Open carlituxman opened this issue 9 years ago • 3 comments

Hi, can I use doing this

$x = new App\Repositories\MyRepository

without injection at construct??

carlituxman avatar Nov 19 '15 17:11 carlituxman

Yes, initialize your concrete implementation

class X {
   private $x = new App\Repositories\UserRepository;

  ...
}

petehouston avatar Nov 25 '15 16:11 petehouston

not work for me. Here error: syntax error, unexpected 'new' (T_NEW)

if I use inside a function : Argument 1 passed to Bosnadev\Repositories\Eloquent\Repository::__construct() must be an instance of Illuminate\Container\Container, none given, called in ...

carlituxman avatar Dec 01 '15 12:12 carlituxman

$repo = new \App\Repositories\AppRepository(app(), \Illuminate\Support\Collection::make());

marwanzak avatar Sep 06 '16 06:09 marwanzak