from_id = $iFromId; $oTgStep->cmd = $sCmd; $oTgStep->step = $iStep; $oTgStep->cache = json_encode($sCache); $oTgStep->date = date("Y-m-d"); $oTgStep->save(); } public function fromIdHit($iFromId) { return TgStep::where('from_id', $iFromId)->exists(); } public function find($iFromId, $iStep = false, $sCmd = false) { $oTgStep = TgStep::query(); $oTgStep->where("from_id", $iFromId); if ($iStep) { $oTgStep->where("step", $iStep); } if ($sCmd) { $oTgStep->where("cmd", $sCmd); } $aData = $oTgStep->orderBy("step", "desc")->first()->toArray(); $aData['cache'] = json_decode($aData['cache'], true); return $aData; } public function clearByFromId($iFromId) { $oTgStep = new TgStep(); return $oTgStep->where("from_id", $iFromId)->delete(); } public function clearAll() { return TgStep::delete(); } }