Skip to content

Commit

Permalink
added verification, analytics, booking form working
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-mc-m committed Dec 7, 2017
1 parent b8efb05 commit 84ed335
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 94 deletions.
24 changes: 22 additions & 2 deletions app/Http/Controllers/FrontendController.php
Expand Up @@ -13,6 +13,7 @@
use Illuminate\Support\Facades\Mail;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class FrontendController extends Controller
{
/**
Expand Down Expand Up @@ -53,9 +54,28 @@ public function contact()
return view('contact');
}

/**
* Process the contact form and send an email form it.
*
* @param Request $request
* @return view
*/
public function book(Request $request)
{
Mail::to('neilo2000@gmail.com')->send(new BookingForm($request));
return view('contact');

$bookingFormData = array(
'name' => $request->input('name'),
'email' => $request->input('email'),
'date' => $request->input('date'),
'message' => $request->input('message')
);
try {
Mail::to(env('MAIL_TO'))->send(new BookingForm($bookingFormData));
return view('contact')->with(['sent' => true]);
} catch (\Exception $e) {
return view('contact')->with(['sent' => false]);
}


}
}
7 changes: 4 additions & 3 deletions app/Mail/BookingForm.php
Expand Up @@ -12,14 +12,14 @@ class BookingForm extends Mailable
{
use Queueable, SerializesModels;

public $request;
public $bookingFormData;
/**
* Create a new message instance.
*
*/
public function __construct(Request $request)
public function __construct($bookingFormData)
{
$this->request = $request;
$this->bookingFormData = $bookingFormData;
}

/**
Expand All @@ -29,6 +29,7 @@ public function __construct(Request $request)
*/
public function build()
{
$this->replyTo($this->bookingFormData['email'], $this->bookingFormData['name']);
return $this->view('emails.booking');
}
}
16 changes: 16 additions & 0 deletions public/.htaccess
Expand Up @@ -4,6 +4,12 @@
</IfModule>

RewriteEngine On
# Set %{ENV:PROTO} variable, to allow rewrites to redirect with the
# appropriate schema automatically (http or https).
RewriteCond %{HTTPS} =on
RewriteRule ^ - [env=proto:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^ - [env=proto:http]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
Expand All @@ -18,4 +24,14 @@
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Option 1: rewrite www.example.com → example.com


RewriteEngine On
# (1)
# RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ %{ENV:PROTO}://%1%{REQUEST_URI} [R=301,L]

</IfModule>
31 changes: 15 additions & 16 deletions resources/views/base.twig
Expand Up @@ -2,29 +2,26 @@
<!doctype html>
<html lang="en">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-70929080-4"></script>
<script>
if (window.location.hostname != 'localhost') {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-70929080-4');
}
</script>

<meta charset="utf-8" />
{#<link rel="icon" type="image/png" href="../assets/img/favicon.ico">#}
{#<link rel="apple-touch-icon" sizes="76x76" href="../assets/img/apple-icon.png">#}

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

<title>{% block title %}{% endblock %}</title>

<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
<meta name="viewport" content="width=device-width" />

<!-- Bootstrap core CSS -->
{#<link href="css/bootstrap.min.css" rel="stylesheet" />#}
{#<link href="css/paper-kit.css?v=2.1.0" rel="stylesheet"/>#}

<!-- CSS for Demo Purpose, don't include it in your project -->
{#<link href="../assets/css/demo.css" rel="stylesheet" />#}

<!-- Canonical SEO -->
{#<link rel="canonical" href=" https://www.creative-tim.com/product/paper-kit-2">#}

<!-- Social tags -->
{#<meta name="keywords" content="creative tim, bootstrap 4 kit, ui kit, web kit, paper kit, web design, web development, presentation pages, frontend, responsive bootstrap 4 template">#}

<meta name="description" content="{% block description %}{% endblock %}">

<!-- Schema.org markup for Google+ -->
Expand All @@ -49,6 +46,8 @@
<meta property="og:description" content="Personal Trainer based out of Northwood Gym. Prices from 30euro per session and free 30min consultation.">
<meta property="og:site_name" content="Phil Dillon Fitness">

<!-- verification for google search console -->
<meta name="google-site-verification" content="IrIah9awQ7APZHDeJ771JoxM7MiFtChMCloe7xNgzw8" />
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet" />
<link href="css/paper-kit.css" rel="stylesheet"/>
Expand Down
91 changes: 57 additions & 34 deletions resources/views/contact.twig
Expand Up @@ -13,11 +13,34 @@
{#<h1>Phil Dillon Fitness</h1>#}
<h1>Personal Trainer</h1>
<br/>
<p class="p-3">Get your free 30min fitness assessment</p>
<button type="button" class="btn btn-outline-neutral btn-round">Book Now</button>
<h6 class="p-3">Contact</h6>
<p>Use the booking form below to get a free fitness consultation.</p>
</div>
</div>
</div><!-- end page-header -->
{% if sent is defined %}
{% if sent == true %}
<div class="alert alert-success">
<div class="container">
<div class="row">
<div class="col-12 col-md-8 p-">
<p>Thanks for getting in touch. Ill get back to you to confirm your fitness assessment.</p>
</div>
</div>
</div>
</div><!-- end alert -->
{% elseif sent == false %}
<div class="alert alert-success">
<div class="container">
<div class="row">
<div class="col-12 col-md-8 p-">
<p>Sorry, that message didnt send for some reason.</p>
</div>
</div>
</div>
</div><!-- end alert -->
{% endif %}
{% endif %}
<div class="section">
<div class="container">
<div class="row">
Expand All @@ -32,65 +55,65 @@
Book a date and time and i'll get back to you if available.
</p>
<br>
<form action="{{ route('book') }}" method="POST">
<form action="{{ route('contact') }}" method="POST">
{{ csrf_field() }}
<div class="container">
<div class="row">
<div class="col-md-6 p-1">
<label for="name">Name</label>
<div class="input-group">
<div class="row">
<div class="col-md-6 p-1">
<label for="name">Name</label>
<div class="input-group">

<input type="text" class="form-control" name="name" placeholder="name"/>
<span class="input-group-addon">
<input type="text" class="form-control" name="name" placeholder="name"/>
<span class="input-group-addon">

<i class="nc-icon nc-single-02" aria-hidden="true"></i>

</span>
</div>
</div>
</div>
<div class="col-md-6 p-1">
<label for="email">email</label>
<div class="input-group">
<div class="col-md-6 p-1">
<label for="email">email</label>
<div class="input-group">

<input type="email" class="form-control" name="email" placeholder="email"/>
<span class="input-group-addon">
<input type="email" class="form-control" name="email" placeholder="email"/>
<span class="input-group-addon">

<i class="nc-icon nc-email-85" aria-hidden="true"></i>

</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 p-1">
<label for="date">Date</label>
<div class="input-group date" id="datetimepicker">
<input type="text" class="form-control datetimepicker" name="date" placeholder="book a date" readonly="true"/>
<span class="input-group-addon">
<div class="row">
<div class="col-md-12 p-1">
<label for="date">Date</label>
<div class="input-group date" id="datetimepicker">
<input type="text" class="form-control datetimepicker" name="date" placeholder="book a date" readonly="true"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar">
<i class="fa fa-calendar" aria-hidden="true"></i>
</span>
</span>
</div>
</div>
</div>

</div>
<div class="row">
<div class="col-md-12 p-1">
<label for="message">Message</label>
<textarea class="form-control" name="message" rows="4" placeholder="Got any special requirements or allergies? Let me know here.
."></textarea>
</div>
<div class="row">
<div class="col-md-12 p-1">
<label for="message">Message</label>
<textarea class="form-control" name="message" rows="4" placeholder="Got any special requirements or allergies? Let me know here.
."></textarea>
</div>


</div>
</div>

<div class="row text-center">
<div class="col-md-12 m-3">
<button type="submit" class="btn btn-danger btn-lg btn-fill">Book</button>
<div class="row text-center">
<div class="col-md-12 m-3">
<button type="submit" class="btn btn-danger btn-lg btn-fill">Book</button>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions resources/views/emails/booking.twig
@@ -1,4 +1,5 @@
<h1>Phil Dillon Fitness Booking Form</h1>
<p>Kudos! You have a new message from {{ request.name }}</p>
<p>I want the {{ request.date }}</p>
<p>{{ request.message }}</p>
<p>Kudos!</p>
<p>You have a new message from <em>{{ bookingFormData.name }}</em></p>
<p>I would like to book a fitness assessment on {{ bookingFormData.date }}</p>
<p>{{ bookingFormData.message }}</p>
4 changes: 2 additions & 2 deletions resources/views/footer.twig
Expand Up @@ -18,8 +18,8 @@
<li><a href="mailto:info@phildillonfitness.ie">info@phildillonfitness.ie</a></li>

<li class="nav-item">
<a href="tel:+13174562564" class="nav-link d-block d-sm-none">call</a>
<a href="#" class="nav-link d-none d-md-block">call : 0876216768</a>
<a href="tel:0877756921" class="nav-link d-block d-sm-none">call</a>
<a href="#" class="nav-link d-none d-md-block">call : 0877756921</a>
</li>
</ul>
</nav>
Expand Down
16 changes: 10 additions & 6 deletions resources/views/hello.twig
Expand Up @@ -10,9 +10,9 @@
<div class="container">
<div class="motto text-center">
{#<h1>Phil Dillon Fitness</h1>#}
<h1>Personal Trainer<br>&<br> Fitness Instructor</h1>
<h1>Personal Trainer</h1>
<br/>
<p class="p-3">Get your free 30min fitness assessment</p>
<p class="p-3">Get your free 30min fitness consultation</p>
<a href="/contact" class="btn btn-outline-neutral btn-round">Book Now</a>
</div>
</div>
Expand Down Expand Up @@ -41,12 +41,16 @@
<div class="row">

<div class="col-12 col-md-6">

<p>I cater for individuals and groups of 2 with a flexible approach to the classes. With prices from &euro;30 per session (when you
book 6 or more), you'll get great value and great results!</p>
<p>
I cater for individuals and groups of 2 with a flexible approach to the classes. With competitve pricing packages available, you'll
get great value and great results!
</p>
</div>
<div class="col-12 col-md-6">
<p>I also provide realistic training programs and food plans as part of my service.</p>
<p>
I also provide realistic training programs and food plans as part of my service. I understand the importance of nutrition along
with personalised exercise programs to help people achieve their goals.
</p>
</div>

<br><br>
Expand Down

0 comments on commit 84ed335

Please sign in to comment.