Example #1
0
 /**
  * @name make
  *
  * Create new gallery from scratch
  * 
  * @param string $type [optional] - Type of the gallery that is created
  * @return bool|array - returns Eloquent model of gallery or FALSE if there was an error
  * @static
  */
 public static function make($type = self::DEFAULT_TYPE)
 {
     $gallery_params = array('type' => $type, 'status' => 'publish', 'name' => '', 'description' => '');
     $gallery = new GalleryModel();
     $gallery->fill($gallery_params);
     try {
         DB::beginTransaction();
         if (!$gallery->save()) {
             DB::rollBack();
             $this->errors[] = 'Failed to create Gallery';
             return false;
         }
         DB::commit();
         return $gallery;
     } catch (PDOException $e) {
         DB::rollBack();
         $this->errors[] = 'Fatal error' . $e->message;
         return false;
     }
 }