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\BelongsToTenantTrait; | ||||
use App\Traits\BelongsToUserTrait; | |||||
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 ?int $user_id | ||||
* @property ?\App\User $user | |||||
*/ | */ | ||||
class SignupInvitation extends Model | class SignupInvitation extends Model | ||||
{ | { | ||||
use BelongsToTenantTrait; | use BelongsToTenantTrait; | ||||
use BelongsToUserTrait; | |||||
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 All 39 Lines | class SignupInvitation extends Model | ||||
* Returns whether this invitation has been sent. | * Returns whether this invitation has been sent. | ||||
* | * | ||||
* @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 account to which the invitation was used for. | |||||
* | |||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | |||||
*/ | |||||
public function user() | |||||
{ | |||||
return $this->belongsTo(User::class, 'user_id', 'id'); | |||||
} | |||||
} | } |