MarketCustomerFollow.php 771 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace app\model;
  3. use DateTimeInterface;
  4. use Illuminate\Database\Eloquent\Casts\Attribute;
  5. use support\Model;
  6. class MarketCustomerFollow extends Model
  7. {
  8. protected $table = 'market_customer_follow';
  9. protected $dateFormat = 'U';
  10. public function serializeDate(DateTimeInterface $date)
  11. {
  12. return $date->format('Y-m-d H:i:s');
  13. }
  14. protected function followTime():Attribute
  15. {
  16. return Attribute::get(function ($value) {
  17. return date('Y-m-d H:i:s', $value);
  18. });
  19. }
  20. public function custom()
  21. {
  22. return $this->belongsTo(MarketCustomer::class, 'market_customer_id');
  23. }
  24. public function consultant()
  25. {
  26. return $this->belongsTo(Consultant::class, 'consultant_id');
  27. }
  28. }