112 lines
2.9 KiB
PHP
Executable File
112 lines
2.9 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class OrdersDriversUploads extends Model
|
|
{
|
|
const STTS_UP_OTW_PICKUP = 1;
|
|
const STTS_UP_ARRIVED_PICKUP = 2;
|
|
const STTS_UP_PROCESS_PICKUP = 3;
|
|
const STTS_UP_FINISH_PICKUP = 4;
|
|
const STTS_UP_TRAVEL_DOCUMENT = 5;
|
|
const STTS_UP_OTW_DROP = 6;
|
|
const STTS_UP_ARRIVED_DROP = 7;
|
|
const STTS_UP_PROCESS_DROP = 8;
|
|
const STTS_UP_FINISH_DROP = 9;
|
|
const STTS_UP_HANDOVER_DOCUMENT = 10;
|
|
const STTS_UP_ACCIDENT = 11;
|
|
|
|
const IS_INACTIVE = 0;
|
|
const IS_ACTIVE = 1;
|
|
|
|
public static function list($filter = [])
|
|
{
|
|
$params = [];
|
|
$select = '';
|
|
$where = '';
|
|
$join = '';
|
|
$limit = '';
|
|
|
|
if (isset($filter['id'])) {
|
|
$where .= ' AND drv_up.id = ?';
|
|
$params[] = $filter['id'];
|
|
}
|
|
if (isset($filter['ord_id'])) {
|
|
$where .= ' AND drv_up.ord_id = ?';
|
|
$params[] = $filter['ord_id'];
|
|
}
|
|
if (isset($filter['ord_code'])) {
|
|
$where .= ' AND drv_up.ord_code = ?';
|
|
$params[] = $filter['ord_code'];
|
|
}
|
|
if (isset($filter['did'])) {
|
|
$where .= ' AND drv_up.did = ?';
|
|
$params[] = $filter['did'];
|
|
}
|
|
if (isset($filter['pck_id'])) {
|
|
$where .= ' AND drv_up.pck_id = ?';
|
|
$params[] = $filter['pck_id'];
|
|
}
|
|
if (isset($filter['drop_id'])) {
|
|
$where .= ' AND drv_up.drop_id = ?';
|
|
$params[] = $filter['drop_id'];
|
|
}
|
|
if (isset($filter['ord_pck_drop_id'])) {
|
|
$where .= ' AND drv_up.ord_pck_drop_id = ?';
|
|
$params[] = $filter['ord_pck_drop_id'];
|
|
}
|
|
|
|
$query = "SELECT drv_up.* $select FROM t_orders_drivers_uploads as drv_up $join WHERE drv_up.dlt is null $where $limit;";
|
|
return DB::select($query, $params);
|
|
}
|
|
|
|
public static function get()
|
|
{
|
|
return DB::select("SELECT * FROM t_orders_drivers_uploads;");
|
|
}
|
|
|
|
public static function getById($id)
|
|
{
|
|
return DB::select("SELECT * FROM t_orders_drivers_uploads WHERE id = ? LIMIT 1;", [$id]);
|
|
}
|
|
|
|
public static function getByOrdCode($code)
|
|
{
|
|
return DB::select("SELECT * FROM t_orders_drivers_uploads WHERE ord_code = ? LIMIT 1;", [$code]);
|
|
}
|
|
|
|
public static function getByOrdId($ordid)
|
|
{
|
|
return DB::select("SELECT * FROM t_orders_drivers_uploads WHERE ord_id = ? LIMIT 1;", [$ordid]);
|
|
}
|
|
|
|
public static function add($data)
|
|
{
|
|
$id = DB::table("t_orders_drivers_uploads")->insertGetId($data);
|
|
return $id;
|
|
}
|
|
|
|
public static function updt($id, $data)
|
|
{
|
|
return DB::table("t_orders_drivers_uploads")->where("id", $id)->update($data);
|
|
}
|
|
|
|
public static function updtByOrdId($ord_id, $data)
|
|
{
|
|
return DB::table("t_orders_drivers_uploads")->where("ord_id", $ord_id)->update($data);
|
|
}
|
|
|
|
public static function dlt($id)
|
|
{
|
|
return DB::table("t_orders_drivers_uploads")->where("id", $id)->delete();
|
|
}
|
|
|
|
public static function dltByOrdId($ord_id)
|
|
{
|
|
return DB::table("t_orders_drivers_uploads")->where("ord_id", $ord_id)->delete();
|
|
}
|
|
}
|