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