diff --git a/.env.example b/.env.example deleted file mode 100644 index 65a300a439541cb2b6d826f507c70c41375b4d8d..0000000000000000000000000000000000000000 --- a/.env.example +++ /dev/null @@ -1,5 +0,0 @@ -POSTGRES_HOST=db_wbd_1 -POSTGRES_DB=wbd_db -POSTGRES_PORT=5432 -POSTGRES_USER=postgres -POSTGRES_PASSWORD=Aa123456 \ No newline at end of file diff --git a/src/app/controllers/Subscriber.php b/src/app/controllers/Subscriber.php new file mode 100644 index 0000000000000000000000000000000000000000..8a8e68bd1ae9952d4055874636d00e7b25fb089e --- /dev/null +++ b/src/app/controllers/Subscriber.php @@ -0,0 +1,22 @@ +<?php +namespace app\controllers; +use app\core\Controller; +use app\core\Router; +use app\core\Sessions; +use config\AppConfig; +use Exception; + +class Subscriber extends Controller{ + public function index($data=[]){ + $authorBook = $this->model("BookModel"); + $this->addRel("stylesheet", "/public/css/style-2.css"); + $this->addRel("stylesheet", "/public/css/topbar.css"); + $data = $authorBook->getAuthor(); + $this->view('Subscriber', $data); + } + + public function subscriber(){ + echo"AWW"; + } +} +?> \ No newline at end of file diff --git a/src/app/core/app.php b/src/app/core/app.php index 5bcf8c5354ccd7bdc5617a8a3fb47fcb7c3a13eb..455a96e61d364c1b9d8d1e0c6f38fcac42a12d0b 100644 --- a/src/app/core/app.php +++ b/src/app/core/app.php @@ -24,6 +24,7 @@ class App { $this->router->addRoute('/login', 'app/controllers/Login', 'index', ['GET']); $this->router->addPost('/profile', 'app/controllers/Profile', 'profile'); $this->router->addPost('/login', 'app/controllers/Login', 'login'); + $this->router->addRoute('/subscriber', 'app/controllers/Subscriber', 'index', ['GET']); $this->router->addRoute('/register', 'app/controllers/Register', 'index', ['GET']); $this->router->addRoute('/admin/books', 'app/controllers/Admin', 'bookView', ['GET']); @@ -34,6 +35,7 @@ class App { $this->router->addPost('/login', 'app/controllers/Login', 'login'); $this->router->addPost('/register', 'app/controllers/Register', 'register'); $this->router->addPost('/logout', 'app/controllers/Login', 'logout'); + $this->router->addPost('/subscriber', 'app/controllers/Subscriber', 'subscriber'); // Public route for page utilities $this->router->addRoute('/api/search', 'app/controllers/Search', 'serve', ['GET']); @@ -60,6 +62,7 @@ class App { $this->router->addRoute('/api/user/edit', 'app/controllers/User', 'editUser', ['POST']); $this->router->addRoute('/api/user/add', 'app/controllers/User', 'addUser', ["PUT"]); $this->router->addRoute('/api/user/delete', 'app/controllers/User', 'deleteUser', ['DELETE']); + // Sori masih bingung best practicenya buat post sama put } diff --git a/src/app/models/bookmodel.php b/src/app/models/bookmodel.php index ec156306344b18b8d854afb1894cbb1f9f1e89ba..cc9513242a019ff1ede224bf17586e62035993e3 100644 --- a/src/app/models/bookmodel.php +++ b/src/app/models/bookmodel.php @@ -401,6 +401,12 @@ class BookModel{ return $this->database->fetch(); } + public function getAuthor(){ + $query = "SELECT username FROM users where user_id IN (SELECT DISTINCT author_id FROM books)"; + $this->database->query($query); + $result = $this->database->fetchAll(); + return $result; + } } ?> \ No newline at end of file diff --git a/src/app/models/usermodel.php b/src/app/models/usermodel.php index baae0d80b98bfc63d76ee4e84b70921d02889cdc..753370b1f7b36b0d9d56807470abc60a6c44dfa4 100644 --- a/src/app/models/usermodel.php +++ b/src/app/models/usermodel.php @@ -183,5 +183,7 @@ class UserModel{ return $this->database->rowCount(); } + + } ?> \ No newline at end of file diff --git a/src/app/views/Subscriber.php b/src/app/views/Subscriber.php new file mode 100644 index 0000000000000000000000000000000000000000..bf73ba794979108bbbf402c8143a9a73403cb0d7 --- /dev/null +++ b/src/app/views/Subscriber.php @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <title>Daftar Premium</title> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <?php echo strip_tags($REL_DATA, '<link>');?> +</head> +<?php if(file_exists($TOP_BAR)) include_once($TOP_BAR);?> +<img class="sty-bckgrnd" src="/storage/assets/logo.svg" alt="Stylized Background"> +<div class="main-content first"> + <div class="gen-header cluster-h"> + <h2>Daftar Author Yang Bisa Di Subscribe</h2> + </div> + <div class="subscribe-section"> + <?php + if (is_array($data)) { + foreach ($data as $key => $value) { + if (is_array($value) && isset($value['username'])) { + echo '<div class="author-info">'; + echo '<img src="https://tse4.mm.bing.net/th?id=OIP._arhxJRyb58rGEtxa_v_1QHaHa&pid=Api&P=0&h=180" alt="Author Image">'; + echo '<h3>' . $value["username"] . '</h3>'; + echo '<button class="btn btn-yellow">Subscribe</button>'; + echo '</div>'; + } + } + } else { + echo 'Data tidak valid atau kosong.'; + } + ?> + </div> +</div> +</html> diff --git a/src/app/views/home.php b/src/app/views/home.php index 7a46a5ba64928a946230d23674ed0f5d646eb590..ad7d028d8472fa2251ed309cf36464d205b26caa 100644 --- a/src/app/views/home.php +++ b/src/app/views/home.php @@ -27,6 +27,9 @@ use config\AppConfig; echo '<h1 class="gen-h1 ">Start Exploring</h1>'; } ?> + <button class="btn btn-yellow subscribe" type="submit" name="Premium">Daftar Premium</button> + + <p>Here's what our reviewers think you should read this today</p> <p id="currentdate" style="color:#9b9b9b;text-align:right">date</p> </header> diff --git a/src/public/css/style-2.css b/src/public/css/style-2.css index db487b39518dbb65d17b7c31eea1226cfb405b01..4b609879b3c09a9f2f620da9be4e64c7ce93c1eb 100644 --- a/src/public/css/style-2.css +++ b/src/public/css/style-2.css @@ -91,7 +91,7 @@ cursor: pointer; } -.circular-btn{ +.circular-btn { border-radius: 24px; } @@ -124,6 +124,20 @@ color: #ffffff; } +.subscribe{ + float: right; + margin-top: -10px; +} +.subscribe-section { + display: flex; + flex-wrap: wrap; + justify-content: space-between; +} + +.author-info { + flex: 1 0 18%; /* 18% untuk memberikan sedikit ruang antara kotak */ + margin-bottom: 20px; /* Jarak antara baris */ +} .btn-red:hover { background: #ff6b6b; } @@ -135,6 +149,31 @@ gap: 10px; } +.cluster-v { + display: flex; +} + background: #edc001; + color: #ffffff; + border-radius: 24px; + padding: 8px 16px; + font-size: 14px; + line-height: 1; + font-weight: 550; + position: left; + text-align: center; + cursor: pointer; + transition: 0.3s; + box-sizing: border-box; + border: none; +} + +.cluster-h { + display: inline-flex; + flex-direction: row; + align-items: center; + gap: 10px; +} + .cluster-v { display: flex; flex-direction: column; @@ -405,7 +444,7 @@ z-index: 101; } -.modal .modal-content{ +.modal .modal-content { font-family: Rubik, sans-serif; position: relative; display: flex; @@ -418,25 +457,25 @@ overflow: hidden; } -.modal .modal-header{ +.modal .modal-header { display: flex; flex-direction: row; justify-content: space-between; } -.modal .modal-subtitle{ +.modal .modal-subtitle { color: #7b7b7b; font-size: 10px; margin-top: 0; } -.modal-header .close{ +.modal-header .close { margin: 0; font-size: 24px; cursor: pointer; } -.modal-header h5{ +.modal-header h5 { margin: 0; margin-bottom: 10px; font-size: 24px;