Added Video
This commit is contained in:
60
app/Jobs/VideoDelete.php
Normal file
60
app/Jobs/VideoDelete.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Log;
|
||||
use App\Jobs\Job;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use App\Model\Video;
|
||||
|
||||
class VideoDelete extends Job implements ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue, SerializesModels;
|
||||
|
||||
private $video;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Video $video)
|
||||
{
|
||||
$this->video = $video;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if (! $this->video->remove)
|
||||
{
|
||||
Log::warning(sprintf('%s: NOT Deleting [%s] not marked for deletion',__METHOD__,$this->video->file_path()));
|
||||
exit;
|
||||
}
|
||||
|
||||
// Remove tags;
|
||||
if ($this->video->Tags->count())
|
||||
$this->video->Tags()->detach();
|
||||
|
||||
// Remove People;
|
||||
if ($this->video->People->count())
|
||||
$this->video->People()->detach();
|
||||
|
||||
// Make sure our parent is writable
|
||||
if (! is_writable(dirname($this->video->file_path())))
|
||||
Log::warning(sprintf('%s: NOT Deleting [%s] parent directory not writable',__METHOD__,$this->video->file_path()));
|
||||
|
||||
// Perform delete
|
||||
if (file_exists($this->video->file_path()))
|
||||
unlink($this->video->file_path());
|
||||
|
||||
Log::warning(sprintf('%s: Deleted [%s]',__METHOD__,$this->video->file_path()));
|
||||
$this->video->delete();
|
||||
}
|
||||
}
|
39
app/Jobs/VideoMove.php
Normal file
39
app/Jobs/VideoMove.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Log;
|
||||
use App\Jobs\Job;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use App\Model\Video;
|
||||
use Artisan;
|
||||
|
||||
class VideoMove extends Job implements ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue, SerializesModels;
|
||||
|
||||
private $video;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Video $video)
|
||||
{
|
||||
$this->video = $video;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Log::info(sprintf('%s: Moving [%s]',__METHOD__,$this->video->id));
|
||||
Artisan::call('video:move',['--id' => $this->video->id]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user