Questions tagged [laravel-request]

Laravel Requests - handling request and Request validation

218 questions
3
votes
6 answers

How to Use custom request (make:request)? (laravel) Method App\Http\Requests\Custom::doesExistI does not exist

I created a custom request to make my own validation. As i follow these article. I created ProfileRequest php artisan make:request ProfileRequest Inside my ProfileRequest
schutte
  • 1,949
  • 7
  • 25
  • 45
3
votes
2 answers

FormRequest not populating $request->old() after validation failure

My request object isn't receiving old() data when the form fails validation. I am receiving the error messages, but none of the old input data. I've read a few solutions on similar questions that reference making changes to the redirect on the…
Dom DaFonte
  • 1,619
  • 14
  • 31
3
votes
3 answers

Laravel 5.5 read a file from the local disk

I am trying to import a csv file with Laravel 5.5 from the local file location. For some reason it can't find the file on my computer however the path is correct. $fileLocation = $request->file('file')->store('csv'); $importFile =…
3
votes
2 answers

Laravel 5.5 Testing JSON header doesn't work

I have a problem in testing Laravel 5.5. I need to send a Bearer Token in TEST HEADER, but doesn't work public function testAuthCheckinvalidToken() { $response = $this->withHeaders([ 'Accept' => 'application/json', …
3
votes
3 answers

Laravel validation require if the user is logged in

So let's say I've got a custom request called CreateReviewRequest. In this request, I've got this method: /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return [ 'name' …
Eliya Cohen
  • 10,716
  • 13
  • 59
  • 116
3
votes
2 answers

laravel 5 request::is() not working for active menu

I am new in Laravel, I'm trying to give active class to menu links if current url matches the menu link url,
  • Asad Zaheer
    • 81
    • 2
    • 9
  • 3
    votes
    2 answers

    Access a URL Parameter in a Route Prefix from Middleware

    I am struggling to access a route prefix parameter from my middleware. Given this URL: http://www.example.com/api/v1/campaign/40/status, and the following route: Route::group( [ 'prefix' => 'api/v1' ], function() { Route::group( [ …
    voidstate
    • 7,937
    • 4
    • 40
    • 52
    2
    votes
    2 answers

    How to validate a post request without a specific attribute to validate

    I have a time tracking application where every time that a new Time Entry is about to be added, I must first verify that all the previous time entries have been closed (meaning that an ending date has been set) and throw and error message using the…
    coderdonezo
    • 399
    • 1
    • 12
    2
    votes
    3 answers

    Laravel URL Filtering with GET

    I am building a simple Laravel routing to display an array when someone goes to http://127.0.0.1:8000/planets But I need to make a filter to check the array on what request has been send on the URL. For example:…
    Shawty
    • 97
    • 6
    2
    votes
    0 answers

    Laravel how to modify custom request from middleware

    I have middleware that modifies requests by adding some data retrieved from DB: public function handle($request, Closure $next, ...$guards) { $request->merge(['newData' => [...]]); return $next($request); } And everything worked just…
    Alexey
    • 81
    • 2
    2
    votes
    1 answer

    Is there a request/validation rule that would throw an error in case of unexpected input?

    Something like Request::only() that throws an error if there is any extra/unexpected field in the request? E.g.: $request->strictly(['username', 'password']); that would throw an error if POST request contains fields 'username', 'password', and…
    Your Common Sense
    • 156,878
    • 40
    • 214
    • 345
    2
    votes
    0 answers

    Laravel 7.4 - Outside of regular expressions, is there any way to validate the parameters of the URL string in a GET request?

    I have a URL of the following form: GET /cat/{cat}/meows/{overTime} I can write a controller method that looks like this in order to capture the values: public function getMeowsOverTime(Cat cat, int overTime) What I would like is to validate the…
    pickle
    • 855
    • 1
    • 7
    • 16
    2
    votes
    1 answer

    When method changed to GET route not working like POST method Laravel

    I have a search bar in view: {!! Form::open(['name' => 'myForm', 'method' => 'GET', 'action' => 'AreaController@search', 'files' => true, 'onsubmit' => "return validateForm()"])…
    Pooya Chavoshi
    • 346
    • 4
    • 12
    2
    votes
    1 answer

    Laravel Request does not return the modified request on validation fail

    I have recently updated my controllers to use Requests to validate data before saving, originally I used $request->validate() within the controller route, but I am now at a stage where I really need to seperate it out in to a request. Issue Before…
    RobFos
    • 951
    • 6
    • 24
    2
    votes
    1 answer

    Laravel 5.7 validation using required_with and required_with_all for 3 fields does not work

    My question is how does logics using required_with and required_with_all for Laravel validation works? I have read the documentation but can not get anything from it documentation link I am applying for 3 different fields Let me give you my example…
    1 2
    3
    14 15