<?php
namespace App\Controllers\Admin;
use App\Controllers\BaseController;
use App\Models\KontakModel;

class Kontak extends BaseController {
    public function index() {
        $model = new KontakModel();
        $data = [
            'title'  => 'Manajemen Kontak Sekolah',
            'kontak' => $model->first()
        ];
        return view('admin/kontak/index', $data);
    }

    public function update() {
    $model = new \App\Models\KontakModel();
    $id = $this->request->getPost('id_kontak');
    $model->update($id, [
        'alamat'      => $this->request->getPost('alamat'),
        'email'       => $this->request->getPost('email'),
        'telepon'     => $this->request->getPost('telepon'),
        'instagram'   => $this->request->getPost('instagram'), // Ubah ini
        'maps_iframe' => $this->request->getPost('maps_iframe'),
    ]);
    return redirect()->to(base_url('admin/kontak'))->with('success', 'Kontak diperbarui.');
}
public function edit() {
    $model = new \App\Models\KontakModel();
    $data = [
        'title'  => 'Edit Info Kontak',
        'kontak' => $model->first()
    ];
    return view('admin/kontak/edit', $data);
}
}