<?php

namespace App\Models;

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

class OrdersPckDrop extends Model
{
    // stts_delivery
	const STTS_DELIVERY_OTW_PICKUP = 1;
    const STTS_DELIVERY_ARRIVED_PICKUP = 2;
    const STTS_DELIVERY_PROCESS_PICKUP = 3;
    const STTS_DELIVERY_FINISH_PICKUP = 4;
    const STTS_DELIVERY_TRAVEL_DOC = 5;
    const STTS_DELIVERY_OTW_DROP = 6;
    const STTS_DELIVERY_ARRIVED_DROP = 7;
    const STTS_DELIVERY_PROCESS_DROP = 8;
    const STTS_DELIVERY_FINISH_DROP = 9;
    const STTS_DELIVERY_HANDOVER_DOC = 10;

    const IS_APRV_NO = 0;
    const IS_APRV_YES = 1;

    public static function get()
    {
        return DB::select("SELECT * FROM t_orders_pck_drop;");
    }

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

    public static function getByOrdCode($code)
    {
        return DB::select("SELECT * FROM t_orders_pck_drop WHERE ord_code = ? LIMIT 1;", [$code]);
    }

	public static function getByOrdId($ordid)
    {
        return DB::select("SELECT * FROM t_orders_pck_drop WHERE ord_id = ? LIMIT 1;", [$ordid]);
    }

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

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

    public static function updtByOrdId($ord_id, $data)
    {
        return DB::table("t_orders_pck_drop")->where("ord_id", $ord_id)->update($data);
    }

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

    public static function dltByOrdId($ord_id)
    {
        return DB::table("t_orders_pck_drop")->where("ord_id", $ord_id)->delete();
    }
}
