hi i am tring to make laravel Repository and getting this error please help me with this here is the directry structure app\Acme\Repository\BoardsInterface.php app\Acme\Repository\Eloquent\Boards.php
BoardsInterface.php
<?php
namespace App\Acme\Repository;
interface BoardsInterface{
public function all();
public function get($id);
}
?>
Boards.php
<?php
namespace App\Acme\Repository\Eloquent;
use App\Acme\Repository\BoardsInterface;
class Boards implements BoardsInterface{
protected $boards;
function __construct(\Boards $boards) {
$this->boards = $boards;
}
public function all()
{
return $this->boards->all();
}
public function get($id)
{
return $this->boards->where('id',$id)->get();
}
}
?>
StorageServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Acme\Repository\BoardsInterface;
use App\Acme\Repository\Eloquent\Boards;
class StorageServiceProvider extends ServiceProvider {
public function boot() {}
public function register()
{
$models = array(
'Boards'
);
foreach ($models as $model) {
$this->app->bind("App\Acme\Repository\\{$model}Interface", "App\Acme\Repositories\Eloquent\\{$model}");
}
}
}
BoardsController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\User_profiles;
use App\Http\Requests;
use App\Website_links;
use App\Website;
use Illuminate\Routing\Redirector;
use App\Http\Controllers\Controller;
use App\Acme\Repository\BoardsInterface;
class BoardsController extends Controller
{
protected $boardsrepo;
public function __construct(BoardsInterface $boardsrepo)
{
$this->middleware('auth');
$this->boardsrepo=$boardsrepo;
}
function index()
{
$boards=$this->boardsrepo->all();
echo "<pre>";
print_r($boards);
return view('user.boards');
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire