領収証発行サービス
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

31 linhas
735B

  1. <?php
  2. namespace App\Models\Feature;
  3. use App\Models\ColumnName;
  4. use App\Models\Contract;
  5. use Illuminate\Database\Eloquent\Model;
  6. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  7. use LogicException;
  8. trait ContractFeature
  9. {
  10. const COL_NAME_CONTRACT_ID = ColumnName::CONTRACT_ID;
  11. public function setContract(Contract|string $contract): static
  12. {
  13. $id = is_string($contract) ? $contract : $contract->id;
  14. data_set($this, self::COL_NAME_CONTRACT_ID, $id);
  15. return $this;
  16. }
  17. public function contract(): BelongsTo
  18. {
  19. if ($this instanceof Model) {
  20. return $this->belongsTo(Contract::class);
  21. } else {
  22. throw new LogicException("不正");
  23. }
  24. }
  25. }