MediaController.php
555 Bytes
<?php
namespace App\Http\Controllers;
use App\Models\Media;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
class MediaController extends Controller
{
public function index() {
$Media = Media::query()->OrderBy('id', 'desc')->paginate();
return view('admin.media.index', compact('Media'));
}
public function delete(Media $media) {
if (!empty($media->file)){
Storage::delete($media->file);
}
$media->delete();
return redirect()->route('admin.media');
}
}