Category : request

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 ‘foo’? In case there isn’t, what would be the best way to perfoem such a verification manually? Sourc..

Read more

I have controller recieve 12 request from flutter app, the request is like this: data.map((e) async { Map list = { ‘username’: username, ‘club’: e.club, ‘price’: e.price, ‘surename’: e.surname, ‘id’: e.id, ‘league’: e.leagueName, }; try { var newurl = Uri.parse(url + ‘create_team’); var response = await http.post(newurl, body: jsonEncode(list), headers: { ‘Content-Type’: ‘application/json’, ‘Authorization’: ‘Bearer ..

Read more

I need to get response from async request and retry request if it’s not successful. I’m trying to test with printing message in log file if exception is called, but I’m not getting this error message. What I tried so far -> I followed this link: https://github.com/reactphp/promise#how-promise-forwarding-works $promise = Api::async()->get($url)->then( function ($result) { $this->handleResult($result); } ..

Read more

I’m trying to make asynchronous request using laravel async() function. Following this link: https://www.amitmerchant.com/async-http-requests-laravel-8x/ I set up function like this: $promise = Http::async()->get($url)->then( fn ($result) => $this->handleResult($result) ); The thing is, I need to manage request in background, I need to handle promise response and If promise is resolved return response code, if response is ..

Read more

I have flutter app with this register request : var url = ‘xxxxxxx/api/v1/’; // register—————– registerToApp(password, username, email, context) async { var newurl = Uri.parse(url + ‘register’); var data = { ‘password’: password, ‘username’: username, ’email’: email, }; if (username == ” || password == ” || email == ”) { showSnackBar(context, ‘Username and Password ..

Read more

I see a lot of answers to this question, but they are all very naive, and I wouldn’t consider them a solution, just a workaround (e.g. this one) What I have are 2 Laravel projects, one for administration and one for the "ecommerce" Now, let’s say the administrator uploads some images, and I want to ..

Read more

I’m working on a large Laravel app, currently on v8.45.1 which has never had tests, so I’m working to get it to a point where we can start writing unit & feature tests. I’m hitting an issue where the two request classes (AppCoreRequest and AppCoreFormRequest) both use a trait RequestTrait which holds a set of ..

Read more

I’ll have JSON and try to disassemble and save it in database: { “token”: “f56445c24ad84e9c452f3ca6ef91e90beb2aef21”, “participant”: “ZuP0rsny3MhqLC0”, “data”: { “orgs”: [{ “org1”: { “attribute”: [{ “name”: “val”, “inn”: “val”, “kpp”: “val” }], “tickets”: [{ “ticket1”: [{ “account_uid”: “val”, “created_at”: “val”, “title”: “val”, “text”: “val”, “status”: “val”, “priority”: “val”, “fullname”: “val”, “workaddr”: “val”, “phone”: “val”, “email”: ..

Read more

i use Authentication system and want Update record of User is "loggen in" and use this code: enter code here $data=User::find(Auth::user()->id); //echo $date; $data->gender=$request->gender; $data->name=$request->username; $data->mobile=$request->mobile; $data->email=$request->email; $data->address=$request->address; $data->image=$request->image; $data->save; return redirect()->route(‘profile.view’)->with(‘success’,’ User Updated successfuly’); but dont update this record and dont receive any Error. please guide me Sourc..

Read more

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: ..

Read more

public function addcart($request) { $patient_id = 10217; $patient_diagnostic_cart = @unserialize($patient->diagnostic_cart); $cart = Session::get(‘cart’); $response = []; if (!empty($patient_diagnostic_cart)) { if (in_array((int)$cart->test_id, $patient_diagnostic_cart)) { $message = "Test allready added"; } else { array_push($patient_diagnostic_cart, (int)$cart->test_id); $patient->diagnostic_cart = serialize($patient_diagnostic_cart); $patient->save(); $message = "Test added"; } } else { $patient_diagnostic_cart = (array)(int)$cart->test_id; $patient->diagnostic_cart = serialize($patient_diagnostic_cart); $message = "Test added"; ..

Read more

I am using laravel 7 and need to check Request::path() where Url will have dynamic values Route in web.php Route::get(‘/user/portfolio/{id}/{cid}’, ‘[email protected]’)->name(‘user_portfolio_view’); URL on browser http://cat-and-pillar.ets/user/portfolio/34/1 where 34 and 1 always dynamic. i need to add some condition on all these type of URl Thank you in advance Sourc..

Read more

Bagian isi dari else sudah dapat dijalankan, tetapi bagian isi dari if jika di die dump (dd) hasilnya null. tolong bantuannya if (request()->get(‘month’) && request()->get(‘year’)) { $reports = $reports->whereMonth("created_at", date("m", request()->get(‘month’))) ->whereYear("created_at", date("Y", strtotime(request()->get(‘year’)))) ->get(); } else { $reports = Report::whereMonth(‘created_at’, now()->month) ->whereYear(‘created_at’, now()->year)->get(); } return $reports;“` Sourc..

Read more

The contents of the else can already be executed, but the contents of the if in the die dump (dd) the result is null. please help if (request()->get(‘month’) && request()->get(‘year’)) { $reports = $reports->whereMonth("created_at", date("m", request()->get(‘month’))) ->whereYear("created_at", date("Y", strtotime(request()->get(‘year’)))) ->get(); } else { $reports = Report::whereMonth(‘created_at’, now()->month) ->whereYear(‘created_at’, now()->year)->get(); } return $reports; Sourc..

Read more

public function addcart($request) { $patient_id = config(‘api.current_user.patient_id’) ? config(‘api.current_user.patient_id’) : 0; $patient = Patient::find($patient_id); $patient_diagnostic_cart = @unserialize($patient->diagnostic_cart); $response = []; if (!empty($patient_diagnostic_cart)) { if (in_array((int)$request->test_id, $patient_diagnostic_cart)) { // abort(400, "Test allready added"); $message = "Test allready added"; } else { array_push($patient_diagnostic_cart, (int)$request->test_id); $patient->diagnostic_cart = serialize($patient_diagnostic_cart); $patient->save(); $message = "Test added"; } } else { $patient_diagnostic_cart ..

Read more

Hello guys I need to limit the size of the image, not the size of file, but the width and height, so far I have this: public function rules() { if(request()->isMethod(‘put’)) // could be patch as well { // Update rules here – Don’t require image here return [ ‘name’ => ‘required’, ‘code’ => ‘required|regex:/^#?(([a-f0-9]{3}){1,2})$/i’, ..

Read more