public function createNewExhibit($isPublic, $isFeatured, $title, $description, $credits, $slug = '')
 {
     $exhibit = new Exhibit();
     $exhibit->public = $isPublic ? 1 : 0;
     $exhibit->featured = $isFeatured ? 1 : 0;
     $exhibit->title = $title;
     $exhibit->description = $description;
     $exhibit->credits = $credits;
     if ($slug != '') {
         $exhibit->slug = $slug;
     }
     $exhibit->save();
     return $exhibit;
 }
Example #2
0
 public static function addMedia($fileName, $objType, $user_id, $route)
 {
     $file = Input::file($fileName);
     $currentMo = date('Y_M');
     $destination = "uploads/{$currentMo}";
     $filename = $file->getClientOriginalName();
     $filename = Exhibit::string_convert($filename);
     // $cleanFilename = Exhibit::permalink($filename);
     // Move the new file into the uploads directory
     $uploadSuccess = $file->move($destination, "{$filename}");
     $imgOrigDestination = $destination . '/' . $filename;
     // Check to make sure that upload was successful and add the content
     if ($uploadSuccess) {
         $imageMinDestination = $destination . '/min_' . $filename;
         $imageMin = Image::make($imgOrigDestination)->crop(250, 250, 10, 10)->save($imageMinDestination);
         // Saves the media and adds the appropriate foreign keys for the exhibit
         $media = $objType->media()->create(['user_id' => $user_id, 'img_min' => $imageMinDestination, 'img_big' => $imgOrigDestination]);
         $objType->media()->save($media);
         return $media->id;
     } else {
         if ($route == 'back') {
             return Redirect::back()->with('status', 'alert-error')->with('global', 'Something went wrong with uploading your photos.');
         }
         return Redirect::route($route)->with('status', 'alert-error')->with('global', 'Something went wrong with uploading your photos.');
     }
 }
 public function postUpdateMediaIDsOrder()
 {
     // Find and process media Ids
     $exhibit = Exhibit::find(Input::get('ex_id'));
     $exhibit->update(array('media_ids' => json_encode(Input::get('media_ids'))));
     $exhibit->save();
     return Response::json(array('media_ids' => $exhibit->media_ids));
 }
 /**
  * Create an exhibit.
  *
  * @param boolean $public True if the exhibit is public.
  * @param string $title The exhibit title.
  * @param string $slug The exhibit slug.
  * @return Exhibit
  */
 protected function _exhibit($public = true, $title = 'Test Title', $slug = 'test-slug')
 {
     $exhibit = new Exhibit();
     $exhibit->public = $public;
     $exhibit->slug = $slug;
     $exhibit->title = $title;
     $exhibit->save();
     return $exhibit;
 }
 public function exhibitAddEmpty()
 {
     $exhibit = Exhibit::create(array('published' => false, 'autodraft' => true));
     return Response::json(array('success' => true, 'id' => $exhibit->id));
 }