diff --git a/app/Http/Controllers/EnquiryController.php b/app/Http/Controllers/EnquiryController.php new file mode 100644 index 0000000..8cb726a --- /dev/null +++ b/app/Http/Controllers/EnquiryController.php @@ -0,0 +1,45 @@ +get('work_experience'); + if ($work_experience == 'no') { + $request['work_experience_details'] = null; + $request['salary_mode'] = null; + } + $marital_status = $request->get('marital_status'); + if ($marital_status == 'Widow' || $marital_status == 'Single') { + + $request['married_date'] = null; + $request['spouse_academics'] = null; + $request['spouse_work_experience'] = null; + $request['spouse_salary_mode'] = null; + } + DB::beginTransaction(); + try { + $enquiry = Enquiry::create($request->all()); + } catch (\Exception $e) { + DB::rollback(); + return redirect()->back()->with(['msg' => 'Something went wrong. Please try again!', 'status' => false], 400); + } + DB::commit(); + dispatch(new SendEnquiryMailJob($enquiry)); + return redirect()->back()->with(['msg' => 'We have recieved your enquiry. You will be contacted soon!', 'status' => true], 200); + } +} diff --git a/app/Jobs/SendEnquiryMailJob.php b/app/Jobs/SendEnquiryMailJob.php new file mode 100644 index 0000000..b2e2a99 --- /dev/null +++ b/app/Jobs/SendEnquiryMailJob.php @@ -0,0 +1,41 @@ +enquiry = $enquiry; + } + + /** + * Execute the job. + * + * @return void + */ + public function handle() + { + $email = Setting::where('key', 'email')->get('value')->first()->value; + + Mail::to($email)->send(new EnquiryMail($this->enquiry)); + } +} diff --git a/app/Mail/EnquiryMail.php b/app/Mail/EnquiryMail.php new file mode 100644 index 0000000..98e5137 --- /dev/null +++ b/app/Mail/EnquiryMail.php @@ -0,0 +1,65 @@ +enquiry = $enquiry; + } + + /** + * Get the message envelope. + * + * @return \Illuminate\Mail\Mailables\Envelope + */ + public function envelope() + { + return new Envelope( + subject: 'Enquiry Mail', + ); + } + + /** + * Get the message content definition. + * + * @return \Illuminate\Mail\Mailables\Content + */ + public function content() + { + return new Content( + view: 'enquiry_mail', + with: [ + 'enquiry' => $this->enquiry, + ], + ); + } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments() + { + return []; + } +} diff --git a/app/Models/Enquiry.php b/app/Models/Enquiry.php new file mode 100644 index 0000000..45f7bcd --- /dev/null +++ b/app/Models/Enquiry.php @@ -0,0 +1,13 @@ +id(); $table->string('first_name'); - $table->string('middle_name'); + $table->string('middle_name')->nullable(); $table->string('last_name'); $table->date('dob'); $table->string('cob'); @@ -25,17 +25,23 @@ return new class extends Migration $table->string('phone'); $table->string('address'); $table->string('highest_qualification'); - $table->string('stream'); + $table->string('stream')->nullable(); $table->string('gpa'); $table->string('graduate_year'); - $table->string('gap'); + $table->string('gap')->nullable(); + $table->string('current_status')->nullable(); $table->string('work_experience'); - $table->string('salary_mode'); - $table->string('test_score'); + $table->text('work_experience_details')->nullable(); + $table->string('salary_mode')->nullable(); + $table->string('test_score')->nullable(); $table->string('marital_status'); - $table->string('marital_date'); - $table->string('spouse_academics'); - $table->string('marital_date'); + $table->string('married_date')->nullable(); + $table->string('spouse_academics')->nullable(); + $table->string('spouse_work_experience')->nullable(); + $table->string('spouse_salary_mode')->nullable(); + $table->string('immigration_history')->nullable(); + $table->string('desired_study_field')->nullable(); + $table->string('desired_location')->nullable(); $table->boolean('status')->default(true); $table->timestamps(); }); diff --git a/resources/views/contact.blade.php b/resources/views/contact.blade.php index 08465c0..0b940e3 100644 --- a/resources/views/contact.blade.php +++ b/resources/views/contact.blade.php @@ -9,8 +9,8 @@ @endsection @section('content') -@php - $msg = Session::get('msg') ?? null; + @php + $msg = Session::get('msg') ?? null; @endphp