領収証発行サービス
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

29 行
673B

  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. public function setContract(Contract|string $contract): static
  11. {
  12. $id = is_string($contract) ? $contract : $contract->id;
  13. data_set($this, ColumnName::CONTRACT_ID, $id);
  14. return $this;
  15. }
  16. public function contract(): BelongsTo
  17. {
  18. if ($this instanceof Model) {
  19. return $this->belongsTo(Contract::class);
  20. } else {
  21. throw new LogicException("不正");
  22. }
  23. }
  24. }