Added delete and removed Kohana
This commit is contained in:
58
app/Jobs/PhotoDelete.php
Normal file
58
app/Jobs/PhotoDelete.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?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\Photo;
|
||||
|
||||
class PhotoDelete extends Job implements ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue, SerializesModels;
|
||||
|
||||
private $photo;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Photo $photo)
|
||||
{
|
||||
$this->photo = $photo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if (! $this->photo->remove)
|
||||
{
|
||||
Log::warning(__METHOD__.' NOT Deleting: '.$this->photo->file_path().', not marked for deletion');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Remove tags;
|
||||
// @todo
|
||||
|
||||
// Remove People;
|
||||
// @todo
|
||||
|
||||
// Make sure our parent is writable
|
||||
if (! is_writable(dirname($this->photo->file_path())))
|
||||
Log::warning(__METHOD__.' NOT Deleting: '.$this->photo->file_path().', parent directory not writable');
|
||||
|
||||
// Perform delete
|
||||
if (file_exists($this->photo->file_path()))
|
||||
unlink($this->photo->file_path());
|
||||
|
||||
Log::info(sprintf('%s: Deleted (%s): %s',__METHOD__,$this->photo->id,$this->photo->file_path()));
|
||||
$this->photo->delete();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user