init
This commit is contained in:
232 files changed
+25416
No files matched your search
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\BazaarApiRequestFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
#[Fillable(['mobile_app_id', 'operation', 'method', 'url', 'status_code', 'successful', 'duration_ms', 'request_metadata', 'response_body', 'error_message'])]
|
||||
class BazaarApiRequest extends Model
|
||||
{
|
||||
/** @use HasFactory<BazaarApiRequestFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $attributes = ['successful' => false];
|
||||
|
||||
public function mobileApp(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MobileApp::class);
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'successful' => 'boolean',
|
||||
'request_metadata' => 'array',
|
||||
'response_body' => 'array',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\BazaarPurchaseFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
#[Fillable(['mobile_app_id', 'product_id', 'purchase_token', 'purchase_token_hash', 'status', 'is_consumed', 'purchased_at', 'validated_at', 'bazaar_response'])]
|
||||
#[Hidden(['purchase_token', 'purchase_token_hash'])]
|
||||
class BazaarPurchase extends Model
|
||||
{
|
||||
/** @use HasFactory<BazaarPurchaseFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $attributes = ['status' => 'unknown'];
|
||||
|
||||
public function mobileApp(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MobileApp::class);
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saving(function (BazaarPurchase $purchase): void {
|
||||
if ($purchase->isDirty('purchase_token')) {
|
||||
$purchase->purchase_token_hash = hash('sha256', $purchase->purchase_token);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_consumed' => 'boolean',
|
||||
'purchase_token' => 'encrypted',
|
||||
'purchased_at' => 'datetime',
|
||||
'validated_at' => 'datetime',
|
||||
'bazaar_response' => 'array',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\BazaarReleaseFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
#[Fillable(['mobile_app_id', 'bazaar_release_id', 'status', 'artifact_type', 'staged_rollout_percentage', 'auto_publish', 'changelog_fa', 'changelog_en', 'developer_note', 'bazaar_response', 'committed_at', 'published_at'])]
|
||||
class BazaarRelease extends Model
|
||||
{
|
||||
/** @use HasFactory<BazaarReleaseFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $attributes = [
|
||||
'status' => 'draft',
|
||||
'staged_rollout_percentage' => 100,
|
||||
'auto_publish' => false,
|
||||
];
|
||||
|
||||
public function mobileApp(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MobileApp::class);
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'auto_publish' => 'boolean',
|
||||
'bazaar_response' => 'array',
|
||||
'committed_at' => 'datetime',
|
||||
'published_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\BazaarReviewFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
#[Fillable(['mobile_app_id', 'bazaar_review_id', 'user_account_id', 'rate', 'text', 'app_version_code', 'is_edited', 'published_at', 'developer_reply_text', 'developer_reply_email', 'developer_replied_at', 'bazaar_response'])]
|
||||
class BazaarReview extends Model
|
||||
{
|
||||
/** @use HasFactory<BazaarReviewFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $attributes = ['is_edited' => false];
|
||||
|
||||
public function mobileApp(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MobileApp::class);
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_edited' => 'boolean',
|
||||
'published_at' => 'datetime',
|
||||
'developer_replied_at' => 'datetime',
|
||||
'bazaar_response' => 'array',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\BazaarSubscriptionFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
#[Fillable(['mobile_app_id', 'subscription_id', 'purchase_token', 'purchase_token_hash', 'linked_subscription_token', 'status', 'auto_renewing', 'starts_at', 'valid_until', 'validated_at', 'bazaar_response'])]
|
||||
#[Hidden(['purchase_token', 'purchase_token_hash', 'linked_subscription_token'])]
|
||||
class BazaarSubscription extends Model
|
||||
{
|
||||
/** @use HasFactory<BazaarSubscriptionFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $attributes = ['status' => 'unknown'];
|
||||
|
||||
public function mobileApp(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MobileApp::class);
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saving(function (BazaarSubscription $subscription): void {
|
||||
if ($subscription->isDirty('purchase_token')) {
|
||||
$subscription->purchase_token_hash = hash('sha256', $subscription->purchase_token);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'auto_renewing' => 'boolean',
|
||||
'purchase_token' => 'encrypted',
|
||||
'starts_at' => 'datetime',
|
||||
'valid_until' => 'datetime',
|
||||
'validated_at' => 'datetime',
|
||||
'bazaar_response' => 'array',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\MobileAppFactory;
|
||||
use Filament\Models\Contracts\HasName;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
#[Fillable([
|
||||
'name',
|
||||
'package_name',
|
||||
'client_key',
|
||||
'management_key',
|
||||
'is_active',
|
||||
'maintenance_mode',
|
||||
'latest_version_name',
|
||||
'latest_version_code',
|
||||
'minimum_version_code',
|
||||
'store_url',
|
||||
'privacy_url',
|
||||
'support_email',
|
||||
'configuration',
|
||||
'feature_flags',
|
||||
'bazaar_api_secret',
|
||||
'bazaar_comments_header',
|
||||
'bazaar_comments_secret',
|
||||
'bazaar_login_client_id',
|
||||
'bazaar_login_client_secret',
|
||||
'bazaar_login_redirect_url',
|
||||
'bazaar_billing_public_key',
|
||||
'bazaar_sync_enabled',
|
||||
'bazaar_sync_interval_minutes',
|
||||
'bazaar_sync_status',
|
||||
'bazaar_sync_started_at',
|
||||
'bazaar_last_synced_at',
|
||||
'bazaar_sync_error',
|
||||
'bazaar_sync_summary',
|
||||
])]
|
||||
#[Hidden([
|
||||
'client_key',
|
||||
'management_key',
|
||||
'bazaar_api_secret',
|
||||
'bazaar_comments_secret',
|
||||
'bazaar_login_client_secret',
|
||||
'bazaar_billing_public_key',
|
||||
])]
|
||||
class MobileApp extends Model implements HasName
|
||||
{
|
||||
/** @use HasFactory<MobileAppFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $attributes = [
|
||||
'is_active' => true,
|
||||
'maintenance_mode' => false,
|
||||
'bazaar_sync_enabled' => true,
|
||||
'bazaar_sync_interval_minutes' => 15,
|
||||
'bazaar_sync_status' => 'idle',
|
||||
];
|
||||
|
||||
public function getFilamentName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getRouteKeyName(): string
|
||||
{
|
||||
return 'package_name';
|
||||
}
|
||||
|
||||
public function users(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class)->withPivot('role')->withTimestamps();
|
||||
}
|
||||
|
||||
public function bazaarPurchases(): HasMany
|
||||
{
|
||||
return $this->hasMany(BazaarPurchase::class);
|
||||
}
|
||||
|
||||
public function bazaarSubscriptions(): HasMany
|
||||
{
|
||||
return $this->hasMany(BazaarSubscription::class);
|
||||
}
|
||||
|
||||
public function bazaarReleases(): HasMany
|
||||
{
|
||||
return $this->hasMany(BazaarRelease::class);
|
||||
}
|
||||
|
||||
public function bazaarReviews(): HasMany
|
||||
{
|
||||
return $this->hasMany(BazaarReview::class);
|
||||
}
|
||||
|
||||
public function bazaarApiRequests(): HasMany
|
||||
{
|
||||
return $this->hasMany(BazaarApiRequest::class);
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'client_key' => 'encrypted',
|
||||
'management_key' => 'encrypted',
|
||||
'is_active' => 'boolean',
|
||||
'maintenance_mode' => 'boolean',
|
||||
'configuration' => 'array',
|
||||
'feature_flags' => 'array',
|
||||
'bazaar_api_secret' => 'encrypted',
|
||||
'bazaar_comments_secret' => 'encrypted',
|
||||
'bazaar_login_client_secret' => 'encrypted',
|
||||
'bazaar_billing_public_key' => 'encrypted',
|
||||
'bazaar_sync_enabled' => 'boolean',
|
||||
'bazaar_sync_interval_minutes' => 'integer',
|
||||
'bazaar_sync_started_at' => 'datetime',
|
||||
'bazaar_last_synced_at' => 'datetime',
|
||||
'bazaar_sync_summary' => 'array',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Database\Factories\UserFactory;
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Filament\Models\Contracts\HasTenants;
|
||||
use Filament\Panel;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
#[Fillable(['name', 'email', 'password'])]
|
||||
#[Hidden(['password', 'remember_token'])]
|
||||
class User extends Authenticatable implements FilamentUser, HasTenants
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
public function canAccessPanel(Panel $panel): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function mobileApps(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(MobileApp::class)->withPivot('role')->withTimestamps();
|
||||
}
|
||||
|
||||
public function getTenants(Panel $panel): Collection
|
||||
{
|
||||
return $this->mobileApps;
|
||||
}
|
||||
|
||||
public function canAccessTenant(Model $tenant): bool
|
||||
{
|
||||
return $tenant instanceof MobileApp && $this->mobileApps()->whereKey($tenant)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user