Changeset View
Changeset View
Standalone View
Standalone View
src/app/SignupInvitation.php
<?php | <?php | ||||
namespace App; | namespace App; | ||||
use Carbon\Carbon; | use Carbon\Carbon; | ||||
use Illuminate\Database\Eloquent\Model; | use Illuminate\Database\Eloquent\Model; | ||||
use App\Traits\BelongsToTenantTrait; | |||||
use App\Traits\UuidStrKeyTrait; | use App\Traits\UuidStrKeyTrait; | ||||
/** | /** | ||||
* The eloquent definition of a signup invitation. | * The eloquent definition of a signup invitation. | ||||
* | * | ||||
* @property string $email | * @property string $email | ||||
* @property string $id | * @property string $id | ||||
* @property ?int $tenant_id | * @property ?int $tenant_id | ||||
* @property ?\App\Tenant $tenant | * @property ?\App\Tenant $tenant | ||||
* @property ?\App\User $user | * @property ?\App\User $user | ||||
*/ | */ | ||||
class SignupInvitation extends Model | class SignupInvitation extends Model | ||||
{ | { | ||||
use BelongsToTenantTrait; | |||||
use UuidStrKeyTrait; | use UuidStrKeyTrait; | ||||
// just created | // just created | ||||
public const STATUS_NEW = 1 << 0; | public const STATUS_NEW = 1 << 0; | ||||
// it's been sent successfully | // it's been sent successfully | ||||
public const STATUS_SENT = 1 << 1; | public const STATUS_SENT = 1 << 1; | ||||
// sending failed | // sending failed | ||||
public const STATUS_FAILED = 1 << 2; | public const STATUS_FAILED = 1 << 2; | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | class SignupInvitation extends Model | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
public function isSent(): bool | public function isSent(): bool | ||||
{ | { | ||||
return ($this->status & self::STATUS_SENT) > 0; | return ($this->status & self::STATUS_SENT) > 0; | ||||
} | } | ||||
/** | /** | ||||
* The tenant for this invitation. | |||||
* | |||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | |||||
*/ | |||||
public function tenant() | |||||
{ | |||||
return $this->belongsTo('App\Tenant', 'tenant_id', 'id'); | |||||
} | |||||
/** | |||||
* The account to which the invitation was used for. | * The account to which the invitation was used for. | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||||
*/ | */ | ||||
public function user() | public function user() | ||||
{ | { | ||||
return $this->belongsTo('App\User', 'user_id', 'id'); | return $this->belongsTo('App\User', 'user_id', 'id'); | ||||
} | } | ||||
} | } |