public function run() { $this->dirname = dirname(__FILE__); $this->imageDir = $this->dirname . '/gallery_images'; $this->locations = Location::all(); $this->galleries = ['Residential Roofing', 'Commercial and Personal', 'Econo Buildings', 'Churches', 'Pole Barns', 'Carports and Awnings']; foreach ($this->galleries as $galleryName) { // Create gallery (or attempt to) $gallery = new Gallery(); $gallery->name = $galleryName; $gallery->slug = preg_replace("/[^a-zA-Z0-9 ]+/", "", $gallery->name); $gallery->slug = str_replace(' ', '-', $gallery->slug); $gallery->slug = strtolower($gallery->slug); $gallery->save(); // Save it to every location foreach ($this->locations as $location) { $locationGallery = new LocationGallery(); $locationGallery->gallery()->associate($gallery); $locationGallery->location()->associate($location); $locationGallery->show = true; $locationGallery->save(); } } $this->recurseDir($this->imageDir, ''); }
private static function append_locations() { $locations = Location::all(); foreach ($locations as $location) { array_push(static::$allPages, ['loc' => URL::to('/locations/' . strtolower(str_replace(' ', '-', $location->name))), 'mod' => $location->updated_at->toDateString(), 'freq' => 'monthly', 'pri' => '0.9']); } }
public function run() { $forms = ['App\\Models\\Forms\\BuildingQuote:Rigid Frame', 'App\\Models\\Forms\\BuildingQuote:Galv-Econ', 'App\\Models\\Forms\\BuildingQuote:Pole Barn', 'App\\Models\\Forms\\BuildingQuote:Roof', 'App\\Models\\Forms\\ContactForm', 'App\\Models\\Forms\\EmploymentApp', 'App\\Models\\Forms\\CreditApp']; foreach (Location::all() as $location) { foreach ($forms as $form) { $formRotation = FormRotation::create(['location_id' => $location->id, 'form' => $form, 'current' => 0]); } } }
public function run() { DB::table('menus')->delete(); DB::table('pages')->delete(); $this->dirname = dirname(__FILE__); $this->pageDir = $this->dirname . '/pages'; $this->pageImageDir = $this->dirname . '/'; $this->locations = Location::all(); $this->recurseDir($this->pageDir, ''); }
public function run() { DB::table('testimonials')->delete(); $testimonials = [["quote" => "Great job on the steel roofing order. I've saved nearly as much on electric bills as the materials cost. My electric bill was \$235 before, the next month it was \$137. Looks great! Thanks!", "author" => "L. Adams"], ["quote" => "This is a sample quote to test the swapping out of different quotes using JavaScript", "author" => "Steven Barnett"], ["quote" => "Reed's Metals is coooooooooooool", "author" => "Stephanie Barnett"]]; $locations = Location::all(); foreach ($testimonials as $testimonial) { foreach ($locations as $location) { $newTestimonial = new Testimonial(['quote' => $testimonial['quote'], 'author' => $testimonial['author']]); $newTestimonial->location()->associate($location); $newTestimonial->save(); } } }
public function run() { $profiles = ['Residential' => ['coverage' => 36], 'PBR' => ['coverage' => 36], 'Secure-Seam Standing Seam' => ['coverage' => 18], 'Perma-Lok Standing Seam' => ['coverage' => 16], '5-V' => ['coverage' => 24], 'Corrugated' => ['coverage' => 24], 'MECH-SEAM' => ['coverage' => 16]]; $dirname = dirname(__FILE__); foreach ($profiles as $profileName => $profileInfo) { if (MetalProfile::where('name', '=', $profileName)->first()) { continue; } /* // Upload profile image copy( $dirname . "/default_images/colors/" . $colorInfo['image'], $dirname . "/" . $colorInfo['image'] ); $file = new UploadedFile( $dirname . "/" . $colorInfo['image'], // path $colorInfo['image'], // originalName "image/png", // mimeType filesize( $dirname . "/" . $colorInfo['image'] ), // size null, // error true // test ); $profileImage = ImageList::upload( $file ); // Upload overhead image copy( $dirname . "/default_images/colors/" . $colorInfo['image'], $dirname . "/" . $colorInfo['image'] ); $file = new UploadedFile( $dirname . "/" . $colorInfo['image'], // path $colorInfo['image'], // originalName "image/png", // mimeType filesize( $dirname . "/" . $colorInfo['image'] ), // size null, // error true // test ); $overheadImage = ImageList::upload( $file ); */ $profile = MetalProfile::firstOrCreate(['name' => $profileName, 'coverage' => $profileInfo['coverage']]); $profile->save(); foreach (Location::all() as $location) { foreach (Gauge::all() as $gauge) { $locationProfileGauge = new LocationProfileGauge(); $locationProfileGauge->location()->associate($location); $locationProfileGauge->metalProfile()->associate($profile); $locationProfileGauge->gauge()->associate($gauge); $locationProfileGauge->save(); } } } }
/** * 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); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // $gallery = new Gallery(); $gallery->name = Request::input('name'); $gallery->slug = preg_replace("/[^a-zA-Z0-9 ]+/", "", $gallery->name); $gallery->slug = str_replace(' ', '-', $gallery->slug); $gallery->slug = strtolower($gallery->slug); $gallery->save(); $locations = Location::all(); $current = Location::current(); foreach ($locations as $location) { $locationGallery = new LocationGallery(); $locationGallery->gallery()->associate($gallery); $locationGallery->location()->associate($location); if ($location == $current) { $locationGallery->show = true; } $locationGallery->save(); } return $gallery; }
public function run() { $colors = ['Galvalume' => ['hex' => 'cad0d2', 'image' => 'galvalume.png'], 'Pure White' => ['hex' => 'eceaee'], 'Polar White' => ['hex' => 'f0f2f3'], 'Ivory' => ['hex' => 'f8e5c6'], 'Light Stone' => ['hex' => 'cccab2'], 'Mocha Tan' => ['hex' => 'b1946f'], 'Patina Green' => ['hex' => '6c7f56'], 'Marine Green' => ['hex' => '5b9994'], 'Forest Green' => ['hex' => '10411e'], 'Hawaiian Blue' => ['hex' => '426d7e'], 'Gallery Blue' => ['hex' => '073e60'], 'Barn Red' => ['hex' => '6e1f19'], 'Patriot Red' => ['hex' => '8c181b'], 'Burgundy' => ['hex' => '512127'], 'Cocoa Brown' => ['hex' => '513d30'], 'Metallic Copper' => ['hex' => 'b15726'], 'Galvanized Silver' => ['hex' => 'afafb1', 'image' => 'galvanized_silver.png'], 'Old Town Gray' => ['hex' => '898b8e'], 'Clay' => ['hex' => '979888'], 'Charcoal Gray' => ['hex' => '565656'], 'Burnished Slate' => ['hex' => '342019'], 'Black' => ['hex' => '030303'], 'Ash Gray' => ['hex' => 'aca1a1'], 'Evergreen' => ['hex' => '394f46']]; $dirname = dirname(__FILE__); foreach ($colors as $colorName => $colorInfo) { if (Color::where('name', '=', $colorName)->first()) { continue; } if (empty($colorInfo['hex'])) { // Nothing we can do (yet) continue; } // Upload image, if exists $colorImage = null; if (isset($colorInfo['image'])) { copy($dirname . "/default_images/colors/" . $colorInfo['image'], $dirname . "/" . $colorInfo['image']); $file = new UploadedFile($dirname . "/" . $colorInfo['image'], $colorInfo['image'], "image/png", filesize($dirname . "/" . $colorInfo['image']), null, true); $colorImage = ImageList::upload($file); } $redHex = substr($colorInfo['hex'], 0, 2); $greenHex = substr($colorInfo['hex'], 2, 2); $blueHex = substr($colorInfo['hex'], 4, 2); $color = Color::firstOrCreate(['name' => $colorName, 'red' => hexdec($redHex), 'green' => hexdec($greenHex), 'blue' => hexdec($blueHex)]); $color->save(); if ($colorImage != null) { $color->image()->save($colorImage); } foreach (Location::all() as $location) { foreach (Gauge::all() as $gauge) { $locationColorGauge = new LocationColorGauge(); $locationColorGauge->location()->associate($location); $locationColorGauge->color()->associate($color); $locationColorGauge->gauge()->associate($gauge); $locationColorGauge->save(); } } } }
public function run() { DB::table('form_settings')->delete(); $alwaysCopy = ['*****@*****.**', '*****@*****.**']; $perLocationCopy = ['Brookhaven' => ['BuildingQuote:Rigid Frame' => ['*****@*****.**'], 'BuildingQuote:Galv-Econ' => ['*****@*****.**'], 'BuildingQuote:Pole Barn' => ['*****@*****.**'], 'BuildingQuote:Roof' => [], 'ContactForm' => [], 'EmploymentApp' => [], 'CreditApp' => []], 'Tupelo' => ['BuildingQuote:Rigid Frame' => ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'], 'BuildingQuote:Galv-Econ' => ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'], 'BuildingQuote:Pole Barn' => ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'], 'BuildingQuote:Roof' => ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'], 'ContactForm' => [], 'EmploymentApp' => [], 'CreditApp' => []], 'Lake Charles' => ['BuildingQuote:Rigid Frame' => ['*****@*****.**', '*****@*****.**'], 'BuildingQuote:Galv-Econ' => ['*****@*****.**', '*****@*****.**'], 'BuildingQuote:Pole Barn' => ['*****@*****.**', '*****@*****.**'], 'BuildingQuote:Roof' => [], 'ContactForm' => [], 'EmploymentApp' => [], 'CreditApp' => []], 'Benton' => ['BuildingQuote:Rigid Frame' => ['*****@*****.**', '*****@*****.**'], 'BuildingQuote:Galv-Econ' => ['*****@*****.**', '*****@*****.**'], 'BuildingQuote:Pole Barn' => ['*****@*****.**', '*****@*****.**'], 'BuildingQuote:Roof' => [], 'ContactForm' => [], 'EmploymentApp' => [], 'CreditApp' => []], 'Jackson' => ['BuildingQuote:Rigid Frame' => ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'], 'BuildingQuote:Galv-Econ' => ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'], 'BuildingQuote:Pole Barn' => ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'], 'BuildingQuote:Roof' => ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'], 'ContactForm' => [], 'EmploymentApp' => [], 'CreditApp' => []]]; $locations = Location::all(); $rigidFrameRole = Role::where('name', 'RigidFrameSales')->first(); $galvEconRole = Role::where('name', 'GalvEconSales')->first(); $poleBarnRole = Role::where('name', 'PoleBarnSales')->first(); $roofingRole = Role::where('name', 'RoofingSales')->first(); $contactRole = Role::where('name', 'GeneralManager')->first(); $employeeRole = Role::where('name', 'HR')->first(); foreach ($locations as $location) { $rigidFrameBuildingQuoteSettings = new FormSettings(); $rigidFrameBuildingQuoteSettings->model = 'App\\Models\\Forms\\BuildingQuote:Rigid Frame'; $rigidFrameBuildingQuoteSettings->rotation()->associate($rigidFrameRole); $location->formSettings()->save($rigidFrameBuildingQuoteSettings); $galvEconBuildingQuoteSettings = new FormSettings(); $galvEconBuildingQuoteSettings->model = 'App\\Models\\Forms\\BuildingQuote:Galv-Econ'; $galvEconBuildingQuoteSettings->rotation()->associate($galvEconRole); $location->formSettings()->save($galvEconBuildingQuoteSettings); $poleBarnBuildingQuoteSettings = new FormSettings(); $poleBarnBuildingQuoteSettings->model = 'App\\Models\\Forms\\BuildingQuote:Pole Barn'; $poleBarnBuildingQuoteSettings->rotation()->associate($poleBarnRole); $location->formSettings()->save($poleBarnBuildingQuoteSettings); $roofBuildingQuoteSettings = new FormSettings(); $roofBuildingQuoteSettings->model = 'App\\Models\\Forms\\BuildingQuote:Roof'; $roofBuildingQuoteSettings->rotation()->associate($roofingRole); $location->formSettings()->save($roofBuildingQuoteSettings); $contactFormSettings = new FormSettings(); $contactFormSettings->model = 'App\\Models\\Forms\\ContactForm'; $contactFormSettings->rotation()->associate($contactRole); $location->formSettings()->save($contactFormSettings); $employmentAppSettings = new FormSettings(); $employmentAppSettings->model = 'App\\Models\\Forms\\EmploymentApp'; $employmentAppSettings->rotation()->associate($employeeRole); $location->formSettings()->save($employmentAppSettings); $creditAppSettings = new FormSettings(); $creditAppSettings->model = 'App\\Models\\Forms\\CreditApp'; $creditAppSettings->rotation()->associate($contactRole); $location->formSettings()->save($creditAppSettings); $rigidFrameBuildingQuoteSettings->save(); $galvEconBuildingQuoteSettings->save(); $poleBarnBuildingQuoteSettings->save(); $roofBuildingQuoteSettings->save(); $contactFormSettings->save(); $employmentAppSettings->save(); $creditAppSettings->save(); $settingsArr = [$rigidFrameBuildingQuoteSettings, $galvEconBuildingQuoteSettings, $poleBarnBuildingQuoteSettings, $roofBuildingQuoteSettings, $contactFormSettings, $employmentAppSettings, $creditAppSettings]; if ($location->parent) { $location = $location->parent; } foreach ($perLocationCopy[$location->name] as $key => $value) { foreach ($value as $recipient) { $formRecipient = new FormRecipient(); if ($person = Person::where('email', $recipient)->first()) { $employee = Employee::whereIs($person); if ($employee != null) { $formRecipient->employee()->associate(Employee::whereIs($person)); } } else { $formRecipient->email = $recipient; } $formRecipient->save(); foreach ($settingsArr as $settings) { if (strpos($settings->model, $key) !== false) { $settings->copyTo()->save($formRecipient); break; } } } } foreach ($alwaysCopy as $recipient) { $formRecipient = new FormRecipient(); if ($person = Person::where('email', $recipient)->first()) { $employee = Employee::whereIs($person); if ($employee != null) { $formRecipient->employee()->associate(Employee::whereIs($person)); } } else { $formRecipient->email = $recipient; } $formRecipient->save(); foreach ($settingsArr as $settings) { $settings->copyTo()->save($formRecipient); } } } }
public static function setCurrent($latitude, $longitude) { $locations = Location::all(); $geoLocation = [$latitude, $longitude]; $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; } } session()->put('location', $location); if ($location != null && Request::user()) { Request::user()->location = $location->id; Request::user()->save(); } }
/** * Display a listing of the resource. * * @return Response */ public function index() { // return Location::all(); }
/** * 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())); }
<?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"> </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>