<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class DriversDetail extends Model
{
    public static function getDetailByDid($did)
    {
        return DB::select("SELECT * FROM t_drivers_detail WHERE did = ? LIMIT 1;", [$did]);
    }

	public static function getDetailById($id)
    {
        return DB::select("SELECT * FROM t_drivers_detail WHERE id = ? LIMIT 1;", [$id]);
    }

    public static function addDetail($data)
    {
        $id = DB::table("t_drivers_detail")->insertGetId($data);
        return $id;
    }

    public static function updateDetailByDid($id, $data)
    {
        return DB::table("t_drivers_detail")->where("did", $id)->update($data);
    }

    public static function updateDetail($id, $data)
    {
        return DB::table("t_drivers_detail")->where("id", $id)->update($data);
    }

    public static function deleteDetail($id)
    {
        return DB::table("t_drivers_detail")->where("id", $id)->delete();
    }
}
