2021-08-27 06:46:27 -04:00
|
|
|
<?php
|
2021-08-29 01:26:29 -04:00
|
|
|
namespace PonePaste\Models;
|
|
|
|
|
2021-08-27 06:46:27 -04:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class User extends Model {
|
|
|
|
protected $table = 'users';
|
2021-11-01 16:56:17 -04:00
|
|
|
protected $fillable = [
|
2023-02-24 06:26:40 -05:00
|
|
|
'username', 'password', 'recovery_code_hash'
|
2021-11-01 16:56:17 -04:00
|
|
|
];
|
2021-08-27 06:46:27 -04:00
|
|
|
|
|
|
|
public function session() {
|
|
|
|
return $this->hasOne(UserSession::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function favourites() {
|
2022-04-19 19:36:18 -04:00
|
|
|
return $this->belongsToMany(Paste::class, 'user_favourites')->withPivot('f_time')
|
|
|
|
->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))");
|
2021-08-27 06:46:27 -04:00
|
|
|
}
|
|
|
|
|
2021-08-29 01:26:29 -04:00
|
|
|
public function pastes() {
|
2022-04-19 19:36:18 -04:00
|
|
|
return $this->hasMany(Paste::class)
|
|
|
|
->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))");
|
2021-08-29 01:26:29 -04:00
|
|
|
}
|
2023-02-24 06:26:40 -05:00
|
|
|
|
|
|
|
public function badges() {
|
|
|
|
return $this->hasMany(Badge::class);
|
|
|
|
}
|
2021-08-27 06:46:27 -04:00
|
|
|
}
|
|
|
|
|