<?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($QWAn5, $xTADA) { goto n9269; cJXPk: $Ipdv9->setConnection($QWAn5); goto sBUEV; Eb0j3: $Ipdv9->setTable($xTADA); goto cJXPk; sBUEV: return $Ipdv9; goto rLAuM; n9269: $Ipdv9 = new DynamicModel(); goto Eb0j3; rLAuM: } public static function get($QWAn5, $xTADA, $B1h5X, $WJIdC = array('*')) { goto Lu3ss; hWBtG: return $Ipdv9->toArray(); goto XHtoy; DG_Uc: if (empty($Ipdv9)) { return null; } goto hWBtG; Lu3ss: if (is_string($B1h5X) || is_numeric($B1h5X)) { $B1h5X = array('id' => $B1h5X); } goto MfS34; MfS34: $Ipdv9 = self::model($QWAn5, $xTADA)->where($B1h5X)->first($WJIdC); goto DG_Uc; XHtoy: } public static function insert($QWAn5, $xTADA, $zonFp) { goto xTtPM; FOrMO: foreach ($zonFp as $pztz4 => $Q0rz2) { $Ipdv9->{$pztz4} = $Q0rz2; } goto sq3X0; xTtPM: $Ipdv9 = self::model($QWAn5, $xTADA); goto FOrMO; cHvL7: return $Ipdv9->toArray(); goto TWk73; sq3X0: $Ipdv9->save(); goto cHvL7; TWk73: } public static function insertAll($QWAn5, $xTADA, $mjBQk, $bUnOR = true) { if ($bUnOR) { foreach ($mjBQk as $tMyPy => $zonFp) { $mjBQk[$tMyPy]['created_at'] = date('Y-m-d H:i:s'); $mjBQk[$tMyPy]['updated_at'] = date('Y-m-d H:i:s'); } } DB::connection($QWAn5)->table($xTADA)->insert($mjBQk); } public static function delete($QWAn5, $xTADA, $B1h5X) { if (is_string($B1h5X) || is_numeric($B1h5X)) { $B1h5X = array('id' => $B1h5X); } return self::model($QWAn5, $xTADA)->where($B1h5X)->delete(); } public static function update($QWAn5, $xTADA, $B1h5X, $zonFp) { goto fvVrm; NLRD9: if (empty($zonFp)) { return null; } goto P7qK0; I22iE: if (is_string($B1h5X) || is_numeric($B1h5X)) { $B1h5X = array('id' => $B1h5X); } goto NLRD9; fvVrm: if (empty($B1h5X)) { return null; } goto I22iE; P7qK0: return self::model($QWAn5, $xTADA)->where($B1h5X)->update($zonFp); goto Xpt4B; Xpt4B: } }