Customer.php 919 B

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