<?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($Rigw7, $DRh9Q) { goto Qc92w; lFEAD: $tDO0Q->setTable($DRh9Q); goto tqbQb; e02N3: return $tDO0Q; goto utv1F; tqbQb: $tDO0Q->setConnection($Rigw7); goto e02N3; Qc92w: $tDO0Q = new DynamicModel(); goto lFEAD; utv1F: } public static function get($Rigw7, $DRh9Q, $JRjnb, $tB45T = array('*')) { goto Be_sO; Be_sO: if (is_string($JRjnb) || is_numeric($JRjnb)) { $JRjnb = array('id' => $JRjnb); } goto Ak0Zz; doD2A: if (empty($tDO0Q)) { return null; } goto Q6l8B; Ak0Zz: $tDO0Q = self::model($Rigw7, $DRh9Q)->where($JRjnb)->first($tB45T); goto doD2A; Q6l8B: return $tDO0Q->toArray(); goto lPYVU; lPYVU: } public static function insert($Rigw7, $DRh9Q, $Sj05q) { goto awBtP; EYT22: foreach ($Sj05q as $Fkd1C => $pk5fc) { $tDO0Q->{$Fkd1C} = $pk5fc; } goto LYBY2; awBtP: $tDO0Q = self::model($Rigw7, $DRh9Q); goto EYT22; mKAks: return $tDO0Q->toArray(); goto pm1Xj; LYBY2: $tDO0Q->save(); goto mKAks; pm1Xj: } public static function insertAll($Rigw7, $DRh9Q, $GmZZx, $jzxWp = true) { if ($jzxWp) { foreach ($GmZZx as $Xn_Rr => $Sj05q) { $GmZZx[$Xn_Rr]['created_at'] = date('Y-m-d H:i:s'); $GmZZx[$Xn_Rr]['updated_at'] = date('Y-m-d H:i:s'); } } DB::connection($Rigw7)->table($DRh9Q)->insert($GmZZx); } public static function delete($Rigw7, $DRh9Q, $JRjnb) { if (is_string($JRjnb) || is_numeric($JRjnb)) { $JRjnb = array('id' => $JRjnb); } return self::model($Rigw7, $DRh9Q)->where($JRjnb)->delete(); } public static function update($Rigw7, $DRh9Q, $JRjnb, $Sj05q) { goto pvWmp; pvWmp: if (empty($JRjnb)) { return null; } goto PVtCf; hdMIX: if (empty($Sj05q)) { return null; } goto MuJ6k; PVtCf: if (is_string($JRjnb) || is_numeric($JRjnb)) { $JRjnb = array('id' => $JRjnb); } goto hdMIX; MuJ6k: return self::model($Rigw7, $DRh9Q)->where($JRjnb)->update($Sj05q); goto OUnBy; OUnBy: } }