Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/RigbySawGame/ieeEdu_Wen/llms.txt

Use this file to discover all available pages before exploring further.

IEE Edu ships three custom Artisan commands that handle platform administration tasks not covered by the standard Laravel toolset. iie:make-admin provisions administrator accounts safely from the CLI, while subscriptions:sync-expired and subscription:sync keep course access flags in sync with the state of each user’s subscription. All three commands are located under app/Console/Commands/.

iie:make-admin

Creates or updates a user record with role=admin and status=activo. Because it uses updateOrCreate, running it against an existing email is safe — it will simply update the name, password, and role rather than creating a duplicate account.

Signature

php artisan iie:make-admin {email} {--name=Admin} {--password=}

Arguments & Options

ParameterTypeRequiredDefaultDescription
emailArgument✅ YesEmail address of the user to create or update.
--nameOptionNoAdminDisplay name assigned to the user.
--passwordOptionNopasswordPlain-text password (hashed with bcrypt before storing).

Examples

# Create an admin with a secure password
php artisan iie:make-admin [email protected] --name="Super Admin" --password="S3cur3P@ss!"

# Quick local dev admin (uses default password 'password')
php artisan iie:make-admin [email protected] --name="Dev Admin"

# Update an existing user to admin role
php artisan iie:make-admin [email protected] --name="Promoted User" --password="NewP@ss123"

What It Does Internally

1

Resolve arguments

Reads the email argument and the --name and --password options. If --password is omitted or empty, falls back to the literal string 'password'.
2

Upsert the user

Calls User::updateOrCreate(['email' => $email], [...]) with role='admin', status='activo', the provided name, and the bcrypt-hashed password.
3

Output confirmation

Prints the user’s email via $this->info() and echoes the plain-text password via $this->warn() so you can verify what was set.
The --password option defaults to 'password' when omitted. Never rely on this default in production. Always pass an explicit --password with a strong, unique value when provisioning admin accounts on a live server. The command echoes the plain-text password to the terminal upon completion — treat that output as sensitive.

subscriptions:sync-expired

Scans all active subscriptions for ones whose end_date has passed, marks each one as expired, and revokes the corresponding course access grants for the affected users. This command is designed to be run automatically by the Laravel scheduler (see the Scheduler page), but can also be triggered manually at any time.

Signature

php artisan subscriptions:sync-expired

Arguments & Options

This command takes no arguments or options.

Examples

# Run immediately (e.g. after approving a bulk refund)
php artisan subscriptions:sync-expired

# Run inside a deployment pipeline to clean up before go-live
php artisan migrate --force && php artisan subscriptions:sync-expired

What It Does Internally

1

Find expired subscriptions

Queries the subscriptions table for records where status = 'activa' and end_date < now(). These are memberships that are still flagged as active in the database but have already passed their end date.
2

Early exit if none found

If the query returns zero rows, outputs No expired subscriptions found. and exits cleanly with no further database writes.
3

Mark each subscription as expired

Iterates over the results and calls $subscription->update(['status' => 'expirada']) on each one, using the STATUS_EXPIRED constant defined on the Subscription model.
4

Sync access for each affected user

Calls SubscriptionAccessService::sync($subscription->user_id) for every expired subscription. The service recalculates which courses the user may access based on their remaining active subscriptions and individual payment records, then updates the enrollments table accordingly.
5

Report results

Outputs a confirmation line per subscription (e.g. Synced expired subscription ID: 42 for User ID: 7) and a final summary count: Successfully synced N expired subscriptions.
After writing a test that approves a subscription and then backdates its end_date, run php artisan subscriptions:sync-expired manually to verify that the enrollment records are actually revoked. Check the enrollments table for subscription_active = false on that user’s rows.

subscription:sync

Performs a full reconciliation of subscription_active flags across every user in the enrollments table. The optional --backfill flag also repairs the subscription_granted column on pre-migration enrollment rows that were created before the subscription system existed.

Signature

php artisan subscription:sync {--backfill : Mark pre-migration enrollments with correct subscription_granted flag}

Arguments & Options

ParameterTypeRequiredDefaultDescription
--backfillFlagNofalseWhen present, runs a historical data repair pass before the main sync.

Examples

# Run a normal sync of all user access flags
php artisan subscription:sync

# One-time backfill after migrating from a pre-subscription schema
php artisan subscription:sync --backfill

What It Does Internally

1

Optional backfill pass (--backfill only)

Fetches every distinct user_id from the enrollments table. For each user, it collects all course_id values from the payments table where status = 'aprobado'. Any enrollment row for that user that does not have a matching individual payment is assumed to have come from a subscription grant and is updated with subscription_granted = true. This repairs historical data created before the subscription system was introduced.
2

Sync all users

Fetches every distinct user_id from enrollments again and calls SubscriptionAccessService::sync($userId) for each one. This recalculates the subscription_active flag on all enrollment rows for every user in the system.
3

Report results

Outputs a progress message at the start of each phase and a final ✅ Sync complete for N users. summary line.
The --backfill flag performs bulk UPDATE queries against the enrollments table. Run it only once after a schema migration on a system that had existing enrollments. Running it repeatedly is safe (the updates are idempotent) but unnecessary and potentially slow on large datasets.

Build docs developers (and LLMs) love