vendredi 28 octobre 2016

Laravel 5 - Remove Parameter From All Request Objects at Controller Level

I have URLs that look like:

http://ift.tt/2eNrntE
http://ift.tt/2e5znYA
etc...

In my controllers, I have functions that look like:

public function user_get_endpoint(Request $request){

    $request = $request->toArray();
    return UserModel::where($request)->get()->toArray();

}

The above will currently break since the $request object contains a property called api_token which does not exist in the user table. I am using the api_token in a middleware to check for authentication.

I can manually unset the api_token property in each of my API functions by using unset($request['api_token'], but I'd like to avoid that if possible.

Is there anyway to do this application wide or at a class or controller level?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire