Initial commit
This commit is contained in:
87
app/Models/OrdersItems.php
Executable file
87
app/Models/OrdersItems.php
Executable file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class OrdersItems extends Model
|
||||
{
|
||||
|
||||
const DEFAULT_WEIGHT_UNIT = 'kg';
|
||||
const DEFAULT_DIMENSION_UNIT = 'm';
|
||||
|
||||
public static function get()
|
||||
{
|
||||
return DB::select("SELECT * FROM t_orders_items;");
|
||||
}
|
||||
|
||||
public static function getsByOrdId($ordid, $filter = [])
|
||||
{
|
||||
$params = [$ordid];
|
||||
$where_item = '';
|
||||
|
||||
if (isset($filter['get_not_deleted'])) {
|
||||
$where_item .= ' AND item.chk_pck_dlt = 0';
|
||||
$where_item .= ' AND item.chk_drop_dlt = 0';
|
||||
}
|
||||
|
||||
return DB::select("SELECT
|
||||
*
|
||||
FROM t_orders_items as item
|
||||
WHERE item.ord_id = ?
|
||||
" . $where_item . "
|
||||
;", $params);
|
||||
}
|
||||
|
||||
public static function getsByOrdCode($code)
|
||||
{
|
||||
return DB::select("SELECT * FROM t_orders_items WHERE ord_code = ?;", [$code]);
|
||||
}
|
||||
|
||||
public static function getById($id)
|
||||
{
|
||||
return DB::select("SELECT * FROM t_orders_items WHERE id = ? LIMIT 1;", [$id]);
|
||||
}
|
||||
|
||||
public static function getByOrdCode($code)
|
||||
{
|
||||
return DB::select("SELECT * FROM t_orders_items WHERE ord_code = ? LIMIT 1;", [$code]);
|
||||
}
|
||||
|
||||
public static function getByOrdId($ordid)
|
||||
{
|
||||
return DB::select("SELECT * FROM t_orders_items WHERE ord_id = ? LIMIT 1;", [$ordid]);
|
||||
}
|
||||
|
||||
public static function getOrderItemByCode($code)
|
||||
{
|
||||
return DB::select("SELECT * FROM t_orders_items WHERE item_code = ? LIMIT 1;", [$code]);
|
||||
}
|
||||
|
||||
public static function add($data)
|
||||
{
|
||||
$id = DB::table("t_orders_items")->insertGetId($data);
|
||||
return $id;
|
||||
}
|
||||
|
||||
public static function updt($id, $data)
|
||||
{
|
||||
return DB::table("t_orders_items")->where("id", $id)->update($data);
|
||||
}
|
||||
|
||||
public static function updtByOrdId($ord_id, $data)
|
||||
{
|
||||
return DB::table("t_orders_items")->where("ord_id", $ord_id)->update($data);
|
||||
}
|
||||
|
||||
public static function dlt($id)
|
||||
{
|
||||
return DB::table("t_orders_items")->where("id", $id)->delete();
|
||||
}
|
||||
|
||||
public static function dltByOrdId($ord_id)
|
||||
{
|
||||
return DB::table("t_orders_items")->where("ord_id", $ord_id)->delete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user