/**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     //
     $address = urlencode(Request::get('street_address') . ' ' . Request::get('locality') . ' ' . Request::get('region') . ' ' . Request::get('postal_code'));
     // google map geocode api url
     $url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address={$address}";
     // get the json response
     $resp_json = file_get_contents($url);
     // decode the json
     $resp = json_decode($resp_json, true);
     $geometry = $resp['results'][0]['geometry']['location'];
     $location = Location::find($id);
     $location->latitude = $geometry['lat'];
     $location->longitude = $geometry['lng'];
     $location->update(Request::all());
     $location->save();
     return $location;
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $jobs = JobPosting::all();
     $query = Request::query();
     $jobs = $jobs->filter(function ($job) use($query) {
         foreach ($query as $filter => $value) {
             if ($filter == 'location') {
                 if ($job->location == Location::find($value)) {
                     continue;
                 } else {
                     return false;
                 }
             }
             if ($job->{$filter} != $value) {
                 return false;
             }
         }
         return true;
     });
     return $jobs;
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $testimonials = Testimonial::all();
     $query = Request::query();
     $testimonials = $testimonials->filter(function ($testimonial) use($query) {
         foreach ($query as $filter => $value) {
             if ($filter == 'location') {
                 if ($testimonial->location == Location::find($value)) {
                     continue;
                 } else {
                     return false;
                 }
             }
             if ($testimonial->{$filter} != $value) {
                 return false;
             }
         }
         return true;
     });
     return $testimonials;
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $employees = Employee::all();
     $query = Request::query();
     $employees = $employees->filter(function ($employee) use($query) {
         foreach ($query as $filter => $value) {
             if ($filter == 'location') {
                 if ($employee->locations->contains(Location::find($value))) {
                     continue;
                 } else {
                     return false;
                 }
             }
             if ($employee->{$filter} != $value) {
                 return false;
             }
         }
         return true;
     });
     return $employees;
 }
Пример #5
0
 public static function current()
 {
     $location = null;
     // 1. Get by request parameter
     if (Request::has('location')) {
         $location = Location::find(Request::input('location'));
     } else {
         if (session()->has('location')) {
             $location = Location::find(session()->get('location'));
         } else {
             if (Request::user()) {
                 $location = Location::find(Request::user()->location);
             } else {
                 if (!empty(Request::cookie('location'))) {
                     $location = Location::find(Request::cookie('location'));
                 } else {
                     if (false) {
                     }
                 }
             }
         }
     }
     // 6. Calculate nearest
     // Use if( $location == null ) in case one of the earlier checks
     // succeeded but returned an invalid location (e.g. -- cookie existed
     // but had been tampered with)
     if ($location == null) {
         $locations = Location::all();
         $geoLocation = GeoIP::getLatLng();
         $maxDistance = -1;
         foreach ($locations as $check) {
             $distance = Distance::getDistance($geoLocation, [$check->latitude, $check->longitude]);
             //	if( $maxDistance == -1 || $distance < $maxDistance ) {
             if (($maxDistance == -1 || $distance < $maxDistance) && $check->delivery_distance <= $distance) {
                 $maxDistance = $distance;
                 $location = $check;
             }
         }
         if ($location != null && Request::user()) {
             Request::user()->location = $location->id;
             Request::user()->save();
         }
     }
     // Still no location? Either:
     //    1. Location::all() returned nothing (there are no locations)
     //    2. GeoIP::getLatLng() failed
     //    3. God interfered between lines 64 and 70
     if ($location == null) {
         // Pull the default
         $location = Location::find(1);
     } else {
         session()->put('location', $location->id);
     }
     return $location;
 }
<?php

use App\Models\SiteComponents\Location;
$location = Location::find($location_id);
?>
<h1>We have received your contact submission!</h1>
<p>We have receive the below message submitted through our website 
	<a href="https://www.reedsmetals.com">https://www.reedsmetals.com</a>
</p>
<p style="text-align:center">{{ $comments }}</p>

<p>If you need to contact our store directly you can do so at:</p>

<p style="text-align:center">{{ $location->name }}</p>
<p style="text-align:center"><a href="tel:{{ tel_link( $location->phone ) }}">{{ $location->phone }}</a></p>
<p style="text-align:center">{{ $location->street_address }}</p>
<p style="text-align:center">{{ $location->locality }}, {{ shorten_state( $location->region ) }} {{ $location->postal_code }}</p>

<p>Someone from our office will contact you 
shortly to follow up on your contact form submission.
</p>
 public function detach()
 {
     $location = Location::find(Request::input('location'));
     $profile = MetalProfile::find(Request::input('profile'));
     foreach (Gauge::all() as $gauge) {
         $locationProfileGauge = LocationProfileGauge::where('location_id', '=', $location->id)->where('metal_profile_id', '=', $profile->id)->where('gauge_id', '=', $gauge->id);
         if ($locationProfileGauge->first()) {
             $locationProfileGauge->first()->delete();
         }
     }
     return "success";
 }
Пример #8
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $nonFormPostURLS = ['api/', 'admi', 'auth'];
     if ($request->method() == 'POST' && !in_array(substr($request->path(), 0, 4), $nonFormPostURLS)) {
         // Simple anti-spam check
         if (Input::get('antispam')) {
             return redirect('/');
         }
         // And generic form filter
         if ($this->filter_form(Input::all())) {
             return redirect('/');
         }
         // POST was made to non-API URI
         // Looks like a form submission... Attempt to treat it as such
         $model = Input::get('model');
         if ($model == null) {
             abort(400);
         }
         // Extract form name to simplify this next part
         $formName = lcfirst(substr($model, strrpos($model, '\\') + 1));
         // Determine who should receive the next form submission
         $curLocation = Location::current();
         $formType = $model;
         if ($model == 'App\\Models\\Forms\\BuildingQuote') {
             // We also have a TYPE
             $formType .= ':' . Input::get('building_type');
         }
         $settings = $curLocation->formSettings()->where('model', $formType)->first();
         // Get a list of all employees for the desired department
         $possibleEmployees = $settings->rotation->users;
         foreach ($possibleEmployees as $key => $employee) {
             if (!$employee->locations->contains($curLocation)) {
                 unset($possibleEmployees[$key]);
             }
         }
         $possibleEmployees = $possibleEmployees->flatten();
         if (count($possibleEmployees) > 0) {
             // Figure out where we are in the rotation
             $formRotation = FormRotation::where('location_id', '=', $curLocation->id)->where('form', '=', $formType)->first();
             $formRotation->current = ($formRotation->current + 1) % count($possibleEmployees);
             $formRotation->save();
             // And grab the recipient
             $sendTo = Person::where('email', $possibleEmployees[$formRotation->current]->email)->first();
             $sendTo = Employee::whereIs($sendTo);
         } else {
             // Error: No one in this department. Send to the general manager and owner
         }
         // Create and save an instance of the submitted form
         $modelInstance = new $model();
         $modelInstance->fill(Input::all());
         $modelInstance->employee()->associate($sendTo);
         $modelInstance->location()->associate(Location::find(Input::get('location_id')));
         $modelInstance->save();
         // Handle uploaded files
         $files = $request->files->all();
         $filesToBeAttached = [];
         if (count($files) > 0) {
             if (!file_exists(storage_path($formName))) {
                 mkdir(storage_path($formName));
             }
             $storageFolder = storage_path($formName . '/' . $modelInstance->id . '-' . date('Y-m-d'));
             if (!file_exists(storage_path($formName . '/' . $modelInstance->id . '-' . date('Y-m-d')))) {
                 mkdir($storageFolder);
             }
             foreach ($files as $fileName => $uploadedFileInfo) {
                 $newFileName = $fileName . '-' . $modelInstance->id . '-' . date('Y-m-d') . '.' . $uploadedFileInfo->getClientOriginalExtension();
                 $uploadedFileInfo->move($storageFolder, $newFileName);
                 $filesToBeAttached[] = $storageFolder . '/' . $newFileName;
             }
         }
         $copyTo = [];
         foreach ($settings->copyTo as $copyRecipient) {
             if ($copyRecipient->employee != null) {
                 array_push($copyTo, $copyRecipient->employee);
             } else {
                 array_push($copyTo, $copyRecipient->email);
             }
         }
         // Avoid sending duplicates
         if (($key = array_search($sendTo, $copyTo)) !== false) {
             unset($copyTo[$key]);
         }
         $copyTo = array_unique($copyTo);
         // Send email to employees - informing them of new form submission
         Mail::send('emails.employee.' . $formName, $modelInstance->getAttributes(), function ($m) use($sendTo, $copyTo, $model, $modelInstance, $filesToBeAttached) {
             // To
             /*
             if( is_string($sendTo) ) {
             	$m->to($sendTo, $sendTo);
             } else {
             	$m->to($sendTo->email, $sendTo->full_name);
             }
             foreach( $copyTo as $copy ) {
             	if( is_string($copy) ) {
             		$m->cc($copy, $copy);
             	} else {
             		$m->cc($copy->email, $copy->full_name);
             	}
             }
             */
             $m->to('*****@*****.**', 'Steven Barnett');
             // From
             $m->from('*****@*****.**', 'Reed\'s Metals');
             // Subject
             if ($model == 'App\\Models\\Forms\\BuildingQuote') {
                 $m->subject("{$modelInstance->building_type} Quote ID: {$modelInstance->id} ({$modelInstance->customer_name})");
             } else {
                 if ($model == 'App\\Models\\Forms\\ContactForm') {
                     $m->subject("Contact Form Submission ID: {$modelInstance->id} ({$modelInstance->name})");
                 } else {
                     if ($model == 'App\\Models\\Forms\\EmploymentApp') {
                         $m->subject("Employment Application ID: {$modelInstance->id} ({$modelInstance->name})");
                     } else {
                         if ($model == 'App\\Models\\Forms\\CreditApp') {
                             $m->subject("Business Credit Application ID: {$modelInstance->id} ({$modelInstance->name})");
                         } else {
                             $m->subject("Unknown Form Submission Through ReedsMetals.com");
                         }
                     }
                 }
             }
             // ReplyTo
             if ($modelInstance->customer_email != null) {
                 $m->replyTo($modelInstance->customer_email, $modelInstance->customer_name);
             } else {
                 if ($modelInstance->email != null) {
                     $m->replyTo($modelInstance->email, $modelInstance->name);
                 }
             }
             // Attachments
             foreach ($filesToBeAttached as $file) {
                 $m->attach($file);
             }
         });
         // Send email to customer - informing them we received their submission
         Mail::send('emails.customer.' . $formName, $modelInstance->getAttributes(), function ($m) use($sendTo, $model, $modelInstance) {
             // To
             /*
             if( $modelInstance->customer_email != null ) {
             	$m->to($modelInstance->customer_email, $modelInstance->customer_name);
             } else if( $modelInstance->email != null ) {
             	$m->to($modelInstance->email, $modelInstance->name);
             }
             */
             $m->to('*****@*****.**', 'Steven Barnett');
             // From
             $m->from('*****@*****.**', 'Reed\'s Metals');
             // Subject
             if ($model == 'App\\Models\\Forms\\BuildingQuote') {
                 $m->subject("Your Reed's Metals " . $modelInstance->building_type . " Quote has been received");
             } else {
                 if ($model == 'App\\Models\\Forms\\ContactForm') {
                     $m->subject("Your Reed's Metals Contact Form submission has been received");
                 } else {
                     if ($model == 'App\\Models\\Forms\\EmploymentApp') {
                         $m->subject("Your Reed's Metals Employment App has been received");
                     } else {
                         if ($model == 'App\\Models\\Forms\\CreditApp') {
                             $m->subject("Your Reed's Metals Business Credit App has been received");
                         } else {
                             $m->subject("Unknown Form Submission Through ReedsMetals.com");
                         }
                     }
                 }
             }
             // ReplyTo
             if (is_string($sendTo)) {
                 $m->replyTo($sendTo, $sendTo);
             } else {
                 $m->replyTo($sendTo->email, $sendTo->full_name);
             }
         });
         // Also pass the variables to the "thank you" view... for reasons
         View::share($modelInstance->getAttributes());
         View::share(['employee' => $modelInstance->employee]);
     }
     return $next($request);
 }
Пример #9
0
<?php

use App\Models\SiteComponents\Location;
use Illuminate\Database\Eloquent\Collection;
$title = "Permanent Server Issue";
if (!isset($location)) {
    $location = Location::find(1);
    $locations = Location::all();
    $colors = new Collection();
}
?>
@extends('page')

@section('content')
<div class="title row">
	<h1>Permanent Server Issue</h1>
</div>
<div class="row">
	<p>There seems to be a more serious issue with the server. <strong>This is our fault, not yours.</strong> If you don't mind, please report this issue using the form below so that we can fix it:</p>
</div>
<div class="row">
	<div class="two columns">&nbsp;</div>
	<div class="eight columns">
		<form method="post" action="/500error.php">
			<label for="url">URL:</label>
			<input type="text" id="url" name="url" value="{!! Request::fullUrl() !!}" />
			<label for="comments">Comments:</label>
			<textarea id="comments" name="comments"></textarea>
			<input type="submit" value="Submit" />
		</form>
	</div>
Пример #10
0
 public function detach()
 {
     $location = Location::find(Request::input('location'));
     $color = Color::find(Request::input('color'));
     foreach (Gauge::all() as $gauge) {
         $locationColorGauge = LocationColorGauge::where('location_id', '=', $location->id)->where('color_id', '=', $color->id)->where('gauge_id', '=', $gauge->id);
         if ($locationColorGauge->first()) {
             $locationColorGauge->first()->delete();
         }
     }
     return "success";
 }