I just stumbled upon the same problem.
I would like to show you another way to do this without extends, but with traits. (I'll take sample classes from Tarek Adam).
PHP Traits - , . , Trait - , extends do. , e.x. , , .
Laravel BaseController, .
\App\Traits\SanitizedRequest.php. , . .
namespace App\Trait;
trait SanitizedRequest{
private $clean = false;
public function all(){
return $this->sanitize(parent::all());
}
protected function sanitize(Array $inputs){
if($this->clean){ return $inputs; }
foreach($inputs as $i => $item){
$inputs[$i] = trim($item);
}
$this->replace($inputs);
$this->clean = true;
return $inputs;
}
}
use SanitizedRequest.
namespace App\Http\Requests\Forms;
use App\Http\Requests\Request;
use App\Trait\SanitizedRequest;
class ContactRequest extends Request {
use SanitizedRequest;
public function authorize(){ return true; }
public function rules(){ return []; }
}