Skip to content

Commit

Permalink
Merge branch 'development' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
orkit committed May 6, 2024
2 parents f339d50 + 5750cee commit e2943c3
Showing 1 changed file with 1 addition and 61 deletions.
62 changes: 1 addition & 61 deletions app/Services/Stream/StreamsStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,11 @@

namespace App\Services\Stream;

use App\ManualPresentation;
use App\Stream;
use App\StreamResolution;
use Illuminate\Database\Eloquent\Model;

class StreamsStore extends Model
{
protected $streams, $video;

public function __construct($request, $video)
{
$this->streams = $request->input('package.sources');
$this->video = $video;
}

public function streams()
{
//Check if presentation has been edited override source setting
if(!$presentation = ManualPresentation::where('pkg_id', $this->video->id)->where('type', 'edit')->where(function($query) {
$query->where('status', 'sent')->orWhere('status', 'completed');})->latest()->first()) {
if(count($this->streams) > 0) {
foreach ($this->streams as $key => $source) {
if ($source) {
$stream = Stream::updateOrCreate([
'video_id' => $this->video->id, 'name' => $key ?? ''],
[
'poster' => $source['poster'] ?? '',
'audio' => $source['playAudio'] ?? false
]);

if($source['video'] ?? false) {
foreach ($source['video'] as $resolution => $url) {
$streamresolution = StreamResolution::updateOrCreate(
[
'stream_id' => $stream->id,
'resolution' => $resolution
],
[
'filename' => $url
]
);
}
}
} //end check
} // end foreach

} else {
//Remove any old associations
$streams = Stream::where('video_id', $this->video->id)->get();
foreach ($streams as $stream) {
StreamResolution::where('stream_id', $stream->id)->delete();
$stream->delete();
}
}
} //end presentation edit
}

}

/***
* Updated class
* Backend handles hidden streams
*/

/*class StreamsStore extends Model
{
protected $video;

Expand Down Expand Up @@ -116,4 +56,4 @@ protected function deleteAllStreams()
{
$this->video->streams()->delete();
}
}*/
}

0 comments on commit e2943c3

Please sign in to comment.