Commit fc3f4e11 authored by Nicolas Widart's avatar Nicolas Widart

Preparing the file delete

parent 2f3d1e5d
<?php namespace Modules\Media\Repositories\Eloquent;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Database\Eloquent\Model;
use Modules\Core\Internationalisation\Helper;
use Modules\Core\Repositories\Eloquent\EloquentBaseRepository;
use Modules\Media\Entities\File;
......@@ -9,6 +11,18 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
class EloquentFileRepository extends EloquentBaseRepository implements FileRepository
{
/**
* @var Filesystem
*/
private $finder;
public function __construct(Model $model, Filesystem $finder)
{
parent::__construct($model);
$this->finder = $finder;
}
/**
* Update a resource
* @param File $file
......@@ -40,4 +54,11 @@ class EloquentFileRepository extends EloquentBaseRepository implements FileRepos
'filesize' => $file->getFileInfo()->getSize(),
]);
}
public function destroy($file)
{
$this->finder->delete(public_path() . $file->path);
$file->delete();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment