Hi I have set up a repository in laravel, when I query the projects table on its own for example return Project::all();
I am returned with all the records in the database. However I wanted to query the logged in users records and only retrieve those records so I am doing this as so return Auth::user()->projects;
however when I do this I get the following error in my laravel log:
[2014-09-01 20:26:44] production.ERROR: exception
'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class
'Acme\Repositories\Auth' not
found' in /media/sf_Sites/tempus/app/Acme/Repositories/DbProjectRepository.php:17
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleShutdown()
#1 {main} [] []
My full repository is as follows:
<?php
namespace Acme\Repositories;
use Project;
class DbProjectRepository implements ProjectRepositoryInterface {
public function getAll()
{
return Auth::user()->projects;
}
}
Project Controller
public function index()
{
$projects = $this->project->getAll();
echo View::make('projects.index', compact('projects'));
}
Project View
@if (Auth::check())
@if (count($projects) > 0)
@foreach ($projects as $project)
{{ $project->project_name }}
@endforeach
@else
<p>No records, would you like to create some...</p>
@endif
@endif
Does anyone know what I am doing wrong? Would appreciate some guidance.