first commit

This commit is contained in:
浪子
2026-03-19 16:44:38 +08:00
commit ff2af385b9
100 changed files with 16826 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Category extends Model
{
protected $table = 'store_categories';
protected $fillable = [
'type',
'name',
'slug',
'description',
'sort_order',
];
public function packages()
{
return $this->belongsToMany(Package::class, 'store_package_categories', 'category_id', 'package_id');
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class DownloadLog extends Model
{
protected $table = 'store_download_logs';
public $timestamps = false;
protected $fillable = [
'package_id',
'version_id',
'site_url',
'typecho_version',
'php_version',
'ip',
'user_agent',
'created_at',
];
}
+59
View File
@@ -0,0 +1,59 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Package extends Model
{
protected $table = 'store_packages';
protected $fillable = [
'type',
'slug',
'name',
'summary',
'description',
'author',
'homepage',
'icon_url',
'license',
'status',
'is_featured',
'sort_order',
'download_count',
'latest_version',
];
protected $casts = [
'is_featured' => 'boolean',
];
public function versions()
{
return $this->hasMany(Version::class, 'package_id');
}
public function latestStableVersion()
{
return $this->hasOne(Version::class, 'package_id')
->where('is_stable', 1)
->where('is_latest', 1);
}
public function latestVersion()
{
return $this->hasOne(Version::class, 'package_id')
->where('is_latest', 1);
}
public function screenshots()
{
return $this->hasMany(Screenshot::class, 'package_id')->orderBy('sort_order')->orderBy('id');
}
public function categories()
{
return $this->belongsToMany(Category::class, 'store_package_categories', 'package_id', 'category_id');
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Screenshot extends Model
{
protected $table = 'store_screenshots';
protected $fillable = [
'package_id',
'image_url',
'caption',
'sort_order',
];
public function package()
{
return $this->belongsTo(Package::class, 'package_id');
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Database\Factories\UserFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
/** @use HasFactory<UserFactory> */
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Version extends Model
{
protected $table = 'store_versions';
protected $fillable = [
'package_id',
'version',
'changelog',
'typecho_min',
'typecho_max',
'php_min',
'php_max',
'php_extensions',
'package_url',
'package_size',
'sha256',
'is_stable',
'is_latest',
'download_count',
'published_at',
];
protected $casts = [
'is_stable' => 'boolean',
'is_latest' => 'boolean',
'published_at' => 'datetime',
];
public function package()
{
return $this->belongsTo(Package::class, 'package_id');
}
public function getPhpExtensionsArrayAttribute()
{
$value = $this->php_extensions;
if (empty($value)) {
return [];
}
$decoded = json_decode($value, true);
return is_array($decoded) ? $decoded : [];
}
}