So this is probably an easy one but I've been going around for hours. The error message
Illuminate \ Container \ BindingResolutionException
Target [foo\repositories\OrderRepositoryInterface] is not instantiable.
My interface:
<?php namespace foo\repositories;
interface OrderRepositoryInterface
{
public function index(array $dateRange = null, $customerId = null);
}
The repository:
<?php namespace foo\repositories;
use Carbon\Carbon;
use Order;
class OrderRepository implements OrderRepositoryInterface
{
public function index(array $dateRange = null, $customerId = null)
{
return 'HI';
}
}
my routes file:
App::bind('foo\repositories\OrderRepositoryInterface.php',
'foo\repositories\OrderRepository.php');
Route::resource('orders', 'OrdersController');
and finally the controller:
<?php
use foo\repositories\OrderRepositoryInterface;
class OrdersController extends \BaseController
{
protected $order;
/**
* @param OrderRepositoryInterface $order
*/
public function __construct(OrderRepositoryInterface $order)
{
$this->order = $order;
}
public function index()
{
$orders = $this->order->index();
return $orders;
}