ponepaste/includes/Models/User.php

34 lines
869 B
PHP
Raw Normal View History

<?php
2021-08-29 01:26:29 -04:00
namespace PonePaste\Models;
use Illuminate\Database\Eloquent\Model;
class User extends Model {
2023-05-13 21:19:35 -04:00
public const ROLE_MODERATOR = 1;
public const ROLE_ADMIN = 2;
protected $table = 'users';
2021-11-01 16:56:17 -04:00
protected $fillable = [
'username', 'password', 'recovery_code_hash'
2021-11-01 16:56:17 -04:00
];
public function session() {
return $this->hasOne(UserSession::class);
}
public function favourites() {
return $this->belongsToMany(Paste::class, 'user_favourites')->withPivot('created_at')
->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))");
}
2021-08-29 01:26:29 -04:00
public function pastes() {
return $this->hasMany(Paste::class)
->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))");
2021-08-29 01:26:29 -04:00
}
public function badges() {
return $this->hasMany(Badge::class);
}
}