<?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($Ar4n5, $uV19D) { goto p0H56; UTdny: $Q_c7O->setConnection($Ar4n5); goto FO_Yd; iHuGX: $Q_c7O->setTable($uV19D); goto UTdny; p0H56: $Q_c7O = new DynamicModel(); goto iHuGX; FO_Yd: return $Q_c7O; goto KOcGS; KOcGS: } public static function get($Ar4n5, $uV19D, $nDJ06, $xG2vi = array('*')) { goto xAjS1; xAjS1: if (is_string($nDJ06) || is_numeric($nDJ06)) { $nDJ06 = array('id' => $nDJ06); } goto Nc5pO; mxDHd: return $Q_c7O->toArray(); goto YzSCW; Nc5pO: $Q_c7O = self::model($Ar4n5, $uV19D)->where($nDJ06)->first($xG2vi); goto XPnC2; XPnC2: if (empty($Q_c7O)) { return null; } goto mxDHd; YzSCW: } public static function insert($Ar4n5, $uV19D, $OTBPk) { goto i3yI0; LFoBy: foreach ($OTBPk as $GBNIv => $VFelt) { $Q_c7O->{$GBNIv} = $VFelt; } goto A5bfR; i3yI0: $Q_c7O = self::model($Ar4n5, $uV19D); goto LFoBy; ka69R: return $Q_c7O->toArray(); goto aBtbk; A5bfR: $Q_c7O->save(); goto ka69R; aBtbk: } public static function insertAll($Ar4n5, $uV19D, $xAnos, $T8ay2 = true) { if ($T8ay2) { foreach ($xAnos as $VJ5vg => $OTBPk) { $xAnos[$VJ5vg]['created_at'] = date('Y-m-d H:i:s'); $xAnos[$VJ5vg]['updated_at'] = date('Y-m-d H:i:s'); } } DB::connection($Ar4n5)->table($uV19D)->insert($xAnos); } public static function delete($Ar4n5, $uV19D, $nDJ06) { if (is_string($nDJ06) || is_numeric($nDJ06)) { $nDJ06 = array('id' => $nDJ06); } return self::model($Ar4n5, $uV19D)->where($nDJ06)->delete(); } public static function update($Ar4n5, $uV19D, $nDJ06, $OTBPk) { goto UDCKi; mcHFD: if (empty($OTBPk)) { return null; } goto Unnlj; UDCKi: if (empty($nDJ06)) { return null; } goto Ff2pR; Ff2pR: if (is_string($nDJ06) || is_numeric($nDJ06)) { $nDJ06 = array('id' => $nDJ06); } goto mcHFD; Unnlj: return self::model($Ar4n5, $uV19D)->where($nDJ06)->update($OTBPk); goto iXy_D; iXy_D: } }