refactor(backend): reorganize domains into Core, Commerce, Ticketing and Shared
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Integration\Models;
|
||||
|
||||
use App\Domains\Tenant\Models\AdminWebsiteType;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class AdminWebsiteTypeIntegration extends Model
|
||||
{
|
||||
protected $table = 'admin_website_type_integrations';
|
||||
protected $fillable = ['admin_website_type_code', 'integration_code', 'integration_instance_id'];
|
||||
|
||||
/** @return BelongsTo<AdminWebsiteType, $this> */
|
||||
public function adminWebsiteType(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AdminWebsiteType::class, 'admin_website_type_code', 'codigo');
|
||||
}
|
||||
|
||||
/** @return BelongsTo<Integration, $this> */
|
||||
public function integration(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Integration::class, 'integration_code', 'integration_code');
|
||||
}
|
||||
|
||||
/** @return BelongsTo<IntegrationInstance, $this> */
|
||||
public function integrationInstance(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(IntegrationInstance::class);
|
||||
}
|
||||
}
|
||||
34
app/Shared/Integration/Models/ClientIntegration.php
Normal file
34
app/Shared/Integration/Models/ClientIntegration.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Integration\Models;
|
||||
|
||||
use App\Domains\Client\Models\Client;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ClientIntegration extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'client_id',
|
||||
'integration_code',
|
||||
'integration_instance_id',
|
||||
];
|
||||
|
||||
/** @return BelongsTo<Client, $this> */
|
||||
public function client(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Client::class);
|
||||
}
|
||||
|
||||
/** @return BelongsTo<Integration, $this> */
|
||||
public function integration(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Integration::class, 'integration_code', 'integration_code');
|
||||
}
|
||||
|
||||
/** @return BelongsTo<IntegrationInstance, $this> */
|
||||
public function integrationInstance(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(IntegrationInstance::class);
|
||||
}
|
||||
}
|
||||
42
app/Shared/Integration/Models/Integration.php
Normal file
42
app/Shared/Integration/Models/Integration.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Integration\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Integration extends Model
|
||||
{
|
||||
protected $table = 'integrations';
|
||||
|
||||
protected $fillable = [
|
||||
'integration_code',
|
||||
'name',
|
||||
'url',
|
||||
'integration_data_schema',
|
||||
'requires_configuration',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'integration_data_schema' => 'array',
|
||||
'requires_configuration' => 'boolean',
|
||||
];
|
||||
|
||||
/** @return HasMany<IntegrationInstance, $this> */
|
||||
public function instances(): HasMany
|
||||
{
|
||||
return $this->hasMany(IntegrationInstance::class, 'integration_code', 'integration_code');
|
||||
}
|
||||
|
||||
/** @return HasMany<ClientIntegration, $this> */
|
||||
public function clientIntegrations(): HasMany
|
||||
{
|
||||
return $this->hasMany(ClientIntegration::class, 'integration_code', 'integration_code');
|
||||
}
|
||||
|
||||
/** @return HasMany<AdminWebsiteTypeIntegration, $this> */
|
||||
public function websiteTypeIntegrations(): HasMany
|
||||
{
|
||||
return $this->hasMany(AdminWebsiteTypeIntegration::class, 'integration_code', 'integration_code');
|
||||
}
|
||||
}
|
||||
41
app/Shared/Integration/Models/IntegrationInstance.php
Normal file
41
app/Shared/Integration/Models/IntegrationInstance.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Integration\Models;
|
||||
|
||||
use App\Domains\Integration\Casts\EncryptedIntegrationData;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class IntegrationInstance extends Model
|
||||
{
|
||||
// The ciphertext changes whenever credentials are saved, so old tokens cannot be reused.
|
||||
public function tokenCacheKey(): string
|
||||
{
|
||||
return 'integration_token:instance:'.$this->id.':'.hash('sha256', (string) $this->getRawOriginal('integration_data'));
|
||||
}
|
||||
|
||||
protected $fillable = ['integration_code', 'name', 'integration_data'];
|
||||
|
||||
protected $hidden = ['integration_data'];
|
||||
|
||||
protected $casts = ['integration_data' => EncryptedIntegrationData::class];
|
||||
|
||||
/** @return BelongsTo<Integration, $this> */
|
||||
public function integration(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Integration::class, 'integration_code', 'integration_code');
|
||||
}
|
||||
|
||||
/** @return HasMany<ClientIntegration, $this> */
|
||||
public function clientIntegrations(): HasMany
|
||||
{
|
||||
return $this->hasMany(ClientIntegration::class);
|
||||
}
|
||||
|
||||
/** @return HasMany<AdminWebsiteTypeIntegration, $this> */
|
||||
public function websiteTypeIntegrations(): HasMany
|
||||
{
|
||||
return $this->hasMany(AdminWebsiteTypeIntegration::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user