<?php

namespace App\Http\Controllers\Admin\Botanic;

use Illuminate\Http\Request;

use App\Repositories\Botanic\Families;
use App\Datatables\Botanic\FamiliesDataTable;

class FamilyController extends Controller
{
    public function index(FamiliesDataTable $dataTable)
    {
        return $dataTable->render('Admin.Botanic.Families.list');
    }

    public function create()
    {
        return view('Admin.Botanic.Families.create', $data ?? []);
    }

    public function store(Request $request)
    {
        $data = $request->all();
        $ret = Families::store($data);
        return redirect()->route('Admin.Botanic.Families.index');
    }

    public function show($id)
    {
        $data = Families::get($id);
        return view('Admin.Botanic.Families.view', $data);
    }

    public function edit($id)
    {
        $data['family'] = Families::get($id)->toArray();
        return view('Admin.Botanic.Families.edit', $data);
    }

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

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