Example #1
0
 protected static function boot()
 {
     parent::boot();
     self::saving(function ($model) {
         // transaction ended in "saved" event
         // needed to make sure if search index version number is incremented it
         // takes effect at the same time that the rest of the media item is updated
         DB::beginTransaction();
         // assume that something has changed and force ths item to be reindexed
         $a = Show::with("playlists", "playlists.mediaItems")->find(intval($model->id));
         // $a may be null if this item is currently being created
         // when the item is being created pending_search_index_version defaults to 1
         // meaning the item will be indexed
         if (!is_null($a)) {
             // make sure get latest version number. The version in $model might have changed before the transaction started
             $currentPendingIndexVersion = intval($a->pending_search_index_version);
             $model->pending_search_index_version = $currentPendingIndexVersion + 1;
             // also force all playlists liked to this and media items in them to be reindexed
             // because media items and playlists contain show information in their indexes
             foreach ($a->playlists as $playlist) {
                 $playlist->pending_search_index_version += 1;
                 $playlist->save();
                 foreach ($playlist->mediaItems as $mediaItem) {
                     $mediaItem->pending_search_index_version += 1;
                     $mediaItem->save();
                 }
             }
         }
         return true;
     });
     self::saved(function ($model) {
         DB::commit();
     });
 }
Example #2
0
 protected static function boot()
 {
     parent::boot();
     self::saving(function ($model) {
         $sourceFileForeignKey = $model->sourceFile()->getForeignKey();
         $uploadPointForeignKey = $model->uploadPoint()->getForeignKey();
         if ($model->exists && $model->original["in_use"] && !$model->in_use && !$model->ready_for_delete) {
             throw new Exception("The file can only be marked in_use once.");
         } else {
             if ($model->exists && $model->original["ready_for_delete"]) {
                 throw new Exception("This file is pending deletion and can no longer be modified.");
             } else {
                 if (!$model->in_use && (!EloquentHelpers::getIsForeignNull($model->mediaItemVideoWithFile()) || !EloquentHelpers::getIsForeignNull($model->mediaItemWithCover()) || !EloquentHelpers::getIsForeignNull($model->mediaItemWithBanner()) || !EloquentHelpers::getIsForeignNull($model->mediaItemWithCoverArt()) || !EloquentHelpers::getIsForeignNull($model->playlistWithCover()) || !EloquentHelpers::getIsForeignNull($model->playlistWithBanner()) || !EloquentHelpers::getIsForeignNull($model->playlistWithCoverArt()))) {
                     throw new Exception("File must be marked as in use before it can belong to anything.");
                 } else {
                     if ($model->exists && $model->original[$sourceFileForeignKey] !== $model->{$sourceFileForeignKey} || !$model->exists && !is_null($model->{$sourceFileForeignKey})) {
                         throw new Exception("The source file should only be set externally.");
                     } else {
                         if ($model->exists && $model->original[$uploadPointForeignKey] !== $model->{$uploadPointForeignKey}) {
                             throw new Exception("The upload point can only be set on creation.");
                         }
                     }
                 }
             }
         }
         return true;
     });
 }
Example #3
0
 protected static function boot()
 {
     parent::boot();
     self::saving(function ($model) {
         if ($model->dvr_bridge_service_uri && !is_null($model->has_dvr)) {
             throw new Exception("has_dvr must be null if it's a dvr bridge service uri.");
         } else {
             if (!$model->dvr_bridge_service_uri && is_null($model->has_dvr)) {
                 throw new Exception("has_dvr must not be null if it's not a dvr bridge service uri.");
             }
         }
         return true;
     });
 }
Example #4
0
 protected static function boot()
 {
     parent::boot();
     self::creating(function ($model) {
         $model->original_session_id = $model->session_id;
         return true;
     });
     self::saving(function ($model) {
         if ($model->type !== "vod" && $model->type !== "live") {
             throw new Exception("Invalid type.");
         }
         return true;
     });
 }
Example #5
0
 public function getDates()
 {
     return array_merge(parent::getDates(), array('scheduled_publish_time', 'time_promoted'));
 }
Example #6
0
 public function getDates()
 {
     return array_merge(parent::getDates(), array('last_login_attempt'));
 }
 public function getDates()
 {
     return array_merge(parent::getDates(), array('end_time'));
 }
Example #8
0
 public function getDates()
 {
     return array_merge(parent::getDates(), array('time_recorded'));
 }