public static function boot() { parent::boot(); static::creating(function ($model) { if ($model->carsubmodelid == 0) { CommissionExtraCar::where('commissionextraid', $model->commissionextraid)->where('carmodelid', $model->carmodelid)->delete(); } $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::updating(function ($model) { if ($model->carsubmodelid == 0) { CommissionExtraCar::where('id', '!=', $model->id)->where('commissionextraid', $model->commissionextraid)->where('carmodelid', $model->carmodelid)->delete(); } $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); }
public static function boot() { parent::boot(); static::creating(function ($model) { $carpreemption = CarPreemption::find($model->carpreemptionid); $model->provinceid = $carpreemption->provinceid; $model->branchid = $carpreemption->branchid; $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); $carpreemption = CarPreemption::find($model->carpreemptionid); $carpreemption->status = 2; $carpreemption->save(); }); static::updating(function ($model) { $carpreemption = CarPreemption::find($model->carpreemptionid); $model->provinceid = $carpreemption->provinceid; $model->branchid = $carpreemption->branchid; $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); $carpreemption = CarPreemption::find($model->carpreemptionid); $carpreemption->status = 0; $carpreemption->save(); }); }
public static function boot() { parent::boot(); static::creating(function ($model) { $carpayment = CarPayment::find($model->carpaymentid); $model->provinceid = $carpayment->provinceid; $model->branchid = $carpayment->branchid; $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::updating(function ($model) { $carpayment = CarPayment::find($model->carpaymentid); $model->provinceid = $carpayment->provinceid; $model->branchid = $carpayment->branchid; $model->accountingDetailReceiveAndPays()->delete(); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::deleting(function ($model) { $model->accountingDetailReceiveAndPays()->delete(); }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); }
public static function boot() { parent::boot(); static::creating(function ($model) { $model->effectivefrom = date('Y-m-d', strtotime($model->effectivefrom)); $model->effectiveto = date('Y-m-d', strtotime($model->effectiveto)); $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::updating(function ($model) { $model->effectivefrom = date('Y-m-d', strtotime($model->effectivefrom)); $model->effectiveto = date('Y-m-d', strtotime($model->effectiveto)); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); }
public static function boot() { parent::boot(); static::creating(function ($model) { if ($model->isadmin) { $model->branchid = null; $model->departmentid = null; $model->teamid = null; } else { if ($model->branchid == '') { $model->branchid = null; } if ($model->departmentid == '') { $model->departmentid = null; } if ($model->teamid == '') { $model->teamid = null; } } $model->password = bcrypt("nissanhippro"); $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::updating(function ($model) { if ($model->isadmin) { $model->branchid = null; $model->departmentid = null; $model->teamid = null; } else { if ($model->branchid == '') { $model->branchid = null; } if ($model->departmentid == '') { $model->departmentid = null; } if ($model->teamid == '') { $model->teamid = null; } } $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); }
/** * Handle an authentication attempt. * * @return Response */ public function authenticate(Request $request) { $email = Input::get('email'); $password = Input::get('password'); $remember = Input::get('remember'); if (Auth::attempt(['email' => $email, 'password' => $password], $remember)) { Log::create(['action' => '登录系统', 'userid' => Auth::user()->id, 'username' => Auth::user()->name]); return redirect()->intended('orders'); } return Redirect::to('/auth/login')->with('errors', array($this->loginUsername() => '用户名或密码错误')); }
public static function log($type, $value, $additional = null, $vars = null) { $ip = Request::ip(); $user = Auth::user(); if ($user) { $user_id = $user->id; } else { $user_id = 0; } $l = Log::create(['user_id' => $user_id, 'ip' => $ip, 'type' => $type, 'key_value' => $value, 'additional_value' => $additional, 'var' => $vars]); return $l; }
public static function boot() { parent::boot(); static::creating(function ($model) { $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); if ($model->isheadquarter) { for ($i = 1; $i <= $model->keyslot; $i++) { $m = new KeySlot(); $m->provinceid = $model->provinceid; $m->no = $i; $m->active = true; $m->save(); } } }); static::updating(function ($model) { $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); if ($model->isheadquarter) { $max = KeySlot::where('provinceid', $model->provinceid)->max('no'); if ($max == null) { $max = 0; } if ($model->keyslot > $max) { for ($i = $max + 1; $i <= $model->keyslot; $i++) { $m = new KeySlot(); $m->provinceid = $model->provinceid; $m->no = $i; $m->active = true; $m->save(); } } elseif ($model->keyslot < $max) { KeySlot::where('provinceid', $model->provinceid)->where('no', '>', $model->keyslot)->delete(); } } }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); if ($model->isheadquarter) { KeySlot::where('provinceid', $model->provinceid)->delete(); } }); }
public static function boot() { parent::boot(); static::creating(function ($model) { $model->issold = false; $model->isregistered = false; $model->isdelivered = false; $model->dodate = date('Y-m-d', strtotime($model->dodate)); $model->receiveddate = date('Y-m-d', strtotime($model->receiveddate)); $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); $rs = DB::select('call running_number("' . $model->provinceid . date("Y") . '","' . $model->receivetype . '")'); $model->no = $rs[0]->no; $min = KeySlot::where('provinceid', $model->provinceid)->where('active', true)->min('no'); if ($min == null) { $branch = Branch::where('provinceid', $model->provinceid)->where('isheadquarter', true)->first(); $branch->keyslot = $branch->keyslot + 1; $branch->save(); $model->keyno = $branch->keyslot; } else { $model->keyno = $min; } $model->save(); KeySlot::where('provinceid', $model->provinceid)->where('no', $model->keyno)->update(['active' => false]); }); static::updating(function ($model) { $model->dodate = date('Y-m-d', strtotime($model->dodate)); $model->receiveddate = date('Y-m-d', strtotime($model->receiveddate)); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); if ($model->receivecarfilepath != '') { File::delete(public_path() . $model->receivecarfilepath); } if ($model->deliverycarfilepath != '') { File::delete(public_path() . $model->deliverycarfilepath); } KeySlot::where('provinceid', $model->provinceid)->where('no', $model->keyno)->update(['active' => true]); }); }
public static function boot() { parent::boot(); static::updating(function ($model) { if ($model->returncashpledgedate != null && $model->returncashpledgedate != '') { $model->returncashpledgedate = date('Y-m-d', strtotime($model->returncashpledgedate)); } else { $model->returncashpledgedate = null; } $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); }
public static function boot() { parent::boot(); static::creating(function ($model) { if ($model->occupationid == '') { $model->occupationid = null; } if ($model->districtid == '') { $model->districtid = null; } if ($model->amphurid == '') { $model->amphurid = null; } if ($model->addprovinceid == '') { $model->addprovinceid = null; } $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::updating(function ($model) { if ($model->occupationid == '') { $model->occupationid = null; } if ($model->districtid == '') { $model->districtid = null; } if ($model->amphurid == '') { $model->amphurid = null; } if ($model->addprovinceid == '') { $model->addprovinceid = null; } $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); }
public static function boot() { parent::boot(); static::creating(function ($model) { $model->customerid = null; $model->carid = null; $model->deposit = null; if (!strpos($model->no, "-")) { $model->no = substr_replace($model->no, "-", strlen($model->no) - 4, 0); } $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::updating(function ($model) { if ($model->customerid == '') { $model->customerid = null; } if ($model->carid == '') { $model->carid = null; } if ($model->deposit == '') { $model->deposit = null; } if (!strpos($model->no, "-")) { $model->no = substr_replace($model->no, "-", strlen($model->no) - 4, 0); } $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); }
public static function boot() { parent::boot(); static::creating(function ($model) { if ($model->effectiveto != null && $model->effectiveto != '') { $model->effectiveto = date('Y-m-d', strtotime($model->effectiveto)); } $model->effectivefrom = date('Y-m-d', strtotime($model->effectivefrom)); $model->sellingpricewithaccessories = $model->sellingprice + $model->margin; $model->execusivetotalmargincampaing = $model->margin + $model->execusiveinternal + $model->execusivecampaing; $model->totalmargincampaing = $model->margin + $model->internal + $model->campaing; $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::updating(function ($model) { if ($model->effectiveto != null && $model->effectiveto != '') { $model->effectiveto = date('Y-m-d', strtotime($model->effectiveto)); } $model->effectivefrom = date('Y-m-d', strtotime($model->effectivefrom)); $model->sellingpricewithaccessories = $model->sellingprice + $model->margin; $model->execusivetotalmargincampaing = $model->margin + $model->execusiveinternal + $model->execusivecampaing; $model->totalmargincampaing = $model->margin + $model->internal + $model->campaing; $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); }
public static function boot() { parent::boot(); static::creating(function ($model) { $carpreemption = CarPreemption::find($model->carpreemptionid); $model->provinceid = $carpreemption->provinceid; $model->branchid = $carpreemption->branchid; if ($model->insurancecompanyid == '') { $model->insurancecompanyid = null; } if ($model->capitalinsurance == '') { $model->capitalinsurance = null; } if ($model->buyerpay == '') { $model->buyerpay = null; } if ($model->overdue == '') { $model->overdue = null; } if ($model->overdueinterest == '') { $model->overdueinterest = null; } if ($model->totaloverdue == '') { $model->totaloverdue = null; } if ($model->paybytype == '') { $model->paybytype = null; } if ($model->paybyotherdetails == '') { $model->paybyotherdetails = null; } if ($model->overdueinstallments == '') { $model->overdueinstallments = null; } if ($model->overdueinstallmentdate1 == '') { $model->overdueinstallmentdate1 = null; } if ($model->overdueinstallmentamount1 == '') { $model->overdueinstallmentamount1 = null; } if ($model->overdueinstallmentdate2 == '') { $model->overdueinstallmentdate2 = null; } if ($model->overdueinstallmentamount2 == '') { $model->overdueinstallmentamount2 = null; } if ($model->overdueinstallmentdate3 == '') { $model->overdueinstallmentdate3 = null; } if ($model->overdueinstallmentamount3 == '') { $model->overdueinstallmentamount3 = null; } if ($model->overdueinstallmentdate4 == '') { $model->overdueinstallmentdate4 = null; } if ($model->overdueinstallmentamount4 == '') { $model->overdueinstallmentamount4 = null; } if ($model->overdueinstallmentdate5 == '') { $model->overdueinstallmentdate5 = null; } if ($model->overdueinstallmentamount5 == '') { $model->overdueinstallmentamount5 = null; } if ($model->overdueinstallmentdate6 == '') { $model->overdueinstallmentdate6 = null; } if ($model->overdueinstallmentamount6 == '') { $model->overdueinstallmentamount6 = null; } if ($model->oldcarbuyername == '') { $model->oldcarbuyername = null; } if ($model->oldcarpayamount == '') { $model->oldcarpayamount = null; } if ($model->oldcarpaytype == '') { $model->oldcarpaytype = null; } if ($model->oldcarpaydate == '') { $model->oldcarpaydate = null; } if ($model->payeeemployeeid == '') { $model->payeeemployeeid = null; } if ($model->deliverycarbookno == '') { $model->deliverycarbookno = null; } if ($model->deliverycarno == '') { $model->deliverycarno = null; } if ($model->deliverycardate == '') { $model->deliverycardate = null; } $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); $carpreemption = CarPreemption::find($model->carpreemptionid); if ($carpreemption->carobjectivetype == 0) { $redlabelhistory = Redlabelhistory::where('carpreemptionid', $carpreemption->id)->first(); $redlabel = Redlabel::find($redlabelhistory->redlabelid); $redlabel->carid = $model->carid; $redlabel->customerid = $carpreemption->buyercustomerid; $redlabel->deposit = $carpreemption->cashpledgeredlabel; $redlabel->save(); } if ($model->isdraft) { $carpreemption->status = 3; } else { $carpreemption->status = 1; } $carpreemption->save(); $car = Car::find($model->carid); $car->issold = true; $car->buyercustomerid = $carpreemption->buyercustomerid; if ($model->deliverycarbookno != null && $model->deliverycarbookno != '') { $car->isdelivered = true; KeySlot::where('provinceid', $car->provinceid)->where('no', $car->keyno)->update(['carid' => null, 'active' => true]); } $car->save(); }); static::updating(function ($model) { $carpreemption = CarPreemption::find($model->carpreemptionid); $model->provinceid = $carpreemption->provinceid; $model->branchid = $carpreemption->branchid; if ($model->insurancecompanyid == '') { $model->insurancecompanyid = null; } if ($model->capitalinsurance == '') { $model->capitalinsurance = null; } if ($model->buyerpay == '') { $model->buyerpay = null; } if ($model->overdue == '') { $model->overdue = null; } if ($model->overdueinterest == '') { $model->overdueinterest = null; } if ($model->totaloverdue == '') { $model->totaloverdue = null; } if ($model->paybytype == '') { $model->paybytype = null; } if ($model->paybyotherdetails == '') { $model->paybyotherdetails = null; } if ($model->overdueinstallments == '') { $model->overdueinstallments = null; } if ($model->overdueinstallmentdate1 == '') { $model->overdueinstallmentdate1 = null; } if ($model->overdueinstallmentamount1 == '') { $model->overdueinstallmentamount1 = null; } if ($model->overdueinstallmentdate2 == '') { $model->overdueinstallmentdate2 = null; } if ($model->overdueinstallmentamount2 == '') { $model->overdueinstallmentamount2 = null; } if ($model->overdueinstallmentdate3 == '') { $model->overdueinstallmentdate3 = null; } if ($model->overdueinstallmentamount3 == '') { $model->overdueinstallmentamount3 = null; } if ($model->overdueinstallmentdate4 == '') { $model->overdueinstallmentdate4 = null; } if ($model->overdueinstallmentamount4 == '') { $model->overdueinstallmentamount4 = null; } if ($model->overdueinstallmentdate5 == '') { $model->overdueinstallmentdate5 = null; } if ($model->overdueinstallmentamount5 == '') { $model->overdueinstallmentamount5 = null; } if ($model->overdueinstallmentdate6 == '') { $model->overdueinstallmentdate6 = null; } if ($model->overdueinstallmentamount6 == '') { $model->overdueinstallmentamount6 = null; } if ($model->oldcarbuyername == '') { $model->oldcarbuyername = null; } if ($model->oldcarpayamount == '') { $model->oldcarpayamount = null; } if ($model->oldcarpaytype == '') { $model->oldcarpaytype = null; } if ($model->oldcarpaydate == '') { $model->oldcarpaydate = null; } if ($model->payeeemployeeid == '') { $model->payeeemployeeid = null; } if ($model->deliverycarbookno == '') { $model->deliverycarbookno = null; } if ($model->deliverycarno == '') { $model->deliverycarno = null; } if ($model->deliverycardate == '') { $model->deliverycardate = null; } $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); $carpreemption = CarPreemption::find($model->carpreemptionid); if ($model->isdraft) { $carpreemption->status = 3; } else { $carpreemption->status = 1; } $carpreemption->save(); $car = Car::find($model->carid); if ($model->deliverycarbookno != null && $model->deliverycarbookno != '') { $car->isdelivered = true; KeySlot::where('provinceid', $car->provinceid)->where('no', $car->keyno)->where('carid', $car->id)->update(['carid' => null, 'active' => true]); } else { $car->isdelivered = false; KeySlot::where('provinceid', $car->provinceid)->where('no', $car->keyno)->whereNull('carid')->update(['carid' => $car->id, 'active' => false]); } $car->save(); }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); $carpreemption = CarPreemption::find($model->carpreemptionid); if ($carpreemption->carobjectivetype == 0) { $redlabelhistory = Redlabelhistory::where('carpreemptionid', $carpreemption->id)->first(); $redlabel = Redlabel::find($redlabelhistory->redlabelid); $redlabel->carid = null; $redlabel->save(); } $carpreemption->status = 0; $carpreemption->save(); $car = Car::find($model->carid); $car->issold = false; $car->isdelivered = false; KeySlot::where('provinceid', $car->provinceid)->where('no', $car->keyno)->whereNull('carid')->update(['carid' => $car->id, 'active' => false]); }); }
public static function boot() { parent::boot(); static::creating(function ($model) { if ($model->occupationid == '') { $model->occupationid = null; } if ($model->districtid == '') { $model->districtid = null; } if ($model->amphurid == '') { $model->amphurid = null; } if ($model->addprovinceid == '') { $model->addprovinceid = null; } if ($model->birthdate != null && $model->birthdate != '') { $model->birthdate = date('Y-m-d', strtotime($model->birthdate)); } else { $model->birthdate = null; } //$model->isreal = false; $model->statusexpect = 0; $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::updating(function ($model) { if ($model->occupationid == '') { $model->occupationid = null; } if ($model->districtid == '') { $model->districtid = null; } if ($model->amphurid == '') { $model->amphurid = null; } if ($model->addprovinceid == '') { $model->addprovinceid = null; } if ($model->birthdate != null && $model->birthdate != '') { $model->birthdate = date('Y-m-d', strtotime($model->birthdate)); } else { $model->birthdate = null; } $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); if ($model->statusexpect != 1) { CustomerExpectation::where('customerid', $model->id)->where('active', true)->update(['active' => false]); } }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); }
public static function boot() { parent::boot(); static::creating(function ($model) { if ($model->isadmin) { $model->provinceid = null; $model->branchid = null; $model->departmentid = null; $model->teamid = null; $model->candeletedata = true; } else { if ($model->branchid == '') { $model->branchid = null; $model->provinceid = null; } else { if ($model->branchid != null) { $branch = Branch::find($model->branchid); $model->provinceid = $branch->provinceid; } } if ($model->departmentid == '') { $model->departmentid = null; } if ($model->teamid == '') { $model->teamid = null; } } if ($model->username == '') { $model->username = null; } if ($model->email == '') { $model->email = null; } if ($model->workingstartdate != null && $model->workingstartdate != '') { $model->workingstartdate = date('Y-m-d', strtotime($model->workingstartdate)); } else { $model->workingstartdate = null; } if ($model->workingenddate != null && $model->workingenddate != '') { $model->workingenddate = date('Y-m-d', strtotime($model->workingenddate)); } else { $model->workingenddate = null; } if ($model->loginstartdate != null && $model->loginstartdate != '') { $model->loginstartdate = date('Y-m-d', strtotime($model->loginstartdate)); } else { $model->loginstartdate = null; } if ($model->loginenddate != null && $model->loginenddate != '') { $model->loginenddate = date('Y-m-d', strtotime($model->loginenddate)); } else { $model->loginenddate = null; } if ($model->username != null && $model->username != '') { $model->password = bcrypt("nissanhippro"); } $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::updating(function ($model) { if ($model->isadmin) { $model->provinceid = null; $model->branchid = null; $model->departmentid = null; $model->teamid = null; $model->candeletedata = true; } else { if ($model->branchid == '') { $model->branchid = null; $model->provinceid = null; } else { if ($model->branchid != null) { $branch = Branch::find($model->branchid); $model->provinceid = $branch->provinceid; } } if ($model->departmentid == '') { $model->departmentid = null; } if ($model->teamid == '') { $model->teamid = null; } } if ($model->username == '') { $model->username = null; } if ($model->email == '') { $model->email = null; } if ($model->workingstartdate != null && $model->workingstartdate != '') { $model->workingstartdate = date('Y-m-d', strtotime($model->workingstartdate)); } else { $model->workingstartdate = null; } if ($model->workingenddate != null && $model->workingenddate != '') { $model->workingenddate = date('Y-m-d', strtotime($model->workingenddate)); } else { $model->workingenddate = null; } if ($model->loginstartdate != null && $model->loginstartdate != '') { $model->loginstartdate = date('Y-m-d', strtotime($model->loginstartdate)); } else { $model->loginstartdate = null; } if ($model->loginenddate != null && $model->loginenddate != '') { $model->loginenddate = date('Y-m-d', strtotime($model->loginenddate)); } else { $model->loginenddate = null; } if ($model->username != null && $model->username != '' && ($model->password == null || $model->password == '')) { $model->password = bcrypt("nissanhippro"); } $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); }
public static function boot() { parent::boot(); static::creating(function ($model) { $employee = Employee::find($model->salesmanemployeeid); $model->salesmanteamid = $employee->teamid; $model->provinceid = $employee->branch->provinceid; $model->branchid = $employee->branchid; $model->status = 0; if ($model->carobjectivetype == 0) { $model->financingfee = null; $model->transferfee = null; $model->transferoperationfee = null; } else { if ($model->carobjectivetype == 1) { $model->cashpledgeredlabel = null; $model->registerprovinceid = null; $model->registrationtype = null; $model->registrationfee = null; } } if ($model->contractdate == '') { $model->contractdate = null; } $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); Customer::where('id', $model->bookingcustomerid)->orWhere('id', $model->buyercustomerid)->update(['statusexpect' => 0]); $bookingcustomerid = $model->bookingcustomerid; $buyercustomerid = $model->buyercustomerid; CustomerExpectation::where('active', true)->where(function ($query) use($bookingcustomerid, $buyercustomerid) { $query->where('customerid', $bookingcustomerid)->orWhere('customerid', $buyercustomerid); })->update(['active' => false]); }); static::updating(function ($model) { if ($model->carobjectivetype == 0) { $model->financingfee = null; $model->transferfee = null; $model->transferoperationfee = null; } else { if ($model->carobjectivetype == 1) { $model->cashpledgeredlabel = null; $model->registerprovinceid = null; $model->registrationtype = null; $model->registrationfee = null; } } if ($model->contractdate == '') { $model->contractdate = null; } $model->carPreemptionGiveaways()->delete(); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); }
public static function boot() { parent::boot(); static::creating(function ($model) { if ($model->carmodelid1 == '') { $model->carmodelid1 = null; } if ($model->carmodelid2 == '') { $model->carmodelid2 = null; } if ($model->carmodelid3 == '') { $model->carmodelid3 = null; } if ($model->colorid1 == '') { $model->colorid1 = null; } if ($model->colorid2 == '') { $model->colorid2 = null; } if ($model->colorid3 == '') { $model->colorid3 = null; } if ($model->nextappointmentdate != null && $model->nextappointmentdate != '') { $model->nextappointmentdate = date('Y-m-d', strtotime($model->nextappointmentdate)); } $model->active = true; $model->date = date('Y-m-d', strtotime($model->date)); $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); $customer = Customer::find($model->customerid); $customer->statusexpect = 1; $customer->save(); }); static::updating(function ($model) { if ($model->carmodelid1 == '') { $model->carmodelid1 = null; } if ($model->carmodelid2 == '') { $model->carmodelid2 = null; } if ($model->carmodelid3 == '') { $model->carmodelid3 = null; } if ($model->colorid1 == '') { $model->colorid1 = null; } if ($model->colorid2 == '') { $model->colorid2 = null; } if ($model->colorid3 == '') { $model->colorid3 = null; } if ($model->nextappointmentdate != null && $model->nextappointmentdate != '') { $model->nextappointmentdate = date('Y-m-d', strtotime($model->nextappointmentdate)); } $model->date = date('Y-m-d', strtotime($model->date)); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); }
public function destroy($postID) { $post = Post::find($postID); if ($post) { Log::create(array('post_id' => $postID, 'date' => \DB::raw('now()'), 'ip' => \Request::getClientIp())); $post->delete(); Cache::forget('all_post'); Cache::forget('post_' . $postID); //Forgot post_ID in store cache return self::makeResponse(array()); } else { return self::makeResponse(array(), 404, 'Cannot found post'); } }
public static function boot() { parent::boot(); static::creating(function ($model) { $model->issuedate = date('Y-m-d', strtotime($model->issuedate)); $model->returndate = null; $model->createdby = Auth::user()->id; $model->createddate = date("Y-m-d H:i:s"); $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::created(function ($model) { $carpreemption = CarPreemption::find($model->carpreemptionid); $redlabel = RedLabel::find($model->redlabelid); $redlabel->customerid = $carpreemption->buyercustomerid; $redlabel->deposit = $carpreemption->cashpledgeredlabel; $redlabel->save(); Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::updating(function ($model) { $model->issuedate = date('Y-m-d', strtotime($model->issuedate)); if ($model->returndate != null && $model->returndate != '') { $model->returndate = date('Y-m-d', strtotime($model->returndate)); } else { $model->returndate = null; } $model->modifiedby = Auth::user()->id; $model->modifieddate = date("Y-m-d H:i:s"); }); static::updated(function ($model) { $maxid = Redlabelhistory::where('redlabelid', $model->redlabelid)->max('id'); if ($model->returndate != null && $model->returndate != '') { if ($model->id == $maxid) { $redlabel = RedLabel::find($model->redlabelid); $redlabel->customerid = null; $redlabel->carid = null; $redlabel->deposit = null; $redlabel->save(); } } else { if ($model->id == $maxid) { $carpreemption = CarPreemption::find($model->carpreemptionid); $redlabel = RedLabel::find($model->redlabelid); $redlabel->customerid = $carpreemption->buyercustomerid; $redlabel->deposit = $carpreemption->cashpledgeredlabel; $redlabel->save(); } } Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); }); static::deleted(function ($model) { Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]); $maxid = Redlabelhistory::where('redlabelid', $model->redlabelid)->max('id'); if ($maxid == null || $maxid == '' || $model->id > $maxid) { $redlabel = RedLabel::find($model->redlabelid); $redlabel->customerid = null; $redlabel->carid = null; $redlabel->deposit = null; $redlabel->save(); } }); }