Skip to content

Instantly share code, notes, and snippets.

@mubassirhayat
Created May 15, 2018 07:59
Show Gist options
  • Save mubassirhayat/edb455d8e290856721eee2a4e319c36d to your computer and use it in GitHub Desktop.
Save mubassirhayat/edb455d8e290856721eee2a4e319c36d to your computer and use it in GitHub Desktop.
Example of Request Facade for Url Parameters

Url

example.com/route-name?var1=value1

Route

Route::get('route-name', 'Namespace\ControllerClass@functionName')->name('route-name');

Function Definitation

public function functionName(Request $request) {
    $validator = Validator::make($request->all(), [
        'email'        => 'required|string|email|max:191',
        'password'     => 'required|string|min:6',
        'var1'         => 'requred|strring'
    ]);
    if ($validator->fails()) {
        return $this->respondBadRequest('Validation failed for parameters please review.', $validator->errors()->toArray());
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment