|
- <?php
-
- namespace App\Models\Feature;
-
- use App\Models\ColumnName;
- use App\Models\SMSSendOrder;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use LogicException;
-
- trait SMSSendOrderFeature
- {
- const COL_NAME_SMS_SEND_ORDER_ID = ColumnName::SMS_SEND_ORDER_ID;
-
- public function setSMSSendOrder(SMSSendOrder|string $smsSendOrder)
- {
- $id = is_string($smsSendOrder) ? $smsSendOrder : $smsSendOrder->id;
- data_set($this, self::COL_NAME_SMS_SEND_ORDER_ID, $id);
- }
-
- public function smsSendOrder(): BelongsTo
- {
- if ($this instanceof Model) {
- return $this->belongsTo(SMSSendOrder::class);
- } else {
- throw new LogicException("不正");
- }
- }
- }
|