Skip to content
Pro

License Activation Model

DB Table Name{wp_db_prefix}_fct_license_activations
SchemaCheck Schema
Source Filefluent-cart-pro/app/Modules/Licensing/Models/LicenseActivation.php
Name SpaceFluentCartPro\App\Modules\Licensing\Models
ClassFluentCartPro\App\Modules\Licensing\Models\LicenseActivation
PluginFluentCart Pro

Properties

  • Table: fct_license_activations
  • Primary Key: id
  • Guarded: ['id']
  • Fillable: ['site_id', 'license_id', 'status', 'is_local', 'product_id', 'last_update_date', 'last_update_version', 'variation_id', 'activation_method', 'activation_hash']

Attributes

AttributeData TypeComment
idIntegerPrimary Key
site_idIntegerForeign key to license sites
license_idIntegerForeign key to licenses
statusStringActivation status
is_localBooleanWhether this is a local activation
product_idIntegerAssociated product ID
last_update_dateDateTimeLast update timestamp
last_update_versionStringLast update version
variation_idIntegerProduct variation ID
activation_methodStringMethod used for activation
activation_hashStringUnique activation hash
created_atDateTimeCreation timestamp
updated_atDateTimeLast update timestamp

Usage

Please check Model Basic for Common methods.

Accessing Attributes

php
$activation = FluentCartPro\App\Modules\Licensing\Models\LicenseActivation::find(1);

$activation->id; // returns id
$activation->license_id; // returns license ID
$activation->site_id; // returns site ID
$activation->status; // returns status
$activation->is_local; // returns whether local
$activation->activation_hash; // returns activation hash

Relations

This model has the following relationships that you can use

license

Access the associated license (BelongsTo)

  • return FluentCartPro\App\Modules\Licensing\Models\License Model

Example:

php
// Accessing License
$license = $activation->license;

// For Filtering by license relationship
$activations = FluentCartPro\App\Modules\Licensing\Models\LicenseActivation::whereHas('license', function($query) {
    $query->where('status', 'active');
})->get();

site

Access the associated license site (BelongsTo)

  • return FluentCartPro\App\Modules\Licensing\Models\LicenseSite Model

Example:

php
// Accessing Site
$site = $activation->site;

// For Filtering by site relationship
$activations = FluentCartPro\App\Modules\Licensing\Models\LicenseActivation::whereHas('site', function($query) {
    $query->where('site_url', 'like', '%example.com%');
})->get();

Methods

Along with Global Model methods, this model has few helper methods.

updateStatus($newStatus)

Updates the activation status and triggers related action hooks.

  • Parameters
    • $newStatus - string - New status value
  • Returns $this - Current model instance

Actions Triggered:

  • fluent_cart_sl/license_activation_status_updated
  • fluent_cart_sl/license_activation_status_updated_to_{$newStatus}

Usage

php
$activation = FluentCartPro\App\Modules\Licensing\Models\LicenseActivation::find(1);
$activation->updateStatus('active');

Usage Examples

Creating License Activation

php
use FluentCartPro\App\Modules\Licensing\Models\LicenseActivation;

$activation = LicenseActivation::create([
    'site_id' => 1,
    'license_id' => 123,
    'status' => 'active',
    'is_local' => false,
    'product_id' => 456,
    'variation_id' => 789,
    'activation_method' => 'api',
    'activation_hash' => 'unique_hash_here'
]);

Querying Activations

php
// Get all activations for a license
$activations = LicenseActivation::where('license_id', 123)->get();

// Get active activations
$activeActivations = LicenseActivation::where('status', 'active')->get();

// Get non-local active activations
$remoteActivations = LicenseActivation::where('status', 'active')
    ->where('is_local', '!=', 1)
    ->get();

// Get activations with license relationship
$activationsWithLicense = LicenseActivation::with('license')->get();

// Get activations with site relationship
$activationsWithSite = LicenseActivation::with('site')->get();

Updating Activation Status

php
$activation = LicenseActivation::find(1);

// Update status (triggers action hooks)
$activation->updateStatus('inactive');

// Direct status update (no action hooks)
$activation->status = 'inactive';
$activation->save();

Plugin: FluentCart Pro

FluentCart developer documentation