Esempio n. 1
0
 private static function append_galleries()
 {
     $galleries = Gallery::all();
     foreach ($galleries as $gallery) {
         array_push(static::$allPages, ['loc' => URL::to('/galleries/' . $gallery->slug), 'mod' => $gallery->updated_at->toDateString(), 'freq' => 'weekly', 'pri' => '0.3']);
     }
 }
 private function processImage($image, $galleryName)
 {
     $gallery = null;
     if (!in_array($galleryName, $this->galleries)) {
         // Create gallery (or attempt to)
         $gallery = new Gallery();
         $gallery->name = $galleryName;
         $gallery->save();
         foreach ($this->locations as $location) {
             $locationGallery = new LocationGallery();
             $locationGallery->gallery()->associate($gallery);
             $locationGallery->location()->associate($location);
             $locationGallery->show = true;
             $locationGallery->save();
         }
         array_push($this->galleries, $galleryName);
     }
     if ($gallery == null) {
         $gallery = Gallery::where('name', $galleryName)->first();
     }
     // "Upload" the image
     $filename = substr($image, strrpos($image, '/') + 1);
     $imgExt = strtolower(substr($filename, strrpos($filename, '.') + 1));
     $imgMime = $imgExt == 'jpg' || $imgExt == 'jpeg' ? 'image/jpeg' : 'image/png';
     $fileSize = filesize($image);
     copy($image, $this->dirname . '/' . $filename);
     $file = new UploadedFile($this->dirname . '/' . $filename, $filename, $imgMime, $fileSize, null, true);
     $uploadedImage = ImageList::upload($file);
     // Attach the image to the gallery
     $gallery->images()->save($uploadedImage);
     $gallery->save();
 }
 public function attach()
 {
     $images = Request::input('images');
     $gallery = Request::input('gallery');
     foreach ($images as $image) {
         $galleryObj = Gallery::find($gallery);
         $galleryObj->images()->save(ImageList::find($image));
         $galleryObj->save();
     }
     return "success";
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     //
     $gallery = Gallery::find($id);
     // TODO: Smarter stuff
     $gallery->update(Request::all());
     $gallery->slug = preg_replace("/[^a-zA-Z0-9 ]+/", "", $gallery->name);
     $gallery->slug = str_replace(' ', '-', $gallery->slug);
     $gallery->slug = strtolower($gallery->slug);
     $gallery->save();
     if (Request::has('show')) {
         $locationGallery = LocationGallery::where('gallery_id', '=', $id)->where('location_id', '=', Location::current()->id)->first();
         $locationGallery->show = filter_var(Request::input('show'), FILTER_VALIDATE_BOOLEAN);
         $locationGallery->save();
     }
     return $gallery;
 }
Esempio n. 5
0
// We'll let the admin panel define its own routes instead of
// setting them all up here manually
Route::match(['get', 'post'], 'admin/{one?}/{two?}/{three?}/{four?}/{five?}', 'AdminController@router');
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
Route::get('images/{one?}/{two?}/{three?}/{four?}/{five?}', 'SiteComponents\\ImageController@loadImage');
// A few oddities
Route::get('/news/{article}', function ($article) {
    $viewing = NewsArticle::where('slug', $article)->first();
    return View::make('dynamic_pages.article')->with(['title' => $viewing->short_title, 'article' => $viewing]);
});
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);