Chengjiu.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Repositories\Models\Dwbs;
  3. use App\Repositories\Models\Base\User;
  4. use App\Repositories\Models\Model;
  5. class Chengjiu extends Model
  6. {
  7. /**
  8. * @var string
  9. */
  10. protected $table = 'user_chengjius';
  11. protected $guarded = [];
  12. /**
  13. * The attributes excluded from the model's JSON form.
  14. *
  15. * @var array
  16. */
  17. protected $hidden = [];
  18. protected $casts = [
  19. 'data' => 'json'
  20. ];
  21. protected static function booted()
  22. {
  23. parent::booted(); // TODO: Change the autogenerated stub
  24. //todo:消息提醒
  25. self::created(function (Chengjiu $model) {
  26. //兑换提醒
  27. });
  28. }
  29. public function user()
  30. {
  31. return $this->belongsTo(User::class)->select(['id', 'nickname', 'headimg', 'mobile', 'mobile_encryption', 'mobile_code']);
  32. }
  33. public function getPathAttribute($val)
  34. {
  35. if (empty($val)) {
  36. return config('app.url') . '/default/headimg.png';
  37. }
  38. return path_to_url($val);
  39. }
  40. }