Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Vendor.php 1.3KB

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