Files
Wian Drs 1e80be180e
tests / ci (push) Has been cancelled
Initial commit device-management
2026-08-25 09:42:00 +07:00

33 lines
1004 B
PHP

<?php
namespace App\Models;
use App\Casts\TenantEncrypted;
use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
class DeviceCredential extends Model
{
use BelongsToTenant;
protected $fillable = ['tenant_id', 'device_id', 'name', 'username', 'password', 'enable_password', 'connection_type', 'privilege_type', 'is_master', 'is_active', 'last_verified_at', 'created_by', 'updated_by'];
protected $hidden = ['password', 'enable_password'];
protected static function booted(): void
{
static::creating(fn (DeviceCredential $credential) => $credential->uuid ??= (string) Str::uuid());
}
protected function casts(): array
{
return ['password' => TenantEncrypted::class, 'enable_password' => TenantEncrypted::class, 'is_master' => 'boolean', 'is_active' => 'boolean', 'last_verified_at' => 'datetime'];
}
public function device()
{
return $this->belongsTo(Device::class);
}
}