Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_cat.blade.php
- @extends('base.base')
- @section('content')
- <head>
- rel="stylesheet">
- <style>
- html,
- body {
- margin: 0;
- padding: 0;
- width: 100%;
- overflow-x: hidden;
- background-color: #f4f4f4;
- }
- .category-container {
- margin-left: 235px; /* match your .sidebar width exactly */
- padding: 20px;
- /* background-color: #f4f4f4; */
- overflow-x: hidden;
- box-sizing: border-box;
- max-width: calc(100vw - 250px);
- }
- .category-header h2 {
- font-size: 25px;
- margin-left: 20px;
- margin-top: 10px;
- font-weight: 800;
- margin-bottom: 45px;
- }
- .add-cat-form {
- min-width: 200px;
- padding: 15px;
- background-color: #fff;
- border-radius: 16px;
- box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
- text-align: left;
- margin-left: 20px;
- }
- .form-group {
- margin-bottom: 20px;
- }
- .form-group label {
- font-weight: bold;
- display: block;
- margin-bottom: 6px;
- margin-left: 40px;
- margin-top: 15px;
- font-size: 20px;
- }
- input,
- select,
- textarea {
- width: 90%;
- padding: 5px;
- border: 1px solid #ccc;
- border-radius: 5px;
- font-size: 15px;
- padding-left: 8px;
- margin-left: 40px;
- }
- .form-buttons {
- display: flex;
- justify-content: center;
- gap: 12px;
- margin-top: 30px;
- /* text-align: center; */
- }
- .form-buttons .btn {
- width: 120px;
- }
- .btn {
- padding: 10px 24px;
- border-radius: 10px;
- border: none;
- cursor: pointer;
- font-weight: bold;
- text-align: center;
- }
- /* utk btton save */
- .save {
- background: #b38cf8;
- color: white;
- }
- /* utk btton cancel */
- .cancel {
- background: #999;
- color: white;
- }
- /* utk btton close di popup */
- .close {
- background: #999;
- color: white;
- }
- .form-buttons .cancel a, .save a, .close a {
- color: rgb(255, 255, 255);
- text-decoration: none;
- }
- .form-buttons .cancel:hover a, .save:hover a, .close:hover a {
- color: rgb(0, 0, 0);
- text-decoration: none;
- }
- /* Popup Styling */
- .popup-overlay {
- display: none;
- position: fixed;
- top: 0; left: 0;
- width: 100vw;
- height: 100vh;
- background: rgba(0,0,0,0.5);
- justify-content: center;
- align-items: center;
- z-index: 999;
- }
- .popup-content {
- background: white;
- padding: 24px;
- border-radius: 12px;
- max-width: 400px;
- box-shadow: 0 8px 20px rgba(0,0,0,0.2);
- text-align: center;
- }
- .popup-content h2 {
- margin-top: 0;
- }
- /* .close-btn {
- margin-top: 16px;
- padding: 8px 16px;
- background: #a78bfa;
- border: none;
- color: white;
- border-radius: 8px;
- cursor: pointer;
- text-decoration: none;
- }
- .close-btn:hover {
- background: #844ae8;
- text-decoration: none;
- } */
- </style>
- </head>
- <div class="category-container">
- <div class="category-header">
- <h2>Add New Category</h2>
- </div>
- <div class="add-cat-form">
- <div class="form-group">
- <label>Name</label>
- <input type="text" placeholder="Maximum 35 characters" />
- </div>
- <div class="form-group">
- <label>Description</label>
- <textarea rows="6" placeholder="Enter the Category's Description" ></textarea>
- </div>
- <!-- Buttons -->
- {{-- <div class="form-buttons">
- <button class="btn btn-secondary">Cancel</button>
- <button class="btn save">Save</button>
- </div> --}}
- <div class="form-buttons">
- <button class="btn cancel">
- <a href="{{ route('category') }}">Cancel</a>
- </button>
- <button class="btn save" onclick="showPopup('popup1')">
- <a href="#">Save</a>
- </button>
- </div>
- </div>
- </div>
- <!-- Popup -->
- <div class="popup-overlay" id="popup1">
- <div class="popup-content">
- <h2>Science Fiction</h2>
- <p>Detail Category:</p>
- <p>Cerita yang berlatar belakang teknologi dan sains. Genre ini seringkali didasarkan pada
- prinsip-prinsip ilmiah yang ada atau dihipotesiskan, namun dengan sentuhan imajinatif dan fiksi.
- </p>
- <div class="form-buttons">
- <button class="btn close">
- <a href="{{ route('category') }}">Close</a>
- </button>
- </div>
- </div>
- </div>
- <script>
- function showPopup(popupId) {
- document.getElementById(popupId).style.display = 'flex';
- }
- function closePopup(popupId) {
- document.getElementById(popupId).style.display = 'none';
- }
- </script>
- <!-- Bootstrap Icons CDN -->
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
- @endsection
- category_books.blade.php
- @extends('base.base')
- @section('content')
- <head>
- rel="stylesheet">
- <style>
- html,
- body {
- margin: 0;
- padding: 0;
- width: 100%;
- overflow-x: hidden;
- background-color: #f4f4f4;
- }
- .category-container {
- margin-left: 235px; /* match your .sidebar width exactly */
- padding: 20px;
- background-color: #f4f4f4;
- overflow-x: hidden;
- box-sizing: border-box;
- max-width: calc(100vw - 250px);
- }
- .category-header h2 {
- font-size: 25px;
- margin-left: 20px;
- margin-top: 10px;
- font-weight: 800;
- }
- .custom-container {
- border: 2px solid #c7b3ff;
- border-radius: 10px;
- padding: 20px;
- margin-left: 20px;
- }
- .action-link {
- color: #8e44ad;
- text-decoration: none;
- }
- .action-link:hover {
- text-decoration: underline;
- }
- .icon-eye {
- margin-right: 5px;
- }
- .search-add {
- margin-left: 20px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 15px;
- }
- .search-bar {
- position: relative;
- width: 550px;
- margin-left: 0px;
- margin-bottom: 10px;
- }
- .search-bar input {
- width: 100%;
- padding: 4px 50px 4px 15px;
- border: 1px solid #ccc;
- border-radius: 8px;
- }
- .search-bar i {
- position: absolute;
- right: 10px;
- top: 50%;
- transform: translateY(-50%);
- color: #888;
- }
- .form-buttons .btn {
- width: 120px;
- }
- .btn {
- padding: 10px 24px;
- border-radius: 10px;
- border: none;
- cursor: pointer;
- font-weight: bold;
- text-align: center;
- }
- /* utk btton cancel */
- .back {
- background: #999;
- color: white;
- }
- .form-buttons .back a{
- color: rgb(255, 255, 255);
- text-decoration: none;
- }
- .form-buttons .back:hover a{
- color: rgb(0, 0, 0);
- text-decoration: none;
- }
- .edit i{
- margin-left: 10px;
- }
- .edit {
- margin-right: 10px;
- }
- </style>
- </head>
- <div class="category-container">
- <div class="category-header">
- <h2>Books in “Arts and Photography”</h2>
- </div>
- <div class="search-add">
- <div class="search-bar">
- <input type="text" placeholder="Search by ID or title or author">
- <i class="fa-solid fa-magnifying-glass"></i>
- </div>
- <div class="form-buttons">
- <button class="btn back">
- <a href="{{ route('category') }}">Back</a>
- </button>
- </div>
- </div>
- <div class="custom-container bg-white">
- <table class="table">
- <thead>
- <tr>
- <th>ID</th>
- <th>Title</th>
- <th>Author</th>
- <th>Price</th>
- <th>Stock</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>PF001</td>
- <td>Belajar Website Pemula</td>
- <td>Celin Celin</td>
- <td>Rp. 500.000</td>
- <td>100</td>
- </tr>
- <tr>
- <td>PF001</td>
- <td>Belajar Website Pemula</td>
- <td>Celin Celin</td>
- <td>Rp. 500.000</td>
- <td>100</td>
- </tr>
- <tr>
- <td>PF001</td>
- <td>Belajar Website Pemula</td>
- <td>Celin Celin</td>
- <td>Rp. 500.000</td>
- <td>100</td>
- </tr>
- <tr>
- <td>PF001</td>
- <td>Belajar Website Pemula</td>
- <td>Celin Celin</td>
- <td>Rp. 500.000</td>
- <td>100</td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <!-- Bootstrap Icons CDN -->
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
- @endsection
- category.blade.php
- @extends('base.base')
- @section('content')
- <head>
- rel="stylesheet">
- <style>
- html,
- body {
- margin: 0;
- padding: 0;
- width: 100%;
- overflow-x: hidden;
- background-color: #f4f4f4;
- }
- .category-container {
- margin-left: 235px; /* match your .sidebar width exactly */
- padding: 20px;
- background-color: #f4f4f4;
- overflow-x: hidden;
- box-sizing: border-box;
- max-width: calc(100vw - 250px);
- }
- .category-header h2 {
- font-size: 25px;
- margin-left: 20px;
- margin-top: 10px;
- font-weight: 800;
- }
- .custom-container {
- border: 2px solid #c7b3ff;
- border-radius: 10px;
- padding: 20px;
- margin-left: 20px;
- }
- .action-link {
- color: #8e44ad;
- text-decoration: none;
- }
- .action-link:hover {
- text-decoration: underline;
- }
- .icon-eye {
- margin-right: 5px;
- }
- .search-add {
- margin-left: 20px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 15px;
- }
- .search-bar {
- position: relative;
- width: 550px;
- margin-left: 0px;
- margin-bottom: 10px;
- }
- .search-bar input {
- width: 100%;
- padding: 4px 50px 4px 15px;
- border: 1px solid #ccc;
- border-radius: 8px;
- }
- .search-bar i {
- position: absolute;
- right: 10px;
- top: 50%;
- transform: translateY(-50%);
- color: #888;
- }
- .add-btn {
- background-color: #b18dfc;
- color: white;
- border: none;
- border-radius: 8px;
- padding: 10px 20px;
- font-weight: bold;
- cursor: pointer;
- margin-right: 10px;
- }
- .add-btn:hover {
- background-color: #996bfa;
- }
- .add-btn i {
- margin-right: 5px;
- }
- .edit i{
- margin-left: 10px;
- }
- .edit {
- margin-right: 10px;
- }
- </style>
- </head>
- <div class="category-container">
- <div class="category-header">
- <h2>Category List</h2>
- </div>
- <div class="search-add">
- <div class="search-bar">
- <input type="text" placeholder="Search by ID or title or author">
- <i class="fa-solid fa-magnifying-glass"></i>
- </div>
- <a href="{{ route('add-category') }}">
- <button class="add-btn">
- <i class="bi bi-plus-lg"></i> Add New Category
- </button>
- </a>
- </div>
- <div class="custom-container bg-white">
- <table class="table">
- <thead>
- <tr>
- <th>ID</th>
- <th>Name</th>
- <th>Total Books</th>
- <th>Action</th>
- </tr>
- </thead>
- <tbody>
- @foreach ($category as $cat)
- <tr>
- <td>{{ $cat['id'] }}</td>
- <td>{{ $cat['nama_category'] }}</td>
- <td>{{ $cat['total_books'] }}</td>
- <td>
- <a href="{{ route('category-books') }}" class="action-link viewAll"><i class="bi bi-eye
- icon-eye"></i>View All Books</a>
- <a href="{{ route('edit-category') }}" class="text-primary edit"><i class="fa-solid fapen"></i>Edit</a>
- <a href="{{ route('category', ['delete_id' => $cat['id']]) }}" onclick="return
- confirm('Yakin ingin menghapus?')" class="text-danger delete"><i class="fa-solid fatrash"></i>Delete</a>
- </td>
- </tr>
- @endforeach
- </tbody>
- </table>
- </div>
- </div>
- <!-- Bootstrap Icons CDN -->
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
- @endsection
- edit_cat.blade.php
- @extends('base.base')
- @section('content')
- <head>
- rel="stylesheet">
- <style>
- html,
- body {
- margin: 0;
- padding: 0;
- width: 100%;
- overflow-x: hidden;
- background-color: #f4f4f4;
- }
- .category-container {
- margin-left: 235px; /* match your .sidebar width exactly */
- padding: 20px;
- /* background-color: #f4f4f4; */
- overflow-x: hidden;
- box-sizing: border-box;
- max-width: calc(100vw - 250px);
- }
- .category-header h2 {
- font-size: 25px;
- margin-left: 20px;
- margin-top: 10px;
- font-weight: 800;
- margin-bottom: 45px;
- }
- .add-cat-form {
- min-width: 200px;
- padding: 15px;
- background-color: #fff;
- border-radius: 16px;
- box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
- text-align: left;
- margin-left: 20px;
- }
- .form-group {
- margin-bottom: 20px;
- }
- .form-group label {
- font-weight: bold;
- display: block;
- margin-bottom: 6px;
- margin-left: 40px;
- margin-top: 15px;
- font-size: 20px;
- }
- input,
- select,
- textarea {
- width: 90%;
- padding: 5px;
- border: 1px solid #ccc;
- border-radius: 5px;
- font-size: 15px;
- padding-left: 8px;
- margin-left: 40px;
- }
- .form-buttons {
- display: flex;
- justify-content: center;
- gap: 12px;
- margin-top: 30px;
- /* text-align: center; */
- }
- .form-buttons .btn {
- width: 120px;
- }
- .btn {
- padding: 10px 24px;
- border-radius: 10px;
- border: none;
- cursor: pointer;
- font-weight: bold;
- text-align: center;
- }
- /* utk btton save */
- .save {
- background: #b38cf8;
- color: white;
- }
- /* utk btton cancel */
- .cancel {
- background: #999;
- color: white;
- }
- .form-buttons .cancel a, .save a {
- color: rgb(255, 255, 255);
- text-decoration: none;
- }
- .form-buttons .cancel:hover a, .save:hover a {
- color: rgb(0, 0, 0);
- text-decoration: none;
- }
- </style>
- </head>
- <div class="category-container">
- <div class="category-header">
- <h2>Edit Category</h2>
- </div>
- <div class="add-cat-form">
- <div class="form-group">
- <label>Name</label>
- <input type="text" placeholder="Maximum 35 characters" />
- </div>
- <div class="form-group">
- <label>Description</label>
- <textarea rows="6" placeholder="Enter the Category's Description" ></textarea>
- </div>
- <div class="form-buttons">
- <button class="btn cancel">
- <a href="{{ route('category') }}">Cancel</a>
- </button>
- <button class="btn save">
- <a href="{{ route('category') }}">Save</a>
- </button>
- </div>
- </div>
- </div>
- <!-- Bootstrap Icons CDN -->
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
- @endsection
- Routing: web.php
- Route::get('/category', [StoreController::class, 'show_category'])
- ->name('category');
- Route::get('/categorybooks', [StoreController::class, 'show_category_books'])
- ->name('category-books');
- Route::get('/add-category', [StoreController::class, 'show_add_category'])
- ->name('add-category');
- Route::get('/edit-category', [StoreController::class, 'show_edit_category'])
- ->name('edit-category');
- Controller: StoreController
- public function show_category_books(){
- return view('category.category_books',[
- 'title' => 'Category Books'
- ]);
- }
- public function show_add_category(){
- return view('category.add_cat',[
- 'title' => 'Add Category'
- ]);
- }
- public function show_edit_category(){
- return view('category.edit_cat',[
- 'title' => 'Edit Category'
- ]);
- }
- public function show_category(Request $request)
- {
- $category = [
- ['id' => 1, 'nama_category' => 'Arts & Photography', 'total_books' => 10],
- ['id' => 2, 'nama_category' => 'Non-Fiksi', 'total_books' => 5],
- ['id' => 3, 'nama_category' => 'Biografi', 'total_books' => 7],
- ];
- // Kalau ada request ID untuk dihapus
- if ($request->has('delete_id')) {
- $deleteId = $request->input('delete_id');
- // Filter data yang tidak sesuai dengan ID yang dihapus
- $category = array_filter($category, function ($cat) use ($deleteId) {
- return $cat['id'] != $deleteId;
- });
- // Reset index array
- $category = array_values($category);
- }
- return view('category.category', compact('category'));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement