contact-mail-send

et#3
Mahesh Sharma 2 years ago
parent b0421ecc08
commit 0ed368eb16
  1. 57
      app/Http/Controllers/HomeController.php
  2. 27
      resources/views/contact_mail.blade.php
  3. 26
      resources/views/welcome.blade.php
  4. 2
      routes/web.php

@ -0,0 +1,57 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function contact(Request $request){
// $contact = new Contact();
$subject = 'Contact Enquiry';
// $check = '';
// if(isset($request['firstname'])){
// $subject = 'Quick Enquiry';
// $check = '1';
// }
// $name = ($request['firstname'] != null) ? ($request['firstname'].' '.$request['lastname']) : $request['fullname'] ;
// $contact->fullname = $name;
// $contact->email = $request['email'];
// $contact->phone = $request['phone'];
// $contact->message = $request['message'];
// $contact->save();
// dispatch(function() use ($check,$subject, $contact) {
\Mail::send('contact_mail', array(
'full_name' =>$request['fname'],
'email' =>$request['email'],
'phone' =>$request['mobile'],
'job_title' =>$request['job_title'],
'contact_message' =>$request['message'],
'subject' =>$subject
), function($message) use ($subject){
// $subject=($service!= '') ? 'Enquiry for '.$service : 'Contact/Feedback';
$message->subject($subject);
// $message->to('info@agilityhomecare.com.au', 'AgilityHomeCare')->subject($subject);
$message->to('info@extratechs.com.au', 'Extratech')->subject($subject);
});
// });
// return redirect()->back()->with(['msg' => 'Successfully submitted.']);
return redirect()->back()->with(['msg' => 'Thank you for your interest. We will get back to you soon.','status' =>'Ok'],200);
}
}

@ -0,0 +1,27 @@
<style>
.main-column{
display:flex;
width:100%;
}
.column-one{
width:50%;
}
</style>
<h1>Contact Details</h1>
<br />
<div class="main-column" style = "display:block; width:100%;">
<div class="column-one" style = "display:block; width:100%;">
<h3>Please, find out the contact details</h3>
<b>Full Name:</b> {{ $full_name }}<br /><br />
<b>Email:</b> {{ $email }}<br /><br />
<b>Phone:</b> {{$phone}}<br /><br />
<b>Job Title:</b> {{$job_title}}<br /><br />
<b>Message:</b> {{ $contact_message }}<br /><br />
</div>
</div>

@ -6,7 +6,9 @@
<meta name="og:image" content="{{url('frontend/images/recruitment.png')}}"/>
@endsection
@section('content')
@php
$msg = Session::get('msg') ?? null;
@endphp
<!-- Start Home -->
<section class="bg-home" style="background: url('/images/recruitment-banner.png') ;">
<div class="bg-overlay"></div>
@ -435,7 +437,8 @@
<div class="col-xl-7 col-lg-8 col-md-9 col-11 text-center">
<div class="card">
<h5 class="text-center mb-4">We do recruitment that makes everyone happy.</h5>
<form class="form-card" onsubmit="event.preventDefault()">
<form class="form-card" method = "post" action = "{{url('/contact')}}">
@csrf
<div class="row justify-content-between text-left">
<div class="form-group col-sm-6 flex-column d-flex"> <label class="form-control-label">Full name<span class="text-danger"> *</span></label>
<input type="text" id="fname" name="fname" placeholder="Enter your full name" onblur="validate(1)">
@ -447,15 +450,15 @@
</div>
<div class="row justify-content-between text-left">
<div class="form-group col-sm-6 flex-column d-flex"> <label class="form-control-label">Phone number<span class="text-danger"> *</span></label>
<input type="text" id="mob" name="mob" placeholder="Enter your phone number" onblur="validate(3)">
<input type="text" id="mob" name="mobile" placeholder="Enter your phone number" onblur="validate(3)">
</div>
<div class="form-group col-sm-6 flex-column d-flex"> <label class="form-control-label">Job title<span class="text-danger"> *</span></label>
<input type="text" id="job" name="job" placeholder="Enter your job title" onblur="validate(4)">
<input type="text" id="job" name="job_title" placeholder="Enter your job title" onblur="validate(4)">
</div>
</div>
<div class="row justify-content-between text-left">
<div class="form-group col-12 flex-column d-flex"> <label class="form-control-label">Have any queries?<span class="text-danger"> *</span></label>
<textarea rows="2" placeholder="Write your message here" id="ans" name="ans"onblur="validate(5)"></textarea>
<textarea rows="2" placeholder="Write your message here" id="message" name="message"onblur="validate(5)"></textarea>
</div>
</div>
<div class="row justify-content-end">
@ -473,7 +476,20 @@
@endsection
@section('script')
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script>
var php_var = "<?php echo $msg; ?>";
if(php_var.length !== 0){
Swal.fire({
title: 'Submitted!!',
text: php_var,
icon: 'success'
})
}
function validate(val) {
v1 = document.getElementById("fname");
v2 = document.getElementById("email");

@ -1,6 +1,7 @@
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomeController;
/*
|--------------------------------------------------------------------------
@ -16,3 +17,4 @@ use Illuminate\Support\Facades\Route;
Route::get('/', function () {
return view('welcome');
});
Route::post('/contact', [HomeController::class, 'contact']);

Loading…
Cancel
Save