| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace app\common\model;
- use fast\Asset;
- use fast\Http;
- use fast\Random;
- use think\Cache;
- use think\Log;
- use think\Model;
- use think\Request;
- class UserCollect extends Model
- {
- protected $name = "user_collect";
- //设置用户收藏
- public static function setUserCollect(int $uid, int $marketId)
- {
- $rows = self::where('user_id', $uid)->where('product_id', $marketId)->find();
- if($rows){
- return $rows->delete();
- }else{
- return self::create(['user_id'=>$uid, 'product_id'=>$marketId]);
- }
- }
- //用户
- public function users()
- {
- return $this->hasOne('UserModel', 'id', 'user_id', [], 'LEFT')->setEagerlyType(0);
- }
-
- }
|