/
DATKAI
/
ITCUP
Обзор
Документация
Войти
/
DATKAI
/
ITCUP
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
app/Models/Credential.php
43 строки
918 B
ITCUP Admin
Initial commit: ITCUP — базовая структура, инвентарь, задачник, пользователи
17 апр 2026, 09:29
17 апр 2026, 09:29
a2ae386
Код
Авторство
О чём код?
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; class Credential extends Model { protected $fillable = [ 'user_id', 'service', 'login', 'password', 'url', 'notes', 'password_changed_at', 'expires_at', ]; protected $casts = [ 'password' => 'encrypted', 'password_changed_at' => 'date', 'expires_at' => 'date', ]; public function user(): BelongsTo { return $this->belongsTo(User::class); } public function isExpired(): bool { return $this->expires_at && $this->expires_at->isPast(); } public function isExpiringSoon(int $days = 14): bool { return $this->expires_at && !$this->expires_at->isPast() && $this->expires_at->diffInDays(now()) <= $days; } }