Skip to content
Snippets Groups Projects
Commit 191c5618 authored by Alexander Jason's avatar Alexander Jason
Browse files

feat: integrate rest to php

parent d4ac4dc7
Branches
Tags
No related merge requests found
...@@ -38,6 +38,22 @@ ...@@ -38,6 +38,22 @@
</li> </li>
<?php endif;?> <?php endif;?>
<?php endif;?> <?php endif;?>
<?php if(isset($_SESSION['username'])):?>
<?php if($_SESSION["role"]=='customer') :?>
<li>
<a class="subscription" href="/user/subs">
<img src="<?= BASE_URL ?>/icon/dashboard.svg" alt="Customer Icon">
My Subscription
</a>
</li>
<li>
<a class="premium" href="/premium">
<img src="<?= BASE_URL ?>/icon/genre.svg" alt="Genre Icon">
Premium Collection
</a>
</li>
<?php endif;?>
<?php endif;?>
</ul> </ul>
<?php if(isset($_SESSION['username'])):?> <?php if(isset($_SESSION['username'])):?>
<form method="POST" <form method="POST"
......
...@@ -18,8 +18,21 @@ class UserController extends Controller implements ControllerInterface ...@@ -18,8 +18,21 @@ class UserController extends Controller implements ControllerInterface
//insert data //insert data
public function subs() public function subs()
{ {
$mySubscriptionView = $this->view('user', 'MySubscriptionView'); if (!isset($_SESSION['username'])) {
$mySubscriptionView->render(); http_response_code(301);
header("Location: /user/login", true, 301);
exit;
}
switch ($_SERVER['REQUEST_METHOD']) {
case 'GET':
// show the login page
$mySubscriptionView = $this->view('user', 'MySubscriptionView');
$mySubscriptionView->render();
break;
default:
throw new RequestException('Method Not Allowed', 405);
}
} }
public function login() public function login()
......
...@@ -26,19 +26,21 @@ ...@@ -26,19 +26,21 @@
<thead> <thead>
<tr> <tr>
<th>Id</th> <th>Id</th>
<th>Book Title</th> <th>Curator Collection</th>
<th>Author</th> <th>Details</th>
</tr> </tr>
</thead> </thead>
<?php <?php
$raw_data = file_get_contents('http://host.docker.internal:8040/api/curator-collection');
$authors = $this->data['authors']; $data = json_decode($raw_data, true);
echo var_dump($data);
$collections = $data['found'];
foreach ($authors as $author) { foreach ($collections as $collection) {
echo "<tr>"; echo "<tr>";
echo "<td>" . $author['author_id'] . "</td>"; echo "<td>" . $collection['collectionId'] . "</td>";
echo "<td>" . $author['full_name'] . "</td>"; echo "<td>" . $collection['createdBy'] . "</td>";
echo "<td>" . $author['full_name'] . "</td>"; echo '<td><a href="/premium/detail/' . $collection['collectionId'] .'">Edit</a></td>';
echo "</tr>"; echo "</tr>";
} }
?> ?>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment