# مُصادَق — ملخص كود المشروع الكامل هذا الملف يحتوي على كافة ملفات المصدر للمشروع مجمعة لتسهيل المراجعة. ## الملف: `migrate.php` ```php exec("CREATE TABLE IF NOT EXISTS migrations ( id INT AUTO_INCREMENT PRIMARY KEY, migration VARCHAR(255) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); $stmt = $db->query("SELECT migration FROM migrations"); $executed = $stmt->fetchAll(PDO::FETCH_COLUMN); $migrationsDir = dirname(__DIR__) . '/database/migrations'; $files = glob($migrationsDir . '/*.sql'); sort($files); // Ensure order $count = 0; foreach ($files as $file) { $name = basename($file); if (!in_array($name, $executed)) { echo "🚀 Running: $name... "; $sql = file_get_contents($file); // Execute the SQL. Since it might contain multiple statements, // and PDO::exec doesn't always handle them well in one go // depending on the driver, we'll try to run it. $db->exec($sql); $stmt = $db->prepare("INSERT INTO migrations (migration) VALUES (?)"); $stmt->execute([$name]); echo "✅ Done\n"; $count++; } } if ($count === 0) { echo "✨ Nothing to migrate. Database is up to date.\n"; } else { echo "🎉 Migrations completed successfully ($count ran).\n"; } } catch (Exception $e) { echo "❌ Error: " . $e->getMessage() . "\n"; exit(1); } echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"; ``` --- ## الملف: `seed.php` ```php toString(); $db->prepare("INSERT INTO tenants (id, name, email, status) VALUES (?, ?, ?, 'active')") ->execute([$tenantId, 'شركة انطلاق للحلول الرقمية', 'admin@intaleqapp.com']); // 2. Create Super Admin User $userId = Uuid::uuid4()->toString(); $passwordHash = password_hash('Musadaq@2026', PASSWORD_ARGON2ID); $db->prepare("INSERT INTO users (id, tenant_id, name, email, password_hash, role, is_active) VALUES (?, ?, ?, ?, ?, 'super_admin', 1)") ->execute([$userId, $tenantId, 'Hamza Admin', 'admin@musadaq.app', $passwordHash]); // 3. Create initial subscription $db->prepare("INSERT INTO subscriptions (tenant_id, plan, max_companies, max_invoices_per_month, max_users) VALUES (?, 'pro', 10, 500, 5)") ->execute([$tenantId]); echo "✅ Success! You can now log in with:\n"; echo "📧 Email: admin@musadaq.app\n"; echo "🔑 Password: Musadaq@2026\n"; } catch (\Throwable $e) { echo "❌ Error: " . $e->getMessage() . "\n"; } ``` ---