Compare commits
5 Commits
2b2a33c59a
...
948b076c03
Author | SHA1 | Date |
---|---|---|
tribikram | 948b076c03 | 2 years ago |
tribikram | 1821580633 | 2 years ago |
tribikram | cf212411de | 2 years ago |
Mahesh Sharma | 4201b17cab | 2 years ago |
Mahesh Sharma | c5d88c4d03 | 2 years ago |
9 changed files with 486 additions and 223 deletions
@ -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']; |
||||||
|
} |
@ -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> |
||||||
|
|
Loading…
Reference in new issue