Support the ongoing development of Laravel.io →
Forms Validation
Last updated 1 year ago.

invokermaster liked this thread

1

Where do you validate the input?

0
moderator

In your request you validate against the pay_period_start and pay_period_end input while in the store function you load a Payperiod model. Where do you want to validate against?

0

@rimace I'm validating it in the form request class that's available in laravel 6+, the rules are the second block of code I have in the example.

0

@Tobias van Beek I'd like to validate work_date against the pay_period_start and pay_period_end. The idea is an admin would create new pay periods for users to input their work hours. I'm not necessarily tied to storing the pay period start and ends to each new instance of $tracked_time, but at least from what I have run into in hopes of solving the problem, it seems that start and end dates are passed into the validator like so:

$rules = [ 'start_date' => 'date_format:d/m/Y|after:tomorrow', 'end_date' => 'date_format:d/m/Y|after:start_date', ];

In the database the dates are being stored correctly, and it the above will check to make sure the inputs are dates, but doesn't check to make sure work_date is between the pay period dates.

Last updated 4 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.