70 lines
1.6 KiB
PHP
70 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class UserMailboxSetting extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
/**
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'user_id',
|
|
'imap_host',
|
|
'imap_port',
|
|
'imap_encryption',
|
|
'imap_validate_cert',
|
|
'imap_username',
|
|
'imap_password',
|
|
'imap_folder',
|
|
'smtp_host',
|
|
'smtp_port',
|
|
'smtp_encryption',
|
|
'smtp_validate_cert',
|
|
'smtp_username',
|
|
'smtp_password',
|
|
'smtp_from_address',
|
|
'smtp_from_name',
|
|
'last_synced_at',
|
|
'last_sync_error',
|
|
];
|
|
|
|
/**
|
|
* @var array<string, string>
|
|
*/
|
|
protected $casts = [
|
|
'imap_validate_cert' => 'boolean',
|
|
'smtp_validate_cert' => 'boolean',
|
|
'imap_password' => 'encrypted',
|
|
'smtp_password' => 'encrypted',
|
|
'last_synced_at' => 'datetime',
|
|
];
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function hasImapConfiguration(): bool
|
|
{
|
|
return filled($this->imap_host)
|
|
&& filled($this->imap_port)
|
|
&& filled($this->imap_username)
|
|
&& filled($this->imap_password);
|
|
}
|
|
|
|
public function hasSmtpConfiguration(): bool
|
|
{
|
|
return filled($this->smtp_host)
|
|
&& filled($this->smtp_port)
|
|
&& filled($this->smtp_username)
|
|
&& filled($this->smtp_password);
|
|
}
|
|
} |