dimanche 11 février 2018

Model Constructor LARAVE 5

Good Day .. Ive tried using a constructor to my model and it flashes an error ..

Type error: Too few arguments to function App\DV::__construct(), 0 passed in E:\Apps\SRAWeb\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Concerns\HasEvents.php on line 35 and exactly 2 expected

This is My CODE .

protected $date;

public function __construct($attributes = array(), Request $request){

    parent::__construct($attributes);
    $this->date = Carbon::parse($request->toDate)->format('Y-m-d');

}

Ive tested it .. and Ive come up with is that if I try to inject Request Class to my constructor, the error flashes .. but if I remove the Request class it run smoothly .. whats the problem here ??



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire