<?php

namespace App\Http\Controllers\Admin\Botanic;

use App\Datatables\Botanic\GenresDataTable;
use App\Repositories\Botanic\Families;
use App\Repositories\Botanic\Genres;
use Illuminate\Http\Request;

class GenreController extends Controller
{
    public function index(GenresDataTable $dataTable)
    {
        return $dataTable->render('Admin.Botanic.Genres.list');
    }

    public function getDatatable(Request $request)
    {
        return Genres::getDataTable($request->all());
    }

    public function create()
    {
        $data['families'] = Families::getOptions();

        return view('Admin.Botanic.Genres.create', $data);
    }

    public function store(Request $request)
    {
        $data = $request->all();
        $ret = Genres::store($data);

        return redirect()->route('Admin.Botanic.Genres.index');
    }

    public function show($id)
    {
        $data['genre'] = Genres::get($id);

        return view('Admin.Botanic.Genres.view', $data);
    }

    public function edit($id)
    {
        $data['genre'] = Genres::get($id);
        $data['families'] = Families::getOptions();

        return view('Admin.Botanic.Genres.edit', $data);
    }

    public function destroy($id)
    {
        return Genres::destroy($id);
    }

    public function exportExcel()
    {
        return Genres::exportExcel();
    }
}
