v26
This commit is contained in:
parent
03c203ff92
commit
d9eba63b0d
7
db/migrations/10_add_missing_startup_fields.sql
Normal file
7
db/migrations/10_add_missing_startup_fields.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
-- Migration: Add missing fields to startups table for Discovery Hub and Details page
|
||||||
|
ALTER TABLE startups
|
||||||
|
ADD COLUMN industry VARCHAR(100) AFTER description,
|
||||||
|
ADD COLUMN followers_count INT DEFAULT 0 AFTER status;
|
||||||
|
|
||||||
|
-- Initialize followers_count from existing startup_followers table
|
||||||
|
UPDATE startups s SET followers_count = (SELECT COUNT(*) FROM startup_followers WHERE startup_id = s.id);
|
||||||
@ -19,7 +19,7 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
|
|||||||
|
|
||||||
// Leaderboard: Most Followed
|
// Leaderboard: Most Followed
|
||||||
$stmt = db()->query("
|
$stmt = db()->query("
|
||||||
SELECT s.*, u.full_name as founder_name, s.followers_count
|
SELECT s.*, u.full_name as founder_name
|
||||||
FROM startups s
|
FROM startups s
|
||||||
JOIN users u ON s.founder_id = u.id
|
JOIN users u ON s.founder_id = u.id
|
||||||
ORDER BY s.followers_count DESC
|
ORDER BY s.followers_count DESC
|
||||||
@ -39,7 +39,7 @@ $mostFunded = $stmt->fetchAll();
|
|||||||
|
|
||||||
// General Browse
|
// General Browse
|
||||||
$q = $_GET['q'] ?? '';
|
$q = $_GET['q'] ?? '';
|
||||||
$where = "onboarding_completed = 1";
|
$where = "u.onboarding_completed = 1";
|
||||||
$params = [];
|
$params = [];
|
||||||
if ($q) {
|
if ($q) {
|
||||||
$where .= " AND (s.name LIKE ? OR s.description LIKE ? OR s.industry LIKE ?)";
|
$where .= " AND (s.name LIKE ? OR s.description LIKE ? OR s.industry LIKE ?)";
|
||||||
@ -187,7 +187,9 @@ $browseStartups = $stmt->fetchAll();
|
|||||||
<?= htmlspecialchars(substr($s['description'], 0, 100)) ?>...
|
<?= htmlspecialchars(substr($s['description'], 0, 100)) ?>...
|
||||||
</p>
|
</p>
|
||||||
<div style="display: flex; justify-content: space-between; align-items: center;">
|
<div style="display: flex; justify-content: space-between; align-items: center;">
|
||||||
<span class="badge" style="font-size: 10px;"><?= ucfirst($s['industry']) ?></span>
|
<?php if (!empty($s['industry'])): ?>
|
||||||
|
<span class="badge" style="font-size: 10px;"><?= htmlspecialchars($s['industry']) ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
<span style="font-weight: 700; color: var(--accent-blue);">£<?= number_format($s['funding_raised']) ?></span>
|
<span style="font-weight: 700; color: var(--accent-blue);">£<?= number_format($s['funding_raised']) ?></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -34,10 +34,11 @@ if ($startup_id > 0) {
|
|||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
$name = trim($_POST['name'] ?? '');
|
$name = trim($_POST['name'] ?? '');
|
||||||
$description = trim($_POST['description'] ?? '');
|
$description = trim($_POST['description'] ?? '');
|
||||||
|
$industry = trim($_POST['industry'] ?? '');
|
||||||
$target = (float)($_POST['funding_target'] ?? 0);
|
$target = (float)($_POST['funding_target'] ?? 0);
|
||||||
$status = $_POST['status'] ?? 'public';
|
$status = $_POST['status'] ?? 'public';
|
||||||
|
|
||||||
if ((!$existingStartup && empty($name)) || (!$existingStartup && empty($description)) || $target < 50) {
|
if ((!$existingStartup && (empty($name) || empty($description) || empty($industry))) || $target < 50) {
|
||||||
$error = "Please fill in all required fields. Minimum target is £50.";
|
$error = "Please fill in all required fields. Minimum target is £50.";
|
||||||
} else {
|
} else {
|
||||||
db()->beginTransaction();
|
db()->beginTransaction();
|
||||||
@ -49,8 +50,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$final_id = $existingStartup['id'];
|
$final_id = $existingStartup['id'];
|
||||||
} else {
|
} else {
|
||||||
// 1. Insert startup
|
// 1. Insert startup
|
||||||
$stmt = db()->prepare("INSERT INTO startups (name, description, founder_id, funding_target, status) VALUES (?, ?, ?, ?, ?)");
|
$stmt = db()->prepare("INSERT INTO startups (name, description, industry, founder_id, funding_target, status) VALUES (?, ?, ?, ?, ?, ?)");
|
||||||
$stmt->execute([$name, $description, $_SESSION['user_id'], $target, $status]);
|
$stmt->execute([$name, $description, $industry, $_SESSION['user_id'], $target, $status]);
|
||||||
$new_startup_id = db()->lastInsertId();
|
$new_startup_id = db()->lastInsertId();
|
||||||
|
|
||||||
// 2. Insert initial funding round
|
// 2. Insert initial funding round
|
||||||
@ -106,6 +107,20 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
|
|||||||
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Startup Name</label>
|
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Startup Name</label>
|
||||||
<input type="text" name="name" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;">
|
<input type="text" name="name" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;">
|
||||||
</div>
|
</div>
|
||||||
|
<div style="margin-bottom: 15px;">
|
||||||
|
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Industry</label>
|
||||||
|
<select name="industry" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;">
|
||||||
|
<option value="">Select Industry</option>
|
||||||
|
<option value="Fintech">Fintech</option>
|
||||||
|
<option value="Healthtech">Healthtech</option>
|
||||||
|
<option value="Edtech">Edtech</option>
|
||||||
|
<option value="E-commerce">E-commerce</option>
|
||||||
|
<option value="SaaS">SaaS</option>
|
||||||
|
<option value="Clean Energy">Clean Energy</option>
|
||||||
|
<option value="AI & Robotics">AI & Robotics</option>
|
||||||
|
<option value="Other">Other</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div style="margin-bottom: 15px;">
|
<div style="margin-bottom: 15px;">
|
||||||
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Description</label>
|
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Description</label>
|
||||||
<textarea name="description" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff; height: 120px; resize: none;"></textarea>
|
<textarea name="description" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff; height: 120px; resize: none;"></textarea>
|
||||||
|
|||||||
@ -31,10 +31,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
|
|||||||
if ($_POST['action'] === 'follow') {
|
if ($_POST['action'] === 'follow') {
|
||||||
$stmt = db()->prepare("INSERT IGNORE INTO startup_followers (user_id, startup_id) VALUES (?, ?)");
|
$stmt = db()->prepare("INSERT IGNORE INTO startup_followers (user_id, startup_id) VALUES (?, ?)");
|
||||||
$stmt->execute([$user_id, $startup_id]);
|
$stmt->execute([$user_id, $startup_id]);
|
||||||
|
if ($stmt->rowCount() > 0) {
|
||||||
|
$stmt = db()->prepare("UPDATE startups SET followers_count = followers_count + 1 WHERE id = ?");
|
||||||
|
$stmt->execute([$startup_id]);
|
||||||
|
}
|
||||||
$success = "You are now following " . $startup['name'] . "!";
|
$success = "You are now following " . $startup['name'] . "!";
|
||||||
} elseif ($_POST['action'] === 'unfollow') {
|
} elseif ($_POST['action'] === 'unfollow') {
|
||||||
$stmt = db()->prepare("DELETE FROM startup_followers WHERE user_id = ? AND startup_id = ?");
|
$stmt = db()->prepare("DELETE FROM startup_followers WHERE user_id = ? AND startup_id = ?");
|
||||||
$stmt->execute([$user_id, $startup_id]);
|
$stmt->execute([$user_id, $startup_id]);
|
||||||
|
if ($stmt->rowCount() > 0) {
|
||||||
|
$stmt = db()->prepare("UPDATE startups SET followers_count = GREATEST(0, followers_count - 1) WHERE id = ?");
|
||||||
|
$stmt->execute([$startup_id]);
|
||||||
|
}
|
||||||
$success = "You have unfollowed " . $startup['name'] . ".";
|
$success = "You have unfollowed " . $startup['name'] . ".";
|
||||||
} elseif ($_POST['action'] === 'invest' && $user['role'] === 'investor') {
|
} elseif ($_POST['action'] === 'invest' && $user['role'] === 'investor') {
|
||||||
$amount = (float)($_POST['amount'] ?? 0);
|
$amount = (float)($_POST['amount'] ?? 0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user