/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $class = new NewsArticle();
     $class->location()->associate(Location::current());
     $class->save();
     $class->update(Request::all());
     return $class;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //$class = JobPosting::create( Request::all() );
     $class = new JobPosting(Request::all());
     $class->location()->associate(Location::current());
     $class->save();
     return $class;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $class = new Testimonial();
     $class->fill(Request::all());
     $class->location()->associate(Location::current());
     $class->save();
     return $class;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     $person = Person::create(Request::all());
     $employee = new Employee();
     $employee->is($person);
     $employee->locations()->attach(Location::current());
     return ['id' => $employee->id, 'full_name' => $person->full_name, 'title' => $person->title, 'email' => $person->email, 'tel' => $person->tel];
 }
Ejemplo n.º 5
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $permalink = implode('/', func_get_args());
     $page = Page::where('permalink', $permalink)->where('location_id', Location::current()->id)->first();
     if ($page != null) {
         return view()->make('pagecontent')->withTitle($page->title)->withContent($page->content);
     } else {
         abort(404);
     }
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Request::has('lat') && Request::has('lng')) {
         Location::setCurrent(Request::get('lat'), Request::get('lng'));
         Session::put('geoIP', true);
     }
     if (Session::get('geoIP')) {
         View::share(['haveGeoIp' => true]);
     } else {
         View::share(['haveGeoIp' => false]);
     }
     $location = Location::current();
     if ($location->parent != null) {
         $location = $location->parent;
     }
     View::share(['user' => Auth::user(), 'location' => $location, 'locations' => Location::all(), 'homepage' => HomePage::where('location_id', '=', $location->id)->first(), 'colors' => $location->colors(), 'profiles' => $location->profiles()]);
     return $next($request);
 }
Ejemplo n.º 7
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // TODO: smarter
     $req = Request::get('recipient');
     $type = Request::get('subsection');
     if (strpos($req, '@') !== false) {
         $recipient = new FormRecipient();
         $recipient->email = $req;
     } else {
         $person = Person::where('full_name', 'like', "%{$req}%")->first();
         $employee = Employee::whereIs($person);
         $recipient = new FormRecipient();
         $recipient->employee()->associate($employee);
     }
     $recipient->type = $type;
     // Duplicates are prevented by an integrity constraint
     Location::current()->{Request::get('section')}->{$type}()->save($recipient);
     $recipient->save();
     return ['id' => $recipient->id, 'email' => $recipient->email];
 }
 public function orderSlider()
 {
     $location = Location::current();
     $order = json_decode(Request::get('order'));
     $panels = $location->homepage->slider->panels;
     $cnt = count($order);
     for ($i = 0; $i < $cnt; $i++) {
         foreach ($panels as $panel) {
             if ($panel->id == $order[$i]) {
                 $panel->order = $i;
                 $panel->save();
                 break;
             }
         }
     }
     return "success";
 }
Ejemplo n.º 9
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);
 }
 public function display()
 {
     return view('gallery')->with(['locationGalleries' => Location::current()->locationGalleries]);
 }
Ejemplo n.º 11
0
});
Route::get('/locations/{location}', function ($location) {
    $viewing = Location::where('name', ucwords(str_replace('-', ' ', $location)))->first();
    return View::make('dynamic_pages.location')->with(['title' => $viewing->name, 'viewingLocation' => $viewing]);
});
Route::get('/galleries/{gallery}', function ($gallery) {
    $viewing = Gallery::where('slug', $gallery)->first();
    return View::make('dynamic_pages.gallery')->with(['title' => $viewing->name, 'gallery' => $viewing]);
});
Route::get('/specials/{special}', function ($special) {
    $viewing = Special::where('title', ucwords(str_replace('-', ' ', $special)))->first();
    return View::make('dynamic_pages.special')->with(['title' => $viewing->title, 'special' => $viewing]);
});
// Some SEO redirects
Route::get('/sales-team', function () {
    return Redirect::to('/locations/' . strtolower(str_replace(' ', '-', Location::current()->name)));
});
Route::any('/careers', function () {
    return Redirect::to('/resources/employment', 301);
});
Route::any('/privacy', function () {
    return Redirect::to('/legal', 301);
});
// This guy is specially generated
Route::get('/sitemap.xml', function () {
    return Sitemap::generate();
});
// Any route that is otherwise not named will go to the PageController
// Route::match(['get', 'post'], '{one?}/{two?}/{three?}/{four?}/{five?}', 'SiteComponents\PageController@index');
// The PageController is going away since custom pages are going away.
// Instead, any route not otherwise named will look for a view of the
Ejemplo n.º 12
0
 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function __construct()
 {
     $this->middleware('auth');
     view()->share(array('description' => 'Another Test', 'keywords' => 'More, tests', 'locations' => Location::all()->sortBy('name'), 'models' => ['Analytics', 'Tools', 'Quotes', 'ContactUs', 'EmploymentApps', 'CreditApps', 'ChatLogs', 'User'], 'homepage' => HomePage::where('location_id', '=', Location::current()->id)->first(), 'colors' => Color::all(), 'profiles' => MetalProfile::all(), 'news' => NewsArticle::where('location_id', '=', Location::current()->id)->get(), 'pages' => Page::where('location_id', '=', Location::current()->id)->get()));
 }