Compare commits

..

5 Commits

  1. 45
      app/Http/Controllers/EnquiryController.php
  2. 41
      app/Jobs/SendEnquiryMailJob.php
  3. 65
      app/Mail/EnquiryMail.php
  4. 13
      app/Models/Enquiry.php
  5. 22
      database/migrations/2023_02_16_171148_create_enquiries_table.php
  6. 20
      resources/views/enquiry-form.blade.php
  7. 76
      resources/views/enquiry_mail.blade.php
  8. 19
      routes/web.php

@ -0,0 +1,45 @@
<?php
namespace App\Http\Controllers;
use App\Jobs\SendEnquiryMailJob;
use App\Models\Country;
use App\Models\Enquiry;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class EnquiryController extends Controller
{
public function form()
{
$countries = Country::all();
return view('enquiry-form', compact('countries'));
}
public function submit(Request $request)
{
$work_experience = $request->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);
}
}

@ -0,0 +1,41 @@
<?php
namespace App\Jobs;
use App\Mail\EnquiryMail;
use App\Models\Setting;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;
class SendEnquiryMailJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
protected $enquiry;
public function __construct($enquiry)
{
$this->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));
}
}

@ -0,0 +1,65 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class EnquiryMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*
*/
protected $enquiry;
public function __construct($enquiry)
{
$this->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 [];
}
}

@ -0,0 +1,13 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Enquiry extends Model
{
use HasFactory;
protected $guarded = ['id'];
}

@ -16,7 +16,7 @@ return new class extends Migration
Schema::create('enquiries', function (Blueprint $table) { Schema::create('enquiries', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('first_name'); $table->string('first_name');
$table->string('middle_name'); $table->string('middle_name')->nullable();
$table->string('last_name'); $table->string('last_name');
$table->date('dob'); $table->date('dob');
$table->string('cob'); $table->string('cob');
@ -25,17 +25,23 @@ return new class extends Migration
$table->string('phone'); $table->string('phone');
$table->string('address'); $table->string('address');
$table->string('highest_qualification'); $table->string('highest_qualification');
$table->string('stream'); $table->string('stream')->nullable();
$table->string('gpa'); $table->string('gpa');
$table->string('graduate_year'); $table->string('graduate_year');
$table->string('gap'); $table->string('gap')->nullable();
$table->string('current_status')->nullable();
$table->string('work_experience'); $table->string('work_experience');
$table->string('salary_mode'); $table->text('work_experience_details')->nullable();
$table->string('test_score'); $table->string('salary_mode')->nullable();
$table->string('test_score')->nullable();
$table->string('marital_status'); $table->string('marital_status');
$table->string('marital_date'); $table->string('married_date')->nullable();
$table->string('spouse_academics'); $table->string('spouse_academics')->nullable();
$table->string('marital_date'); $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->boolean('status')->default(true);
$table->timestamps(); $table->timestamps();
}); });

@ -10,9 +10,14 @@
@endsection @endsection
@section('content') @section('content')
<section class="enquiry-form-section"> <section class="enquiry-form-section">
@php
$msg = Session::get('msg') ?? null;
$status = Session::get('status') ?? null;
@endphp
<h2>Enquiry Form</h2> <h2>Enquiry Form</h2>
<p>Please fill up the form and we will get back to you soon, Thanks !</p> <p>Please fill up the form and we will get back to you soon, Thanks !</p>
<form onsubmit="return submitEnquiry()"> <form action="{{ route('enquiry.submit') }}" onsubmit="return submitEnquiry()" method = "post">
@csrf
<div class="row enquiry-form-row"> <div class="row enquiry-form-row">
<h3>Personal Details</h3> <h3>Personal Details</h3>
<div class="col-md-4"> <div class="col-md-4">
@ -258,7 +263,20 @@
</section> </section>
@endsection @endsection
@section('script') @section('script')
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script> <script>
var php_var = "<?php echo $msg; ?>";
var status = "<?php echo $status; ?>";
if(php_var.length !== 0){
Swal.fire({
title: 'Submitted!!',
text: php_var,
icon: status ? 'success' : 'error'
})
}
fnameError = document.getElementById('error-fname'); fnameError = document.getElementById('error-fname');
lnameError = document.getElementById('error-lname'); lnameError = document.getElementById('error-lname');
dobError = document.getElementById('error-dob'); dobError = document.getElementById('error-dob');

@ -0,0 +1,76 @@
<style>
.main-column{
display:flex;
width:100%;
}
.column-one{
width:50%;
}
</style>
<h1>Persional Details</h1>
<br />
<div class="main-column" style = "display:block; width:100%;">
<div class="column-one" style = "display:block; width:100%;">
<b>Full Name:</b> {{ $enquiry->first_name . ' ' .(!is_null($enquiry->middle_name) ? $enquiry->middle_name .' ' :''). $enquiry->last_name }}<br /><br />
<b>Email:</b> {{ $enquiry->email }}<br /><br />
<b>Phone:</b> {{$enquiry->phone}}<br /><br />
<b>Address:</b> {{$enquiry->address}}<br /><br />
<b>Date of Birth:</b> {{$enquiry->dob}}<br /><br />
<b>Country of Birth:</b> {{$enquiry->cob}}<br /><br />
<b>Gender:</b> {{$enquiry->gender}}<br /><br />
</div>
</div>
<h1>Additional Details</h1>
<br />
<div class="main-column" style = "display:block; width:100%;">
<div class="column-one" style = "display:block; width:100%;">
<b>Highest Qualification:</b> {{ $enquiry->highest_qualification }}<br /><br />
@if(!is_null($enquiry->stream))
<b>Stream:</b> {{$enquiry->stream}}<br /><br />
@endif
<b>% or GPA</b> {{$enquiry->gpa}}<br /><br />
<b>Graduated year:</b> {{$enquiry->graduate_year}}<br /><br />
<b>Gap:</b> {{$enquiry->gap}}<br /><br />
<b>Current Status:</b> {{$enquiry->current_status}}<br /><br />
<b>Work Experience:</b> {{$enquiry->work_experience}}<br /><br />
@if(!is_null($enquiry->work_experience))
<b>Work Experience Details:</b> {{$enquiry->work_experience_details}}<br /><br />
@endif
@if(!is_null($enquiry->salary_mode))
<b>Salary Mode:</b> {{$enquiry->salary_mode}}<br /><br />
@endif
<b>Test Score:</b> {{$enquiry->test_score}}<br /><br />
<b>Marital Status:</b> {{$enquiry->marital_status}}<br /><br />
@if(!is_null($enquiry->married_date))
<b>Married Date:</b> {{$enquiry->married_date}}<br /><br />
@endif
@if(!is_null($enquiry->spouse_academics))
<b>Spouse Academic:</b> {{$enquiry->spouse_academics}}<br /><br />
@endif
@if(!is_null($enquiry->spouse_work_experience))
<b>Spouse Work Experience:</b> {{ $enquiry->spouse_work_experience }}<br /><br />
@endif
@if(!is_null($enquiry->spouse_salary_mode))
<b>Spouse Salary Mode:</b> {{ $enquiry->spouse_salary_mode }}<br /><br />
@endif
@if(!is_null($enquiry->immigration_history))
<b>Immigration History:</b> {{ $enquiry->immigration_history }}<br /><br />
@endif
@if(!is_null($enquiry->desired_study_field))
<b>Desired Field of Study:</b> {{ $enquiry->desired_study_field }}<br /><br />
@endif
@if(!is_null($enquiry->desired_location))
<b>Desired Location:</b> {{ $enquiry->desired_location }}<br /><br />
@endif
</div>
</div>

@ -43,6 +43,7 @@ use App\Models\Country;
use App\Http\Controllers\Admin\TeamController; use App\Http\Controllers\Admin\TeamController;
use App\Http\Controllers\Admin\AppointmentController; use App\Http\Controllers\Admin\AppointmentController;
use App\Http\Controllers\EnquiryController;
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -54,6 +55,7 @@ use App\Http\Controllers\Admin\AppointmentController;
| contains the "web" middleware group. Now create something great! | contains the "web" middleware group. Now create something great!
| |
*/ */
Route::get('/mycron', [HomeController::class, 'runQueueJobs']); Route::get('/mycron', [HomeController::class, 'runQueueJobs']);
Route::get('/seed', [HomeController::class, 'runSeeder']); Route::get('/seed', [HomeController::class, 'runSeeder']);
Route::get('/', [HomeController::class, 'index'])->name('home.index'); Route::get('/', [HomeController::class, 'index'])->name('home.index');
@ -287,11 +289,7 @@ Route::group(['middleware'=>['auth']],function (){
Route::get('accomodations/points_remove/{id}', [AccomodationController::class, 'points_remove']); Route::get('accomodations/points_remove/{id}', [AccomodationController::class, 'points_remove']);
Route::get('accomodations/information_points_remove/{id}', [AccomodationController::class, 'information_points_remove']); Route::get('accomodations/information_points_remove/{id}', [AccomodationController::class, 'information_points_remove']);
Route::get('accomodations/slider_points_remove/{id}', [AccomodationController::class, 'slider_points_remove']); Route::get('accomodations/slider_points_remove/{id}', [AccomodationController::class, 'slider_points_remove']);
}); });
}); });
Route::get('/services', function () { Route::get('/services', function () {
return view('services'); return view('services');
@ -302,12 +300,13 @@ Route::get('/career_counselling', function () {
Route::get('/insurance', function () { Route::get('/insurance', function () {
return view('insurance'); return view('insurance');
}); });
Route::get('/enquiry', function () { // Route::get('/enquiry', function () {
$countries = Country::all(); // $countries = Country::all();
return view('enquiry-form', compact('countries')); // return view('enquiry-form', compact('countries'));
}); // });
Route::get('/enquiry' , [EnquiryController::class, 'form']);
Route::post('/enquiry' , [EnquiryController::class, 'submit'])->name('enquiry.submit');
// Route::get('/visa', function () { // Route::get('/visa', function () {
// return view('visa'); // return view('visa');
// }); // });

Loading…
Cancel
Save