laravel-request

Laravel 5.7 - Override all() method in Request validation Class to validate route parameters?

◇◆丶佛笑我妖孽 提交于 2019-12-07 13:35:11
问题 I want to validate the route parameters in the Request validation class. I know this question has been asked many times before but According to this question I override all() method and I receive this error: Class App\Http\Requests\DestroyUserRequest does not exist I'm using Laravel 5.7. Route: Route::delete('/user/{userId}/delete', 'UserController@destroy')->name('user.destroy'); Controller: <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Requests

Laravel 5 Request - altering data

我是研究僧i 提交于 2019-12-05 11:25:20
I have come across an instance where I need to alter the data that needs to be validated i.e. when no slug has been submitted, create one from the title and then validate that it is unique. The request has a method replace() which is supposed to replace the input data on the request but it doesn't appear to work. Can anyone shine a light on this? This is what I have: <?php namespace Purposemedia\Pages\Http\Requests; use Dashboard\Http\Requests\Request; use Illuminate\Auth\Guard; class PageRequest extends Request { /** * [authorize description] * @return {[type]} [description] */ public

Laravel 5 how to validate route parameters?

邮差的信 提交于 2019-12-03 04:49:53
问题 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(){ Route::get('checkToken/{token}',['as'=>'checkKey','uses'=> 'ServerController@checkToken']); }); Controller namespace App\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Http\Requests; class ServerController extends Controller { public

Laravel 5 how to validate route parameters?

折月煮酒 提交于 2019-12-02 18:03:17
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(){ Route::get('checkToken/{token}',['as'=>'checkKey','uses'=> 'ServerController@checkToken']); }); Controller namespace App\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Http\Requests; class ServerController extends Controller { public function checkToken( \App\Http\Requests\CheckTokenServerRequest $request) // OT: - why I have to set full path

Laravel Request getting current path with query string

你说的曾经没有我的故事 提交于 2019-12-02 16:59:16
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 http://www.example.com/one/two . The desired output is /one/two?key=value . Hubert Dziubiński Try to use the following: \Request::getRequestUri() Request class doesn't offer a method that would return exactly what you need. But you can easily get it by concatenating results of 2 other methods: echo (Request::getPathInfo() . (Request::getQueryString() ? ('?' . Request:

Laravel 5 HTTP/Requests - pass url parameter to the rules() method

对着背影说爱祢 提交于 2019-12-02 08:28:35
问题 I'm trying to create a set of rules under the new \HTTP\Requests\UpdateArticle class for the slug field, which needs to have unique filter applied, but only when the id is not equal the url parameter of the route name article/{article} . What I got so far is: public function rules() { return [ 'title' => 'required|min:3', 'excerpt' => 'required', 'body' => 'required', 'slug' => 'required|unique:articles,slug,?', 'active' => 'required', 'published_at' => 'required|date' ]; } I need to replace

Laravel 5 HTTP/Requests - pass url parameter to the rules() method

帅比萌擦擦* 提交于 2019-12-02 04:25:31
I'm trying to create a set of rules under the new \HTTP\Requests\UpdateArticle class for the slug field, which needs to have unique filter applied, but only when the id is not equal the url parameter of the route name article/{article} . What I got so far is: public function rules() { return [ 'title' => 'required|min:3', 'excerpt' => 'required', 'body' => 'required', 'slug' => 'required|unique:articles,slug,?', 'active' => 'required', 'published_at' => 'required|date' ]; } I need to replace the question mark at the end of the unique filter for slug field with the id from the url, but don't

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

二次信任 提交于 2019-12-01 02:26:06
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 parameter and was not just from a ?my_param=42 appended to the URL? (besides reverting to the ol' $_POST and $_GET superglobals and throwing testability out the window) (Note: I also know that the Request::get method will give me the POST param for a POST request, if both a POST an URL/GET param with the same name exist, but... but if the param land