dd/app/Models/Me.php
2025-07-15 16:57:59 +08:00

65 lines
1.3 KiB
PHP
Executable File

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class GoodPool extends Model
{
protected $table = 'good_pool';
public $timestamps = false;
// public static function _find($sCode)
// {
// $oSelf = self::where("code", $sCode)->first();
//
// return $oSelf;
// }
public static function _all()
{
$oSelf = self::all();
// $oNew;
foreach ($oSelf as &$oSelfRow) {
$oSelfRow->good = json_decode($oSelfRow->good);
}
return $oSelf;
}
public static function _rand($sClass)
{
$aGood = self::where("class", $sClass)->get()->toArray();
$iGoodRandKey = array_rand($aGood);
$aGoodRand = $aGood[$iGoodRandKey];
return $aGoodRand;
}
public static function _goodToGithub($sGood, $bEnter = true)
{
$aGood = json_decode($sGood);
$str = "";
$i = 0;
foreach ($aGood as $sGoodRow) {
if ($i !== 0) {
$str .= "
";
if ($bEnter == true) {
$str .= "
";
}
}
$str .= $sGoodRow;
$i++;
}
return $str;
}
}