skip to Main Content

Laravel: required_if with an AND check

Consider this validation: Route::post('/validate', function (Request $request): JsonResponse { $validated = $request->validate([ "insurance_plan" => ["required", "in:Commerical Insurance,Government,Uninsured"], "insurance_hasSecondaryPrescriptionInsurance" => ["boolean"], 'insurance_secondaryPrescriptionName' => ['required_if:insurance_hasSecondaryPrescriptionInsurance,true', 'required_if:insurance_plan,Government,Commericial Insurance' ] ]); return response()->json([ 'validated' => $validated ]); }); For insurance_secondaryPrescriptionName, I'm looking to do…

VIEW QUESTION

Dynamic Database Connections in Laravel

As already known we can add more database connection in Laravel by updating app/config/database.php file in the connections array and using Schema::connection('mysql2')->... amd = DB::connection('mysql2')->select(...); to do queries. BUT, what if I want 50 databases or more, I can create…

VIEW QUESTION

Sending mail from event and listener in laravel 9

I have the following method in laravel my controller: use AppEventsContactFormSubmitted; public function submitContactForm(Request $request) { $validatedData = $request->validate([ 'name' => 'required|string|max:255', 'email' => 'required|email|max:255', 'subject' => 'required|string|max:255', 'message' => 'required|string', ]); // Dispatch the event with the validated data…

VIEW QUESTION

Laravel join in HasMany relationship

I have three models: EmailTemplate EmailSend Attendee An EmailSend references both an Attendee and an EmailTemplate: class EmailSend extends MyBaseModel { ... public function attendee() { return $this->belongsTo(AppModalsAttendee::class); } public function template() { return $this->belongsTo(AppModalsEmailTemplate::class); } ... } and associated…

VIEW QUESTION
Back To Top
Search