<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class CertificateController extends Controller
{
    public function index(Request $request)
    {
        $size = $request->get('size', 20);
        $certificates = DB::table('certificates')->orderByDesc('id')->paginate($size);
        $certificate = null;
        $message = session('message');
        return view('certificate.index', compact('certificates', 'certificate', 'message', 'size'));
    }

    public function create()
    {
        return view('certificate.create');
    }

    public function store(Request $request)
    {
        return redirect()->route('certificates.index');
    }

    public function show($id)
    {
        $certificate = DB::table('certificates')->find($id);
        return view('certificate.show', compact('certificate'));
    }

    public function edit($id)
    {
        $certificate = DB::table('certificates')->find($id);
        return view('certificate.edit', compact('certificate'));
    }

    public function update(Request $request, $id)
    {
        return redirect()->route('certificates.index');
    }

    public function destroy($id)
    {
        return redirect()->route('certificates.index');
    }
}
