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

invokermaster liked this thread


Where do you validate the input?


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?


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


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

Sign in to participate in this thread!


Your banner here too?


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

Your logo here?

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

© 2024 - All rights reserved.