Initial commit: Animexe Laravel platform

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-14 00:01:48 +03:00
co-authored by Claude Opus 4.8
commit a63515cfc6
366 changed files with 74773 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ActivationCode extends Model
{
protected $fillable = [
'code', 'plan_id', 'used_by', 'used_at',
'created_by', 'expires_at', 'batch', 'notes',
];
protected $casts = [
'used_at' => 'datetime',
'expires_at' => 'datetime',
];
public function plan(): BelongsTo
{
return $this->belongsTo(MembershipPlan::class, 'plan_id');
}
public function usedBy(): BelongsTo
{
return $this->belongsTo(User::class, 'used_by');
}
public function createdBy(): BelongsTo
{
return $this->belongsTo(User::class, 'created_by');
}
public function isUsed(): bool
{
return ! is_null($this->used_at);
}
public function isExpired(): bool
{
return $this->expires_at && $this->expires_at->isPast();
}
public function isValid(): bool
{
return ! $this->isUsed() && ! $this->isExpired();
}
public static function generateCode(): string
{
do {
$hex = strtoupper(bin2hex(random_bytes(6)));
$code = implode('-', str_split($hex, 4));
} while (self::where('code', $code)->exists());
return $code;
}
}