You've already forked Atomcms-edit
Initial commit
This commit is contained in:
Executable
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use App\Models\Concerns\BelongsToUser;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class WebsitePaypalTransaction extends Model
|
||||
{
|
||||
use BelongsToUser;
|
||||
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
}
|
||||
Executable
+76
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use App\Models\Game\Furniture\ItemBase;
|
||||
use App\Models\Game\Permission;
|
||||
use Carbon\Carbon;
|
||||
use Database\Factories\WebsiteShopArticleFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property string $furniture
|
||||
* @property int $give_rank
|
||||
* @property int $costs
|
||||
* @property int $sort_order
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection<int, ItemBase> $furniItems
|
||||
* @property-read Permission|null $rank
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, WebsiteShopArticleFeature> $features
|
||||
* @property-read float|int $price
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteShopArticle orderBy($column, $direction = 'asc')
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteShopArticle get($columns = ['*'])
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteShopArticle with($relations)
|
||||
*/
|
||||
class WebsiteShopArticle extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected static function newFactory()
|
||||
{
|
||||
return WebsiteShopArticleFactory::new();
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at', 'price', 'credits', 'duckets', 'diamonds', 'give_rank', 'badges', 'furniture', 'is_giftable'];
|
||||
|
||||
public function furniItems(): Collection
|
||||
{
|
||||
if (! $this->furniture) {
|
||||
return collect();
|
||||
}
|
||||
|
||||
$furniture = json_decode($this->furniture, true);
|
||||
$furnitureIds = array_column($furniture, 'item_id');
|
||||
|
||||
return ItemBase::query()->whereIn('id', $furnitureIds)->get();
|
||||
}
|
||||
|
||||
public function rank(): HasOne
|
||||
{
|
||||
return $this->hasOne(Permission::class, 'id', 'give_rank');
|
||||
}
|
||||
|
||||
public function features(): HasMany
|
||||
{
|
||||
return $this->HasMany(WebsiteShopArticleFeature::class, 'article_id', 'id');
|
||||
}
|
||||
|
||||
public function price(): float|int
|
||||
{
|
||||
if ($this->costs < 100) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return $this->costs / 100;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class WebsiteShopArticleFeature extends Model
|
||||
{
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at', 'article_id', 'feature'];
|
||||
|
||||
public function article(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WebsiteShopArticle::class, 'article_id', 'id');
|
||||
}
|
||||
}
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Database\Factories\Shop\WebsiteShopCategoryFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteShopCategory whereHas($relation, \Closure $callback = null, $operator = '>=', $count = 1)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteShopCategory get($columns = ['*'])
|
||||
*/
|
||||
class WebsiteShopCategory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
protected static function newFactory()
|
||||
{
|
||||
return WebsiteShopCategoryFactory::new();
|
||||
}
|
||||
|
||||
public function articles(): HasMany
|
||||
{
|
||||
return $this->hasMany(WebsiteShopArticle::class);
|
||||
}
|
||||
}
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteShopVoucher where($column, $operator = null, $value = null)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|WebsiteShopVoucher first()
|
||||
*/
|
||||
class WebsiteShopVoucher extends Model
|
||||
{
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at', 'code', 'amount', 'max_uses', 'expires_at'];
|
||||
|
||||
/** @var array<string, string> */
|
||||
#[\Override]
|
||||
protected $casts = [
|
||||
'expires_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class WebsiteUsedShopVoucher extends Model
|
||||
{
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at', 'user_id', 'voucher_id'];
|
||||
|
||||
public function used(): HasMany
|
||||
{
|
||||
return $this->hasMany(WebsiteUsedShopVoucher::class, 'voucher_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user