MemberGroup.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 2017/2/23
  6. * Time: 下午6:01
  7. */
  8. namespace app\common\models;
  9. use Illuminate\Database\Eloquent\Builder;
  10. use Illuminate\Database\Eloquent\SoftDeletes;
  11. /**
  12. *
  13. * @method static self records()
  14. *
  15. * Class MemberGroup
  16. * @package app\common\models
  17. */
  18. class MemberGroup extends BaseModel
  19. {
  20. use SoftDeletes;
  21. protected $table = 'yz_member_group';
  22. /*public static function boot()
  23. {
  24. parent::boot();
  25. static::addGlobalScope('uniacid',function (Builder $builder) {
  26. return $builder->uniacid();
  27. });
  28. }*/
  29. public function scopeRecords($query)
  30. {
  31. return $query->uniacid()->select('id','group_name');
  32. }
  33. /**
  34. * Get member group information by groupId
  35. *
  36. * @param array $data
  37. *
  38. * @return 1 or 0
  39. * */
  40. protected static function getMemberGroupByGroupID($groupId)
  41. {
  42. return static::uniacid()->where('id', $groupId)->first(1)->toArray();
  43. }
  44. /**
  45. * 获取默认组
  46. *
  47. * @return mixed
  48. */
  49. public static function getDefaultGroupId()
  50. {
  51. return self::select('id')
  52. ->uniacid()
  53. ->where('is_default', 1);
  54. }
  55. }