Customer.php 980 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App;
  3. use App\Traits\ModelTimeFormat;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\Relations\HasMany;
  6. use App\Traits\LogModelChanging;
  7. class Customer extends Model
  8. {
  9. use LogModelChanging;
  10. use ModelTimeFormat;
  11. protected $fillable = [
  12. "code", //客户代码
  13. "name", //客户名称
  14. "company_name", //公司名称
  15. "invoice_address", //发票地址
  16. "contact_man", //联系人
  17. "phone", //联系电话
  18. "remark", //公司备注
  19. ];
  20. public function customerLogs(): HasMany
  21. {
  22. return $this->hasMany(CustomerLog::class,'customer_id','id');
  23. }
  24. public function owners()
  25. { //子项目
  26. return $this->hasMany(Owner::class,"customer_id","id");
  27. }
  28. public function tags()
  29. { //标签
  30. return $this->belongsToMany(CustomerTag::class,"customer_tag_customer");
  31. }
  32. }