66 lines
1.4 KiB
PHP
Executable File
66 lines
1.4 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class Dana extends Model
|
|
{
|
|
const defaultSelectedDana = "
|
|
dana.*
|
|
";
|
|
|
|
const PK_ID = 1;
|
|
const MINIMUM_AMT = 1000000; // 9M
|
|
|
|
public static function listDana($filter = [])
|
|
{
|
|
$select = ''; $join = ''; $where = ''; $group_by = ''; $order_by = ''; $limit = '';
|
|
$params = [];
|
|
|
|
if (isset($filter['id'])) {
|
|
$where .= ' AND dana.id = ?';
|
|
$params[] = $filter['id'];
|
|
}
|
|
|
|
return DB::select("SELECT "
|
|
. Dana::defaultSelectedDana . "
|
|
$select
|
|
FROM t_dana as dana
|
|
$join
|
|
WHERE dana.id is not null
|
|
$where
|
|
$group_by
|
|
$order_by
|
|
$limit
|
|
;", $params);
|
|
}
|
|
|
|
public static function getDana()
|
|
{
|
|
return DB::select("SELECT * FROM t_dana WHERE id is not null;");
|
|
}
|
|
|
|
public static function getDanaById($id)
|
|
{
|
|
return DB::select("SELECT * FROM t_dana WHERE id is not null AND id = ? LIMIT 1;", [$id]);
|
|
}
|
|
|
|
public static function addDana($data)
|
|
{
|
|
$pid = DB::table("t_dana")->insertGetId($data);
|
|
return $pid;
|
|
}
|
|
|
|
public static function updateDana($id, $data)
|
|
{
|
|
return DB::table("t_dana")->where("id", $id)->update($data);
|
|
}
|
|
|
|
public static function deleteDana($id)
|
|
{
|
|
return DB::table("t_dana")->where("id", $id)->delete();
|
|
}
|
|
}
|