mirror of
https://github.com/slawkens/myaac.git
synced 2025-11-02 08:56:24 +01:00
Merge branch 'main' into develop
This commit is contained in:
@@ -5,11 +5,15 @@ namespace MyAAC\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property integer $premium_ends_at
|
||||
* @property integer $premend
|
||||
* @property integer $lastday
|
||||
* @property integer $premdays
|
||||
*/
|
||||
class Account extends Model {
|
||||
|
||||
const GRATIS_PREMIUM_DAYS = 65535;
|
||||
|
||||
protected $table = 'accounts';
|
||||
|
||||
public $timestamps = false;
|
||||
@@ -33,38 +37,35 @@ class Account extends Model {
|
||||
|
||||
public function getPremiumDaysAttribute()
|
||||
{
|
||||
if(isset($this->premium_ends_at) || isset($this->premend)) {
|
||||
$col = isset($this->premium_ends_at) ? 'premium_ends_at' : 'premend';
|
||||
$ret = ceil(($this->{$col}- time()) / (24 * 60 * 60));
|
||||
return $ret > 0 ? $ret : 0;
|
||||
if(isset($this->premium_ends_at) || isset($this->premend) ||
|
||||
(isCanary() && isset($this->lastday))) {
|
||||
$col = (isset($this->premium_ends_at) ? 'premium_ends_at' : (isset($this->lastday) ? 'lastday' : 'premend'));
|
||||
$ret = ceil(($this->{$col} - time()) / (24 * 60 * 60));
|
||||
return max($ret, 0);
|
||||
}
|
||||
|
||||
if($this->premdays == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
global $config;
|
||||
if(isset($config['lua']['freePremium']) && getBoolean($config['lua']['freePremium'])) return -1;
|
||||
|
||||
if($this->premdays == 65535){
|
||||
return 65535;
|
||||
if($this->premdays == self::GRATIS_PREMIUM_DAYS){
|
||||
return self::GRATIS_PREMIUM_DAYS;
|
||||
}
|
||||
|
||||
$ret = ceil($this->premdays - ((int)date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->lastday))) - date("z", $this->lastday)));
|
||||
return max($ret, 0);
|
||||
}
|
||||
|
||||
public function getIsPremiumAttribute()
|
||||
public function getIsPremiumAttribute(): bool
|
||||
{
|
||||
global $config;
|
||||
if(isset($config['lua']['freePremium']) && getBoolean($config['lua']['freePremium'])) return true;
|
||||
if(isset($this->premium_ends_at) || isset($this->premend) ||
|
||||
(isCanary() && isset($this->lastday))) {
|
||||
$col = (isset($this->premium_ends_at) ? 'premium_ends_at' : (isset($this->lastday) ? 'lastday' : 'premend'));
|
||||
return $this->{$col} > time();
|
||||
}
|
||||
|
||||
if(isset($this->premium_ends_at)) {
|
||||
return $this->premium_ends_at > time();
|
||||
}
|
||||
|
||||
if(isset($this->premend)) {
|
||||
return $this->premend > time();
|
||||
if($this->premdays == self::GRATIS_PREMIUM_DAYS){
|
||||
return true;
|
||||
}
|
||||
|
||||
return ($this->premdays - (date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->lastday))) - date("z", $this->lastday)) > 0);
|
||||
|
||||
15
system/src/Models/AccountEmailVerify.php
Normal file
15
system/src/Models/AccountEmailVerify.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace MyAAC\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AccountEmailVerify extends Model
|
||||
{
|
||||
|
||||
protected $table = TABLE_PREFIX . 'account_emails_verify';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = ['account_id', 'hash', 'sent_at'];
|
||||
|
||||
}
|
||||
@@ -18,7 +18,16 @@ class Changelog extends Model {
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'body', 'type', 'where',
|
||||
'date', 'player_id', 'hide',
|
||||
];
|
||||
|
||||
public function scopeIsPublic($query) {
|
||||
$query->where('hide', '!=', 1);
|
||||
}
|
||||
|
||||
public function player() {
|
||||
return $this->belongsTo(Player::class);
|
||||
}
|
||||
}
|
||||
|
||||
16
system/src/Models/ForumBoard.php
Normal file
16
system/src/Models/ForumBoard.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace MyAAC\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ForumBoard extends Model {
|
||||
|
||||
protected $table = TABLE_PREFIX . 'forum_boards';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'description', 'ordering',
|
||||
'guild', 'access', 'closed', 'hide',
|
||||
];
|
||||
}
|
||||
@@ -10,4 +10,9 @@ class Gallery extends Model {
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'comment', 'image', 'thumb',
|
||||
'author', 'ordering', 'hide',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
15
system/src/Models/NewsCategory.php
Normal file
15
system/src/Models/NewsCategory.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace MyAAC\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class NewsCategory extends Model {
|
||||
|
||||
protected $table = TABLE_PREFIX . 'news_categories';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'description', 'icon_id', 'hide'
|
||||
];
|
||||
}
|
||||
@@ -9,6 +9,10 @@ class PlayerOnline extends Model {
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'player_id',
|
||||
];
|
||||
|
||||
public function player()
|
||||
{
|
||||
return $this->belongsTo(Player::class);
|
||||
|
||||
@@ -10,6 +10,6 @@ class Visitor extends Model {
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = ['ip', 'lastivist', 'page', 'user_agent'];
|
||||
protected $fillable = ['ip', 'lastvisit', 'page', 'user_agent'];
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user