Attachment file update

This commit is contained in:
cuneytsenturk
2017-12-29 19:56:56 +03:00
parent 94b7e9ec64
commit 3e04f1295b
7 changed files with 66 additions and 5 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Common;
use App\Http\Controllers\Controller;
use App\Models\Common\Media;
use Storage;
class Uploads extends Controller
@@ -41,6 +42,31 @@ class Uploads extends Controller
return response()->download($path);
}
/**
* Destroy the specified resource.
*
* @param $folder
* @param $file
* @return callable
*/
public function destroy($folder, $id)
{
$media = Media::find($id);
// Get file path
/*if (!$path = $this->getPath($folder, $id)) {
$message = trans('messages.warning.deleted', ['name' => $file, 'text' => $file]);
flash($message)->warning();
return back();
}*/
$media->delete(); //will not delete files
return back();
}
/**
* Get the full path of resource.
*

View File

@@ -0,0 +1,14 @@
<?php
namespace App\Models\Common;
use Illuminate\Database\Eloquent\SoftDeletes;
use Plank\Mediable\Media as PMedia;
class Media extends PMedia
{
use SoftDeletes;
protected $dates = ['deleted_at'];
}

View File

@@ -150,6 +150,6 @@ class Invoice extends Model
return false;
}
return $this->getMedia('attachment')->first();
return $this->getMedia('attachment')->last();
}
}