<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Dao; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; class DModelUtil { public static function model($bJgWQ, $pWRTh) { goto fAKac; jwzJr: $ktBm1->setConnection($bJgWQ); goto Nrg5o; Nrg5o: return $ktBm1; goto ReF8K; fAKac: $ktBm1 = new DynamicModel(); goto qG056; qG056: $ktBm1->setTable($pWRTh); goto jwzJr; ReF8K: } public static function get($bJgWQ, $pWRTh, $ArzOE, $cCRbx = array('*')) { goto tmxBO; wilp3: $ktBm1 = self::model($bJgWQ, $pWRTh)->where($ArzOE)->first($cCRbx); goto Bj5Bj; YR8GX: return $ktBm1->toArray(); goto OV2jr; tmxBO: if (is_string($ArzOE) || is_numeric($ArzOE)) { $ArzOE = array('id' => $ArzOE); } goto wilp3; Bj5Bj: if (empty($ktBm1)) { return null; } goto YR8GX; OV2jr: } public static function insert($bJgWQ, $pWRTh, $Y0YxF) { goto fmXGT; snEvA: $ktBm1->save(); goto t9PiL; fmXGT: $ktBm1 = self::model($bJgWQ, $pWRTh); goto Rt5Nc; t9PiL: return $ktBm1->toArray(); goto bzT1Y; Rt5Nc: foreach ($Y0YxF as $U9AsU => $ohYVl) { $ktBm1->{$U9AsU} = $ohYVl; } goto snEvA; bzT1Y: } public static function insertAll($bJgWQ, $pWRTh, $uPGkE, $Pbl1I = true) { if ($Pbl1I) { foreach ($uPGkE as $K3Ni_ => $Y0YxF) { $uPGkE[$K3Ni_]['created_at'] = date('Y-m-d H:i:s'); $uPGkE[$K3Ni_]['updated_at'] = date('Y-m-d H:i:s'); } } DB::connection($bJgWQ)->table($pWRTh)->insert($uPGkE); } public static function delete($bJgWQ, $pWRTh, $ArzOE) { if (is_string($ArzOE) || is_numeric($ArzOE)) { $ArzOE = array('id' => $ArzOE); } return self::model($bJgWQ, $pWRTh)->where($ArzOE)->delete(); } public static function update($bJgWQ, $pWRTh, $ArzOE, $Y0YxF) { goto GOnbq; KEbFT: return self::model($bJgWQ, $pWRTh)->where($ArzOE)->update($Y0YxF); goto t0kXn; GOnbq: if (empty($ArzOE)) { return null; } goto aMDSZ; aMDSZ: if (is_string($ArzOE) || is_numeric($ArzOE)) { $ArzOE = array('id' => $ArzOE); } goto QY9H3; QY9H3: if (empty($Y0YxF)) { return null; } goto KEbFT; t0kXn: } }