优惠券小程序

UserShareRecord.php 946B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. class UserShareRecord extends Model
  6. {
  7. use HasFactory;
  8. protected $table = 'user_share_record';
  9. public $timestamps = false;
  10. protected static $unguarded = true;
  11. /**
  12. * 分享基础信息保存
  13. * */
  14. public static function saveInfo($userId, $ids, $type)
  15. {
  16. $shareModel = new self;
  17. $shareModel->user_id = $userId;
  18. $shareModel->type = $type;
  19. $shareModel->interest_ids = $ids;
  20. $result = $shareModel->save();
  21. return $result ? $shareModel->id : 0;
  22. }
  23. /**
  24. * 获取分享基础信息
  25. * */
  26. public static function getShareInfo($userId, $shareId)
  27. {
  28. return self::select('id', 'type', 'interest_ids')
  29. ->where('enable', 1)->where('user_id', $userId)
  30. ->where('id', $shareId)->first();
  31. }
  32. }