У меня проблема с использованием абстрактного класса в laravel. Я просто следую этому руководству http://culttt.com/2014/03/17/eloquent-tricks-better-repositories, но когда я выполняю код, я получил сообщение об ошибке «Класс не найден».Laravel Класс не найден + Аннотация Класс
Я переплетены класс в поставщика услуг, вот мой код
RepositoriesServiceProvider.php
<?php namespace Repositories;
use Illuminate\Support\ServiceProvider;
class RepositoriesServiceProvider extends ServiceProvider {
public function register()
{
$this->app->bind(
'Repositories\User\UserRepository',
'Repositories\User\EloquentUserRepository',
'Repositories\User\AbstractEloquentRepository'
);
}
}
?>
EloquentUserRepository.php
namespace Repositories\User;
use User;
class EloquentUserRepository extends AbstractEloquentRepository implements UserRepository{
protected $model;
public function __construct(User $model){
$this->model = $model;
}
public function find($id){
return User::find($id);
}
public function create($input){
return User::create($input);
}
}
?>
AbstractEloquentRepository.php
<?php
abstract class AbstractEloquentRepository{
public function all(){
return $this->model->all();
}
}
?>
UserRepository.php
<?php
namespace Repositories\User;
interface UserRepository{
public function all();
public function find($id);
public function create($input);
}
?>
UserController.php
<?php
use Repositories\User\UserRepository as User;
class UserController extends BaseController {
/*
|--------------------------------------------------------------------------
| Default Home Controller
|--------------------------------------------------------------------------
|
| You may wish to use controllers instead of, or in addition to, Closure
| based routes. That's great! Here is an example controller method to
| get you started. To route to this controller, just add the route:
|
| Route::get('/', 'HomeContr[email protected]');
|
*/
public function __construct(User $user){
$this->user = $user;
}
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
return $this->user->all();
}
// public function showWelcome()
// {
// return View::make('hello');
// }
}
Вот ошибка, которую я получил http://screencast.com/t/GysgRTea – codepinoys