dimanche 13 novembre 2016

call multiple method using call_user_func_array

i use below code for fetch all relevant model data

protected $model = '';

public function getAll()
{
    return call_user_func_array([$this->model, "get"], []);
}

its work for now, but how can i handle chain method by call_user_func_array ? for example:

i need fetch like:

 Model::where('user_id', $user_id)->get();

one solution is (new $this->model)->where(); that i think its a bad idea. is there any solution?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire