您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Vendor.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace App\Models\Common;
  3. use App\Concerns\Blamable;
  4. use App\Concerns\CompanyOwned;
  5. use App\Models\Setting\Currency;
  6. use Illuminate\Database\Eloquent\Factories\HasFactory;
  7. use Illuminate\Database\Eloquent\Model;
  8. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  9. use Illuminate\Database\Eloquent\Relations\MorphOne;
  10. class Vendor extends Model
  11. {
  12. use Blamable;
  13. use CompanyOwned;
  14. use HasFactory;
  15. protected $table = 'vendors';
  16. protected $fillable = [
  17. 'company_id',
  18. 'name',
  19. 'type',
  20. 'contractor_type',
  21. 'ssn',
  22. 'currency_code',
  23. 'account_number',
  24. 'website',
  25. 'notes',
  26. 'created_by',
  27. 'updated_by',
  28. ];
  29. public function currency(): BelongsTo
  30. {
  31. return $this->belongsTo(Currency::class, 'currency_code', 'code');
  32. }
  33. public function address(): MorphOne
  34. {
  35. return $this->morphOne(Address::class, 'addressable');
  36. }
  37. public function contact(): MorphOne
  38. {
  39. return $this->morphOne(Contact::class, 'contactable');
  40. }
  41. }