I trying to implements a interface to a controller but when i try that, the request is converted into a string. Here is the code of the controller:
class FilesController extends Controller implements Repository
{
function __construct()
{
$this->factory = new RepositoryFactoryImp();
}
public function index($request)
{
$repository = $this->factory->createRepository($request->type_repository);
return $repository->getFilesList($request);
}
}
Here is the code of the interface:
interface Repository
{
public function index(GetFileListRequest $request);
}
Then the error that i get is:
ErrorException: Trying to get property 'type_repository' of non-object in file C:\xampp\htdocs\pocs\repository\app\Http\Controllers\FilesController.php on line 31
I do a dd($request); and the result is a string, the string is the content of type_repository variable of the route:
Route::get('files/{type_repository}', 'filesController@index');
What can be the problem? Is possible to implements a interface to a controller?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire