Blame view

app/Http/Controllers/MediaController.php 555 Bytes
9b4580039   Андрей Ларионов   Медиа сущность, д...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  <?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');
      }
  }