Deploy Ladill Hosting / deploy (push) Failing after 17s
Shared web hosting extracted from the platform monolith, with CI deploy to /var/www/ladill-hosting matching Bird/Domains/Email. Co-authored-by: Cursor <cursoragent@cursor.com>
49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/** Membership linking a user to an account (owner) they manage email for. */
|
|
class EmailTeamMember extends Model
|
|
{
|
|
public const ROLE_ADMIN = 'admin';
|
|
public const ROLE_MEMBER = 'member';
|
|
|
|
public const STATUS_INVITED = 'invited';
|
|
public const STATUS_ACTIVE = 'active';
|
|
|
|
protected $fillable = ['account_id', 'user_id', 'email', 'role', 'status', 'token', 'accepted_at'];
|
|
|
|
protected $casts = ['accepted_at' => 'datetime'];
|
|
|
|
public function account(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'account_id');
|
|
}
|
|
|
|
public function member(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'user_id');
|
|
}
|
|
|
|
/**
|
|
* Link any pending invites for this email to the user (called on SSO login),
|
|
* so invited teammates gain access the first time they sign in.
|
|
*/
|
|
public static function linkPendingInvitesFor(User $user): void
|
|
{
|
|
static::query()
|
|
->whereNull('user_id')
|
|
->where('status', self::STATUS_INVITED)
|
|
->whereRaw('LOWER(email) = ?', [strtolower($user->email)])
|
|
->update([
|
|
'user_id' => $user->id,
|
|
'status' => self::STATUS_ACTIVE,
|
|
'accepted_at' => now(),
|
|
'token' => null,
|
|
]);
|
|
}
|
|
}
|