Commit c58bdbdc authored by Nicolas Widart's avatar Nicolas Widart

Adding removing file option

parent fc3f4e11
......@@ -88,11 +88,15 @@ class MediaController extends AdminBaseController
/**
* Remove the specified resource from storage.
*
* @param int $id
* @param File $file
* @internal param int $id
* @return Response
*/
public function destroy($id)
public function destroy(File $file)
{
//
$this->file->destroy($file);
Flash::success('File deleted');
return Redirect::route('dashboard.media.index');
}
}
......@@ -40,8 +40,8 @@ class MediaServiceProvider extends ServiceProvider
{
$this->app->bind(
'Modules\Media\Repositories\FileRepository',
function() {
return new EloquentFileRepository(new File);
function($app) {
return new EloquentFileRepository(new File, $app['filesystem.disk']);
}
);
}
......
......@@ -57,7 +57,7 @@ class EloquentFileRepository extends EloquentBaseRepository implements FileRepos
public function destroy($file)
{
$this->finder->delete(public_path() . $file->path);
$this->finder->delete('public/' . $file->path);
$file->delete();
}
......
......@@ -78,6 +78,30 @@
</div>
</div>
</div>
<?php if ($files): ?>
<?php foreach($files as $file): ?>
<!-- Modal -->
<div class="modal fade" id="confirmation-{{ $file->id }}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">{{ trans('core::core.modal.title') }}</h4>
</div>
<div class="modal-body">
{{ trans('core::core.modal.confirmation-message') }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('core::core.button.cancel') }}</button>
{!! Form::open(['route' => ['dashboard.media.destroy', $file->id], 'method' => 'delete', 'class' => 'pull-left']) !!}
<button type="submit" class="btn btn-danger btn-flat"><i class="glyphicon glyphicon-trash"></i> {{ trans('core::core.button.delete') }}</button>
{!! Form::close() !!}
</div>
</div>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
@stop
@section('scripts')
......
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