<?php

namespace App\Controllers;

use App\Models\AnoModel;
use CodeIgniter\Controller;

class Ano extends Controller
{
    public function index()
    {
        $model = new AnoModel();
        $data['anos'] = $model->findAll();
        return view('anos/index', $data);
    }

    public function create()
    {
        return view('anos/create');
    }

    public function store()
    {
        $model = new AnoModel();
        $data = [
            'ano' => $this->request->getPost('ano'),
        ];
        $model->save($data);
        return redirect()->to('/anos');
    }

    public function delete($id)
    {
        $model = new AnoModel();
        $model->delete($id);
        return redirect()->to('/anos');
    }
}
