You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/common/model/invite/InviteConfig.php

55 lines
1.2 KiB

10 months ago
<?php
namespace app\common\model\invite;
10 months ago
use app\common\model\Coupon;
10 months ago
use cores\BaseModel;
10 months ago
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\model\relation\HasOne;
10 months ago
class InviteConfig extends BaseModel
{
// 定义表名
protected $name = 'invite_config';
// 定义主键
protected $pk = 'id';
10 months ago
public function coupon(): HasOne
10 months ago
{
10 months ago
return $this->hasOne(Coupon::class, 'coupon_id', 'coupon_id');
10 months ago
}
/**
* @notes:新增
* @param $data
* @return bool
10 months ago
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
10 months ago
* @author: wanghousheng
*/
public function add($data): bool
{
10 months ago
if ($this->where(['store_id' => self::$storeId])->find()) {
return $this->where(['store_id' => self::$storeId])->save($data) !== false;
}
10 months ago
$data['store_id'] = self::$storeId;
return $this->save($data);
}
/**
* 详情
* @param array $where
10 months ago
* @param array $with
10 months ago
* @return static|array|null
*/
10 months ago
public static function detail(array $where = [], array $with = [])
10 months ago
{
10 months ago
return self::get($where, $with);
10 months ago
}
}