no message

This commit is contained in:
hellcat committed 2025-03-24 19:45:23 +08:00
1 parent f83b20b3ff
commit cf9f9113b4
7 files changed
+208 -41

No files matched your search

+65
View File
@@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Query\Builder;
final class TgStep extends Model
{
protected $connection = 'default';
protected $table = 'tg_step';
public function add($iFromId, $sCmd, $iStep, $sCache = [])
{
$oTgStep = new TgStep();
$oTgStep->from_id = $iFromId;
$oTgStep->cmd = $sCmd;
$oTgStep->step = $iStep;
$oTgStep->cache = json_encode($sCache);
$oTgStep->save();
}
public function fromIdHit($iFromId)
{
return TgStep::where('from_id', $iFromId)->exists();
}
public function find($iFromId, $iStep = false, $sCmd = false)
{
$oTgStep = new TgStep();
$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();
}
}