#### Category : laravel-request

I used Request to validate data public function rules () : array { return [‘order_type’ => ‘numeric|gt:0′]; } For example, my order_type=’abc’, I’ll be received 2 message in result order_type: [ ‘validate.numeric’, ‘validate.numeric.gt’ ] But I want only 1 message for both numeric validate and greater than 0 validate. And my result I want is: ..

I’m developing an application for Pharmacy Company, Products have many Batches. When New Invoice Creation. They don’t enter the same product with the same batch number in the Invoice Item List. How to validate using laravel Rule. My Blade (Dynamic Row) : <tr class="item_row" id="item-row-0"> <td> <select class="form-control boxed" name="items[0][product_id]" id="product_id0" onchange="productattribute(0)" data-width="100%" required> <option ..

On my SPA side I make http request with axios this way: createCompany(company: ICompanyCreation): Promise<ApiResponse<string|ErrorBody>>{ return instance .post<string|ErrorBody>(apiPaths.createCompany, company) .then(confirmationHandler) .catch(errorHandler); } where ICompanyCreation is: interface Contact{ firstName: string; lastName: string; email: string; phone: string; } export interface ICompanyCreation { name: string; status: Status; country: string; city: string; address: string; zipCode: number; admin: Contact; itHead: ..

Using request object validation /** * Store a new blog post. * * @param IlluminateHttpRequest $request * @return IlluminateHttpResponse */ public function input(PaymentRequest$request){ $payment=new Payment();$payment->order_id=$request->order_id; And request class PaymentRequest extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { .. Read more how to keep all data in form dynamically in Laravel 7 after submitting and request is failing. the all form Created Dynamically after click (button Add more ) is deleted only keep the first form and lot all old data My questions. 1- how to keep all form dynamically created 2 – how to keep .. Read more I am receiving this data from the request: array:2 [ 0 => array:3 [ "from" => 0 "to" => 5 "earned" => 0 ] 1 => array:3 [ "from" => 5 "to" => 10 "earned" => 1 ] ] I would like to add brand_id to each sub-array. I know that I can merge a .. Read more This may be a very simple question, but I can’t figure it out! and that’s frustrating. I do my best to explain everything step by step. This a small Todo list project in Laravel 8 A user can create a Project. When user clicks on a created project, he goes to the project page (show .. Read more I have a search bar in view: {!!Form::open([‘name’=>’myForm’,’method’=>’GET’,’action’=>’[email protected]’, ‘files’=>true,’onsubmit’=>"return validateForm()"]) !!} {!! Form::submit(‘جستجو’,[‘class’=>’btn btn-info’]) !!} {!! Form::close() !!} and in route file, web.php: Route::get(‘area/search/’, ‘[email protected]’)->name(‘area.search’); AreaController: public function search(Request$request){ return " it is working" ; } but when I clicking on the button, the browser showing a blank page. when I use POST method ..

I have below type of json in my laravel request, I want to validate json object key in my laravel request file. I want to validate title value is required of data json. I found solution but it’s for controller, I want to validate it in my request file {"ID":null,"name":"Doe","first-name":"John","age":25,"data":[{"title":"title1","titleval":"title1_val"},{"title":"title2","titleval":"title2_val"}]} Sourc..

I have this function in my controller that checks parameter requests and saves it into my table for tracking. However my if condition is quite too long because whenever a new request will be added I have to write individual if condition to each request. Here is my code: public function storeTracking(Request $request) {$traffic ..

I have two resources Organizations OrganizationUsers Given that I want to create in both resources and that the creation must follow specific requirements, I’m using Request rules() and attributes(). For instance, since organizations need to have a unique name, I’m using public function rules() { return [ ‘name’ => [ ‘required’, ‘min:3’, Rule::unique((new Organization)->getTable())->ignore($this->route()->organization->id ?? .. Read more I’m using the following resource using shallow nesting Route::resource(‘organizations.emaildomains’, ‘OrganizationEmailDomainController’, [‘except’ => [‘show’]])->shallow(); Got the following table with two records which is the result of an index.blade.php Let’s say we want to edit tiagoperes.eu to stackoverflow.com. I’d go to the edit view change the respective field and click the save button. This is the result .. Read more Currently we’re doing unit testing in Laravel, and I just noticed my colleague this line below (its working fine though). I look for a documentation in Laravel about this but I can’t find it. It seems all we’re just focusing on getting the request input values in the documentation. use IlluminateHttpRequest; // …more code here .. Read more What I’m trying to do is basically to avoid having person "like" something same twice. There is combination of author (that’s the user), action (like) and question (question-id), if user has that combination then they cannot like the question again. But issue comes when I try to do this with Laravel validation request. <?php namespace .. Read more Considering this route in web.php: Route::middleware(‘auth:sanctum’)->get(‘/test’, [TestConnections::class, ‘test’]);, Sanctum rejects it if the token is invalid (it is the case if it expired, or a bad token is given, an empty one, etc.). When Sanctum rejects a route, Guard.php‘s __invoke method returns return; so Laravel tries to reach the route "login". Indeed, Laravel shows this .. Read more In web.php, I have set this route: Route::middleware(‘auth:sanctum,expiration:1’)->get(‘/test’, [TestConnections::class, ‘test’]);. The middleware Sanctum’s Guard.php (https://github.com/laravel/sanctum/blob/2.x/src/Guard.php) has indeed a constructor that accepts the expiration as a parameter. I’ve expected that setting this expiration in the route’s middleware declaration was possible but my var_dump($expiration) that I’ve set in the constructor returns NULL, not 1. So this way ..

in my laravel project I extended the core Request class(AppCoreRequest), this works fine, when I call request() it resolves to this class. I also extended this one (AppCoreFormRequest). To keep this example simple, these classes are empty now. In my controller class I’m trying to the following: use AppCoreFormRequest; class MyController { public function update(FormRequest ..

I have defined this route in the web.php route file: Route::get(‘/middleware_test_user_project_change/{pro_id}/{projet_id}’, function ($pro_id,$projet_id) { return ‘test’; })->middleware(‘user.project.change’); I have defined this handle function in my middleware (which I’ve added into the kernel with the following entry: ‘user.project.change’ => AppHttpMiddlewareCheckUserProposition::class): <?php namespace AppHttpMiddleware; use Closure; use IlluminateHttpRequest; use AppModelsUser; class CheckUserProposition { /** * Handle ..

I have a multiple fields binded to "x-editable" plugin that sends the changed data and like all of the data, I want to validate them. But the problem here is that it always sends just 2 fields: name=is_on_probation&value=1. Here, the name key is the field that must be validated (it is the same as DB ..

My code is : … $new_request = Request::create($page, ‘GET’, $request->all(),$request->cookie()); $router = Route::dispatch($new_request); … with middlewares AppHttpMiddlewareEncryptCookies::class, IlluminateCookieMiddlewareAddQueuedCookiesToResponse::class, IlluminateSessionMiddlewareStartSession::class, The problem : A new session is created on every request on Route::dispatch call (if I exit before, no session created, after a new session is created) : new Redis key with redis driver, or ..