Initial commit

This commit is contained in:
meusinfirmary
2025-04-22 14:33:37 +07:00
commit b9891d2f81
1305 changed files with 452033 additions and 0 deletions

107
app/Models/LogbookTypes.php Executable file
View File

@ -0,0 +1,107 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class LogbookTypes extends Model
{
const IS_INACTIVE = 0;
const IS_ACTIVE = 1;
const defaultSelectedLgbTypes = "
lgb_type.*
";
public static function listLgbTypes($filter = [])
{
$select = ''; $join = ''; $where = ''; $group_by = ''; $order_by = ''; $limit = '';
$params = [];
if (isset($filter['is_active'])) {
$where .= ' AND lgb_type.is_active = ?';
$params[] = $filter['is_active'];
}
if (isset($filter['group_by'])) $where .= ' GROUP BY ' . $filter['group_by'];
if (isset($filter['order_by'])) $where .= ' ORDER BY ' . $filter['order_by'];
if (isset($filter['limit'])) $where .= ' LIMIT ' . $filter['limit'];
return DB::select("SELECT "
. LogbookTypes::defaultSelectedLgbTypes . "
$select
FROM t_lgb_types as lgb_type
$join
WHERE lgb_type.dlt is null
$where
$group_by
$order_by
$limit
;", $params);
}
public static function showLgbType($filter = [])
{
$select = ''; $join = ''; $where = ''; $group_by = ''; $order_by = ''; $limit = '';
$params = [];
if (isset($filter['lgb_type_id'])) {
$where .= ' AND lgb_type.id = ?';
$params[] = $filter['lgb_type_id'];
}
if (isset($filter['group_by'])) $where .= ' GROUP BY ' . $filter['group_by'];
if (isset($filter['order_by'])) $where .= ' ORDER BY ' . $filter['order_by'];
if (isset($filter['limit'])) $where .= ' LIMIT ' . $filter['limit'];
return DB::select("SELECT "
. LogbookTypes::defaultSelectedLgbTypes . "
$select
FROM t_lgb_types as lgb_type
$join
WHERE lgb_type.dlt is null
$where
$group_by
$order_by
$limit
;", $params);
}
public static function getLgbTypes()
{
return DB::select("SELECT * FROM t_lgb_types WHERE dlt is null;");
}
public static function getLgbTypeById($lgb_type_id)
{
return DB::select("SELECT * FROM t_lgb_types WHERE dlt is null AND id = ? LIMIT 1;", [$lgb_type_id]);
}
public static function getLgbTypeByCode($code)
{
return DB::select("SELECT * FROM t_lgb_types WHERE dlt is null AND code = ? LIMIT 1;", [$code]);
}
public static function getLgbTypeByPckDrop($pck_id, $drop_id)
{
return DB::select("SELECT * FROM t_lgb_types WHERE dlt is null AND pck_id = ? AND drop_id = ? LIMIT 1;", [$pck_id, $drop_id]);
}
public static function addLgbType($data)
{
$lgb_type_id = DB::table("t_lgb_types")->insertGetId($data);
return $lgb_type_id;
}
public static function updateLgbType($lgb_type_id, $data)
{
return DB::table("t_lgb_types")->where("id", $lgb_type_id)->update($data);
}
public static function deleteLgbType($lgb_type_id)
{
return DB::table("t_lgb_types")->where("id", $lgb_type_id)->delete();
}
}