Questions tagged [laravel-request]

Laravel Requests - handling request and Request validation

218 questions
93
votes
10 answers

Laravel Request getting current path with query string

Is there a Laravel way to get the current path of a Request with its query parameters? For instance, for the URL: http://www.example.com/one/two?key=value Request::getPathInfo() would return /one/two. Request::url() would return…
John Bupit
  • 10,406
  • 8
  • 39
  • 75
42
votes
10 answers

Laravel 5 how to validate route parameters?

I want to validate the route parameters in the "form request" but don't know how to do it. Below is the code sample, I am trying with: Route // controller Server Route::group(['prefix' => 'server'], function(){ …
21
votes
2 answers

How to modify Request values in laravel?

I have the following code, my question is how to modify Request values? public function store(CategoryRequest $request) { try { $request['slug'] = str_slug($request['name'], '_'); if ($request->file('image')->isValid()) { …
Jagadesha NH
  • 2,529
  • 2
  • 23
  • 41
19
votes
2 answers

In Laravel, how can I get *only* POST parameters?

I know that one can use $request->get('my_param') or Input::get('my_param') to get a POST or GET request parameter in Laravel (I'm toying with v5/dev version now, but it's the same for 4.2). But how can I make sure that my my_param came via a POST…
NeuronQ
  • 7,527
  • 9
  • 42
  • 60
18
votes
2 answers

How to set custom response for selected Request class in Laravel 5.5

I'm trying to use Laravel validation to generate custom error message, however I'm unable to find the function I should be overriding. Route: POST:/entries/ uses EntryController@store which uses EntryStoreRequest to perform…
eithed
  • 3,933
  • 6
  • 40
  • 60
17
votes
3 answers

How i can return a customized response in a FormRequest class in Laravel 5.5?

I am making an API and i want return the array of errors with a format as the one that $validator->errors(); generates when i validate the request by the manual way. But i cant manipulate the response. I wanna find thhe correct way to make it. This…
17
votes
6 answers

Validating a Unique Slug on Update in Laravel 5

I currently have a model that has a text field and a slug field. I validate that the slug is unique in my form request class: public function rules() { return [ 'name' => 'required|min:3', 'slug' =>…
Rapture
  • 1,876
  • 10
  • 23
  • 42
16
votes
2 answers

Laravel Request::is() - is there a better way?

@if(Request::is('login') OR Request::is('tags') OR Request::is('categories') OR Request::is('posts') OR Request::is('tags/..') OR Request::is('categories/..') OR Request::is('posts/..') OR Request::is("posts/{$post->id}")) …
vahan terzibashian
  • 258
  • 1
  • 4
  • 9
11
votes
2 answers

Can authorize method in Request class return customized message for HandlesAuthorization trait?

I have the following code in Request class to check if the user is authorized to perform update. HandlesAuthorization trait, by default gives default message. Is there any way to return customized message? I saw the authorize method in Request…
Pankaj
  • 9,749
  • 32
  • 139
  • 283
11
votes
3 answers

How to retrieve a url parameter from request in Laravel 5?

I want to perform certain operations with a model in a middleware. Here is an example of what I want to achieve: public function handle($request, Closure $next) { $itemId = $request->param('item'); // <-- invalid code, serves for illustration…
Alex Lomia
  • 6,705
  • 12
  • 53
  • 87
9
votes
1 answer

Accessing the current request in controller

In other MVC frameworks, accessing to the current request object is as simple as $this->request. However in the Laravel, I generally see that Request $request is generally injected to each action (public function edit($id, Request $request)). It…
Handsome Nerd
  • 17,114
  • 22
  • 95
  • 173
7
votes
1 answer

After validation hook in validation request

Can I attach after validation hook (documentation) to my custom made request with php artisan make:request?
Norgul
  • 4,613
  • 13
  • 61
  • 144
7
votes
2 answers

Difference between Request (Facade) and Illuminate\Http\Request

I'm starting to use Laravel and I would like to know how I should choose one over the other. As of version 5.0 Laravel documentation changed request example from Request::get('form_input') to $request->get('form_input'), but I couldn't find any…
Carlos Afonso
  • 1,927
  • 1
  • 12
  • 22
6
votes
3 answers

get the request values in Laravel

I wish to make search query by datepicker and select field. How could I get the requests values from below view file to controller? Where could I modify in the code? thanks. index.blade.php
{!!…
6
votes
2 answers

Exclude Laravel-specific values from request

I want to run json_encode($request->all()) after a form is submitted, however the returned array is "polluted" with _method and _token values. Is there any neat way to exclude the framework-specific fields from the generated json?
Alex Lomia
  • 6,705
  • 12
  • 53
  • 87
1
2 3
14 15