| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace App\Module\Ulogic\Models;
- use App\Module\Ulogic\Enum\WALLET_ADDRESS_STATUS;
- use App\Module\Ulogic\Enum\WALLET_ADDRESS_TYPE;
- use Dcat\Admin\Traits\HasDateTimeFormatter;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use Illuminate\Support\Str;
- /**
- * 用户钱包地址
- * *
- * * field start
- * field end
- */
- class WalletAddress extends Model
- {
- use HasDateTimeFormatter;
- use SoftDeletes;
- protected $table = 'wallet_address';
- /**
- * @return string
- * 生成uraus地址
- */
- public static function createAddress()
- {
- do {
- $address = Str::lower(Str::random(25)); // 加密安全的随机字符串
- } while (
- self::query()
- ->where(['address' => $address])
- ->exists()
- );
- return $address;
- }
- /**
- * @param $userId
- * @param $type
- * @param $address
- * @return void
- * 新增钱包地址
- */
- public static function createRow($userId, $address)
- {
- $addressModel = new WalletAddress();
- $addressModel->user_id = $userId;
- $addressModel->address = $address;
- $addressModel->save();
- }
- /**
- * @param $field
- * @param $where
- * @return null
- * 获取数据
- */
- public static function getInfoByCondition($field, $where)
- {
- $query = self::query();
- $query->where($field, $where);
- return $query->first();
- }
- }
|