Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rootes's avatar

Validation in Static::Creating

Hello Everyone, I am not an amazing programmer, I am a just a dancer trying to do some app for my dance school, then I am sorry if the issue is too stupid.

In my I app I have App\Registrations when I register a student to the course (Activity) fill a Laravel Nova form where with:

user_id BelongsTo User partner_id BelongsTo User course_id BelongsTo Courses

Now that is easy, I did that when I create a registration the student can select a partner and if is selected in boot static::creating I add a new row with the partner registration, I have to do it this way because I have more fields in the table like paid and maybe the student did paid but not the partner then i decide to replicate the reservation with a few changes.

Example: user_id = 1 partner_id = 2 course_id = 3

create a new row with user_id = 2 partner_id = 1 course_id = 3

Now I would did a function to check if the User or Partner are ALREADY register to the course as a user or as a partner. but imagine that the partner register later alone to the same. I would like to check before that he is not register to not have duplicated registrations, of course in front end I can use the Controller to check if he/she is registered but not with Laravel Nova Form.

Then I was thing to create a Validation in the boot but the if I place Unique user_id the user can not register to another course_id then I have the same problem would be amazing that in the Model I have a beforeCreating function or something like that.

Remember that I am not that good and maybe the answer is really stupid, the good thing is that laravel is making things so easy that people like me can do good things.

Thanks you all. Inaki

0 likes
0 replies

Please or to participate in this conversation.