Overriding laravel 5 dependencies
I have RequestInterface.php
like this:
<?PHP
namespace App\Http\Requests;
interface RequestInterface {
}
and an abstract class Request.php
:
<?php namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
abstract class Request extends FormRequest implements RequestInterface {
//
}
and I have PagesRequest.php
one that extends from Request.php
:
<?php namespace App\Http\Requests;
use App\Helpers\Helpers;
class PageRequest extends Request implements RequestInterface {
In the controller, I have to inject the PageRquest method and override the edit()
class CrudController
and test the injection in another class like this:
PageController.php:
protected function update( $id, PageRequest $request){
parent::update( $request, $id);
}
and the file I have to check the nested class to have the RequestInterface:
protected function update($id, RequestInterface $request)
{
}
But I have this error
Application declaration \ Http \ Controllers \ PagesController :: update () must be compatible with App \ Http \ Controllers \ MasterController \ CrudController :: Update ($ ID, Application \ Http \ Requests \ RequestInterface $ request)
The parent class Request
implements RequestInterface
and PageRequest
extended with Request
, so it PageRequest
has an interface RequestInterface
, but I am getting this error.
source to share