no message
This commit is contained in:
1 parent
f83b20b3ff
commit
cf9f9113b4
7 files changed
+208
-41
No files matched your search
Executable
+65
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user