<?php

namespace App\Controllers\Frontend\User;

use App\Controllers\FrontendBaseController;
use App\Models\UserModel;

class Profile extends FrontendBaseController
{
    public $title = 'My Profile';
    public $menu = 'user';
    public $submenu = 'profile';

    public function index()
    {
        if (!function_exists('is_logged') || !is_logged()) {
            return redirect()->to(url('auth/otp') . '?redirect=' . urlencode(url('user/profile')));
        }
        $user = (new UserModel())->find((int) logged('id'));
        if (!$user) {
            return redirect()->to(url('/'));
        }
        return view('frontend/user/profile/index', ['user' => $user]);
    }
}
