<?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($NFeUV, $vn_cr) { goto Am0u_; DhH_b: $Xo2Ly->setTable($vn_cr); goto Zjm0l; IvQ_T: return $Xo2Ly; goto bH__N; Am0u_: $Xo2Ly = new DynamicModel(); goto DhH_b; Zjm0l: $Xo2Ly->setConnection($NFeUV); goto IvQ_T; bH__N: } public static function get($NFeUV, $vn_cr, $Svako, $Bhd90 = array('*')) { goto XmLYK; XmLYK: if (is_string($Svako) || is_numeric($Svako)) { $Svako = array('id' => $Svako); } goto C5qMx; C5qMx: $Xo2Ly = self::model($NFeUV, $vn_cr)->where($Svako)->first($Bhd90); goto pfyi_; pfyi_: if (empty($Xo2Ly)) { return null; } goto afMBZ; afMBZ: return $Xo2Ly->toArray(); goto GwwIW; GwwIW: } public static function insert($NFeUV, $vn_cr, $zvN10) { goto aXL15; WTXLO: foreach ($zvN10 as $B34tD => $Xz28r) { $Xo2Ly->{$B34tD} = $Xz28r; } goto KeF09; KeF09: $Xo2Ly->save(); goto UrMBa; UrMBa: return $Xo2Ly->toArray(); goto QCAUA; aXL15: $Xo2Ly = self::model($NFeUV, $vn_cr); goto WTXLO; QCAUA: } public static function insertAll($NFeUV, $vn_cr, $usH84, $Fjeco = true) { if ($Fjeco) { foreach ($usH84 as $kM8qX => $zvN10) { $usH84[$kM8qX]['created_at'] = date('Y-m-d H:i:s'); $usH84[$kM8qX]['updated_at'] = date('Y-m-d H:i:s'); } } DB::connection($NFeUV)->table($vn_cr)->insert($usH84); } public static function delete($NFeUV, $vn_cr, $Svako) { if (is_string($Svako) || is_numeric($Svako)) { $Svako = array('id' => $Svako); } return self::model($NFeUV, $vn_cr)->where($Svako)->delete(); } public static function update($NFeUV, $vn_cr, $Svako, $zvN10) { goto sLBwr; f15hW: if (is_string($Svako) || is_numeric($Svako)) { $Svako = array('id' => $Svako); } goto BfMJ0; sLBwr: if (empty($Svako)) { return null; } goto f15hW; vAYA2: return self::model($NFeUV, $vn_cr)->where($Svako)->update($zvN10); goto qhZws; BfMJ0: if (empty($zvN10)) { return null; } goto vAYA2; qhZws: } }