* @license GPL https://xxx.com * @link https://xxx.com * @ctime: 2020/5/13 15:47 */ namespace App\Models; use App\Maps\CacheMap; use Carbon\Carbon; use Illuminate\Support\Facades\Cache; class AdminMerchant extends Model { const STATUS_OK = 1; const STATUS_PAUSE = 0; public static $statusMaps = [ self::STATUS_OK => '正常', self::STATUS_PAUSE => '暂停', ]; protected $guarded = []; /** * 通过id获取数据 * @param $id * Author: Mead */ public static function byId($id) { if (CacheMap::IS_OPEN_DB_CACHE) { return Cache::remember(CacheMap::DB . "AdminMerchantRepository:byIdGetModel:" . $id, Carbon::now()->addHours(24), function () use ($id) { return self::where('id', $id)->where('status', AdminMerchant::STATUS_OK)->first(); }); } return self::where('id', $id)->where('status', AdminMerchant::STATUS_OK)->first(); } public static function byIdNoStatus($id) { if (CacheMap::IS_OPEN_DB_CACHE) { return Cache::remember(CacheMap::DB . "AdminMerchantRepository:byIdNoStatus:" . $id, Carbon::now()->addHours(24), function () use ($id) { return self::where('id', $id)->first(); }); } return self::where('id', $id)->first(); } public function getOrderKey($v) { return strtoupper($v); } }