<?php

namespace App\Controllers\Mobile\Utils;

use App\Controllers\Mobile\BC;
use CodeIgniter\API\ResponseTrait;

class LogActivity extends BC
{
    use ResponseTrait;
    public function index()
    {
        if (!$this->request->isAJAX() && ENVIRONMENT != 'development') {
            exit('No direct script access allowed');
        }
        $builder = db_connect()->table('log_activity');
        $builder->where(['user_id' => user()->id, 'user_type' => 2]);
        $sd = date('Y-m-d 00:00:01');
        $ed = date('Y-m-d 23:59:59');
        $builder->where("created_at BETWEEN '{$sd}' AND '{$ed}'", null, false);
        $builder->orderBy('created_at', 'DESC');
        $data = $builder->get(5)->getResultArray();
        return $this->respond($data);
    }
}
