<?php

namespace App\Models;

use CodeIgniter\Model;
use CodeIgniter\I18n\Time;

class Md_laptop extends Model {
    
    public $db;

    public function __construct() {
        parent::__construct();
        $this->mvpm = \Config\Database::connect('mvpm');
    }
    
    
 public function PendingStd($userid) {

        $notifications = $this->mvpm
                ->table('mvpm_laptop')
                ->select('*')
                ->where('assign_id', $userid)
                ->where('assign_status',1)
                ->orderby('pk_id', 'DESC')
                ->get()
                ->getResult('array');
                
        return $notifications;
    }
    
     public function ConfirmStd($userid) {

        $notifications = $this->mvpm
                ->table('mvpm_laptop')
                ->select('*')
                ->where('assign_id', $userid)
                ->where('assign_status',2)
                ->orderby('pk_id', 'DESC')
                ->get()
                ->getResult('array');
                
        return $notifications;
    }
    
     public function RejectedStd($userid) {

        $notifications = $this->mvpm
                ->table('mvpm_laptop')
                ->select('*')
                ->where('assign_id', $userid)
                ->where('assign_status',3)
                ->orderby('pk_id', 'DESC')
                ->get()
                ->getResult('array');
                
        return $notifications;
    }
    
     public function StudentDetails($studentid) {

        $notifications = $this->mvpm
                ->table('mvpm_laptop')
                ->select('*')
                ->where('pk_id', $studentid)
                ->get()
                ->getRow();
                
        return $notifications;
    }

   public function UpdateData($table, $condition, $data) {
        $this->mvpm->table($table)->update($data, $condition);
        return $this->db->affectedRows();
    }

}