<?php

namespace Modules\Docs\Http\Controllers;

use Modules\Docs\Models\Document;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
class DocsController extends Controller
{
    public function index()
    {
        $docs = Document::orderBy('name')->get();
        return view('docs::index', [
            'docs' => $docs
        ]);
    }
    public function download(Document $document)
    {
        $ext = explode('.', $document->path);
        $ext = end($ext);
        return Storage::download($document->path, $document->name . '.' . $ext);
    }
}