How must i validation in api project?

|
Peace_love_yours 2021-07-18 18:06:02
Anybody know google analytics api
khanbozkurt 2021-07-18 19:08:44
Hi everybody. How must i validation in api project?
Siberfx 2021-07-18 19:15:43
huh?)
cayetanohosma 2021-07-18 19:19:16
khanbozkurt 2021-07-18 19:08:44
Hi everybody. How must i validation in api project?

You could use the same as you use in Controller

khanbozkurt 2021-07-18 19:26:41
cayetanohosma 2021-07-18 19:19:16
You could use the same as you use in Controller

So, can i validate in middleware of request data? i want to write single code for validation.

cayetanohosma 2021-07-18 19:52:30
Hmmm, I’m not pretty sure that in the middleware you can access to the request, but check it! Define a middlwware and debug if you can get the request
Siberfx 2021-07-18 20:01:24
i would not prefer to do validation in middleware side, this will affect the app in performance matter too
2021-07-18 20:03:03
saboorhamedi 2021-07-18 06:03:00
public function store(StoreCategoryRequest $request){

// $this->validate($request, [
// ‘name’ => [‘required’, ‘max: 150’],
// ‘parent_id’ => [‘sometimes’, ‘nullable’, ‘numeric’],
// ]);
$category = new Category;
$category->name = $request->name;
$category->parent_id = $request->parent_id;
$category->slug = Str::slug($request->name);
$category->save();
return redirect()->route(‘categories.index’)
->with(‘success’, ‘Category made’);

}

Validation for mobile number ?

2021-07-18 20:03:20
How to validate a mobile number
Darjus Z 2021-07-18 20:29:26
Hello, everyone please help me to show validation message for multiple image upload
Darjus Z 2021-07-18 20:29:45
laravel_discuss-88562.jpg

Darjus Z 2021-07-18 20:30:30
mimes message appears even if image added properly
Darjus Z 2021-07-18 20:42:09
maybe someone?
Bhavyakumar Panchotiya 2021-07-18 20:45:15
laravel_discuss-88565.jpg
can anyone tell me how to solve this error because i write verified with middleware into web.php file but still i got the error !!
KellsLTE 2021-07-18 20:49:59
Bhavyakumar Panchotiya 2021-07-18 20:45:15
can anyone tell me how to solve this error because i write verified with middleware into web.php file but still i got the error !!

This error is for a named route in Laravel. Check your web.php file and ensure that the route in the error is defined as a named route then reload

Bhuvi100 2021-07-18 20:51:17
Darjus Z 2021-07-18 20:42:09
maybe someone?

I think you need to add a custom rule

Bhuvi100 2021-07-18 20:51:39
As far as I know, laravel does not provide validation rules for multiple images
Darjus Z 2021-07-18 20:52:17
but for example for required i find solution
Darjus Z 2021-07-18 20:53:03
‘photosm’ => ‘required|array|min:1’,
Adetollar 2021-07-18 20:53:16
Hello Laraveler’s,

I am trying to db:seed this function underneath to give me a random integer between 1,5 for each order but I am getting a bad method call for random_int.

Order::factory()->times(30)->create() ->
each(function(Order $order) {
OrderItem::factory()-> random_int(1, 5) ->create([
‘order_id’ => $order -> id,
]);
});

Bhuvi100 2021-07-18 20:53:57
Darjus Z 2021-07-18 20:52:17
but for example for required i find solution

Yeah required wont be a problem but if you wanna validate the files individually, you should write a custom rule ig

Darjus Z 2021-07-18 20:55:56
Bhuvi100 2021-07-18 20:53:57
Yeah required wont be a problem but if you wanna validate the files individually, you should write a custom rule ig

ok understand i will check out

Bhuvi100 2021-07-18 20:56:06
Adetollar 2021-07-18 20:53:16
Hello Laraveler’s,

I am trying to db:seed this function underneath to give me a random integer between 1,5 for each order but I am getting a bad method call for random_int.

Order::factory()->times(30)->create() ->
each(function(Order $order) {
OrderItem::factory()-> random_int(1, 5) ->create([
‘order_id’ => $order -> id,
]);
});

It should be something like OrderItem::factory()-> times(random_int(1, 5))->create(….)

Bhuvi100 2021-07-18 20:57:22
Darjus Z 2021-07-18 20:55:56
ok understand i will check out

If you found any first party solutions, update me too 🙃

Darjus Z 2021-07-18 20:58:23
ok 🙂
Adetollar 2021-07-18 21:02:31
Bhuvi100 2021-07-18 20:56:06
It should be something like OrderItem::factory()-> times(random_int(1, 5))->create(….)

Thank you!!!

DesolatorMagno 2021-07-18 21:09:53
Darjus Z 2021-07-18 20:30:30
mimes message appears even if image added properly

Search Laravel validation array.

Darjus Z 2021-07-18 21:10:39
DesolatorMagno 2021-07-18 21:09:53
Search Laravel validation array.

Searched write but not working

Darjus Z 2021-07-18 21:10:57
Im searching all day today for solution
DesolatorMagno 2021-07-18 21:10:58
Is something like photos.* =>
Darjus Z 2021-07-18 21:11:20
Yes but then no mesaage
DesolatorMagno 2021-07-18 21:14:01
No message?
Darjus Z 2021-07-18 21:14:14
Yeah no messages then
DesolatorMagno 2021-07-18 21:14:25
Btw, mimes can be kinda tricky.
Darjus Z 2021-07-18 21:17:06
M maybe in my array problem? because i made when add images and for example forgot some images to add then you click one more time to add more photos to one query to send upload
|