You've already forked Atomcms-edit
Initial commit
This commit is contained in:
+53
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Community\RareValue;
|
||||
|
||||
use App\Models\Game\Furniture\CatalogItem;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $item_name
|
||||
* @property int $category_id
|
||||
* @property int $item_id
|
||||
* @property int $currency_type
|
||||
* @property int $cost
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read WebsiteRareValueCategory|null $category
|
||||
* @property-read CatalogItem|null $item
|
||||
*/
|
||||
class WebsiteRareValue extends Model
|
||||
{
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
#[\Override]
|
||||
protected function casts()
|
||||
{
|
||||
return [
|
||||
'currency_type' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WebsiteRareValueCategory::class, 'category_id');
|
||||
}
|
||||
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CatalogItem::class, 'item_id', 'item_ids');
|
||||
}
|
||||
|
||||
public function isLimitedEdition(): bool
|
||||
{
|
||||
if (is_null($this->item)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->item->limited_stack > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Community\RareValue;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $badge
|
||||
* @property int $priority
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection<int, WebsiteRareValue> $furniture
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteRareValueCategory orderBy($column, $direction = 'asc')
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteRareValueCategory has($relation, $operator = '>=', $count = 1)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteRareValueCategory get($columns = ['*'])
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteRareValueCategory whereId($id)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteRareValueCategory whereHas($relation, \Closure $callback = null, $operator = '>=', $count = 1)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteRareValueCategory withCount($relations)
|
||||
*/
|
||||
class WebsiteRareValueCategory extends Model
|
||||
{
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
#[\Override]
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'priority' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function furniture(): HasMany
|
||||
{
|
||||
return $this->hasMany(WebsiteRareValue::class, 'category_id');
|
||||
}
|
||||
|
||||
public function getTotalValue(): int
|
||||
{
|
||||
return $this->furniture->sum(fn ($rare) => $rare->credit_value ?? 0);
|
||||
}
|
||||
|
||||
public function getAverageValue(): float
|
||||
{
|
||||
if ($this->furniture->isEmpty()) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return $this->furniture->avg(fn ($rare) => $rare->credit_value ?? 0);
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Community\Staff;
|
||||
|
||||
use App\Models\Community\Teams\WebsiteTeam;
|
||||
use App\Models\Game\Permission;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteOpenPosition canApply()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteOpenPosition get($columns = ['*'])
|
||||
*/
|
||||
class WebsiteOpenPosition extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
#[\Override]
|
||||
protected $table = 'website_open_positions';
|
||||
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at', 'rank_id'];
|
||||
|
||||
/** @var array<string, string> */
|
||||
#[\Override]
|
||||
protected $casts = [
|
||||
'apply_from' => 'datetime',
|
||||
'apply_to' => 'datetime',
|
||||
];
|
||||
|
||||
#[\Override]
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::deleting(function ($openPosition) {
|
||||
if ($openPosition->position_kind === 'rank' && $openPosition->permission_id) {
|
||||
WebsiteStaffApplications::where('rank_id', $openPosition->permission_id)->delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function permission()
|
||||
{
|
||||
return $this->belongsTo(Permission::class, 'permission_id', 'id');
|
||||
}
|
||||
|
||||
public function team()
|
||||
{
|
||||
return $this->belongsTo(WebsiteTeam::class, 'team_id', 'id');
|
||||
}
|
||||
|
||||
public function applications()
|
||||
{
|
||||
return $this->hasMany(WebsiteStaffApplications::class, 'rank_id', 'permission_id');
|
||||
}
|
||||
|
||||
public function scopeCanApply($query)
|
||||
{
|
||||
return $query->where('apply_from', '<=', now())->where('apply_to', '>', now());
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Community\Staff;
|
||||
|
||||
use App\Models\Community\Teams\WebsiteTeam;
|
||||
use App\Models\Game\Permission;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteStaffApplications where($column, $operator = null, $value = null)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteStaffApplications create($attributes = [])
|
||||
*/
|
||||
class WebsiteStaffApplications extends Model
|
||||
{
|
||||
#[\Override]
|
||||
protected $table = 'website_staff_applications';
|
||||
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at', 'user_id', 'rank_id', 'status'];
|
||||
|
||||
/** @var array<string, string> */
|
||||
#[\Override]
|
||||
protected $casts = [
|
||||
'approved_at' => 'datetime',
|
||||
'rejected_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function approver(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'approved_by');
|
||||
}
|
||||
|
||||
public function rejector(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'rejected_by');
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function rank(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Permission::class, 'rank_id');
|
||||
}
|
||||
|
||||
public function team(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WebsiteTeam::class, 'team_id');
|
||||
}
|
||||
}
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Community\Staff;
|
||||
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property string|null $badge
|
||||
* @property string $color
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection<int, User> $users
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteTeam where($column, $operator = null, $value = null)
|
||||
*/
|
||||
class WebsiteTeam extends Model
|
||||
{
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class, 'team_id', 'id');
|
||||
}
|
||||
|
||||
public function getBadgePath(): string
|
||||
{
|
||||
return sprintf('%s%s.gif', setting('badges_path'), $this->getBadgeName());
|
||||
}
|
||||
|
||||
public function getBadgeName(): string
|
||||
{
|
||||
return $this->badge ?: '';
|
||||
}
|
||||
}
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Community\Teams;
|
||||
|
||||
use App\Models\Community\Staff\WebsiteOpenPosition;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteTeam select($columns = ['*'])
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteTeam where($column, $operator = null, $value = null)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteTeam orderByDesc($column)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteTeam get($columns = ['*'])
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteTeam with($relations)
|
||||
*/
|
||||
class WebsiteTeam extends Model
|
||||
{
|
||||
#[\Override]
|
||||
protected $table = 'website_teams';
|
||||
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at', 'name', 'badge', 'color'];
|
||||
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class, 'team_id', 'id');
|
||||
}
|
||||
|
||||
public function openPositions(): HasMany
|
||||
{
|
||||
return $this->hasMany(WebsiteOpenPosition::class, 'team_id', 'id');
|
||||
}
|
||||
|
||||
public function scopeVisible($query)
|
||||
{
|
||||
return $query->where('hidden_rank', false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user