File manager - Edit - /home/u300416816/domains/recipeseasy.online/public_html/storage/framework/views/947ebdc22bfbd33ff135ad993f15f017.php
Back
<?php $__env->startSection('content'); ?> <div class="content-header"> <div class="container-fluid"> <div class="row mb-2"> <div class="col-sm-6"> <h1 class="m-0">Add New Game</h1> </div><!-- /.col --> </div><!-- /.row --> </div><!-- /.container-fluid --> </div> <!-- /.content-header --> <!-- Main content --> <section class="content"> <div class="container-fluid"> <!-- Info boxes --> <ul class="nav nav-tabs" id="gameTabs" role="tablist"> <li class="nav-item m-1"> <a class="nav-link active btn btn-success" id="add-new-tab" data-toggle="tab" href="#add-new" role="tab" aria-controls="add-new" aria-selected="true">Add New</a> </li> <li class="nav-item m-1"> <a class="nav-link btn btn-warning" id="generate-api2-tab" data-toggle="tab" href="#generate-api2" role="tab" aria-controls="generate-api2" aria-selected="false">Import From the API 1</a> </li> <li class="nav-item m-1"> <a class="nav-link btn btn-info" id="generate-api-tab" data-toggle="tab" href="#generate-api" role="tab" aria-controls="generate-api" aria-selected="false">Import From the API 2</a> </li> </ul> <div class="tab-content mt-2" id="gameTabContent"> <!-- Add New Game Form --> <div class="tab-pane fade show active" id="add-new" role="tabpanel" aria-labelledby="add-new-tab"> <!-- Info boxes --> <form action="<?php echo e(route('admin.games.store')); ?>" method="POST" enctype="multipart/form-data"> <?php echo csrf_field(); ?> <div class="row"> <!-- left column --> <div class="col-md-8"> <!-- general form elements --> <div class="card card-primary"> <div class="card-body"> <!-- Game Name field --> <div class="form-group"> <label for="name">Game Name</label> <input type="text" class="form-control" id="name" name="name" placeholder="Enter Game Name" required> </div> <!-- Category field --> <div class="form-group"> <label for="category_id">Category</label> <select class="form-control" name="category_id" id="category_id" required> <option value="">Select Category</option> <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <option value="<?php echo e($category->id); ?>"><?php echo e($category->name); ?></option> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> </select> </div> <!-- Description field --> <div class="form-group"> <label for="description">Description</label> <textarea class="form-control" id="description" name="description" placeholder="Enter Game Description" rows="4" required></textarea> </div> <!-- Game URL field --> <div class="form-group"> <label for="game_url">Game URL</label> <input type="text" class="form-control" id="game_url" name="game_url" placeholder="Enter Game URL" required> </div> <!-- Meta Title field --> <div class="form-group"> <label for="meta_title">Meta Title (Optional)</label> <input type="text" class="form-control" id="meta_title" name="meta_title" placeholder="Enter Meta Title"> </div> <!-- Meta Description field --> <div class="form-group"> <label for="meta_description">Meta Description (Optional)</label> <textarea class="form-control" id="meta_description" name="meta_description" placeholder="Enter Meta Description" rows="3"></textarea> </div> </div> </div> <!-- /.card --> </div> <div class="col-md-4"> <!-- general form elements --> <div class="card card-primary"> <div class="card-body"> <!-- Image Drag-and-Drop field --> <div class="form-group"> <label for="image">Game Image</label> <div id="image-drop-area" class="drop-area"> <p>Drag & drop an image here or click to select a file</p> <img id="image-preview" src="#" alt="Image Preview" style="display: none; max-width: 100%; height: auto; margin-top: 10px;"> <input type="file" class="form-control-file" id="image" name="image" accept="image/*" required hidden> </div> </div> <!-- Banner Drag-and-Drop field --> <div class="form-group"> <label for="banner">Game Banner (Optional)</label> <div id="banner-drop-area" class="drop-area"> <p>Drag & drop a banner here or click to select a file</p> <img id="banner-preview" src="#" alt="Banner Preview" style="display: none; max-width: 100%; height: auto; margin-top: 10px;"> <input type="file" class="form-control-file" id="banner" name="banner" accept="image/*" hidden> </div> </div> <!-- Tags field --> <div class="form-group"> <label for="tags">Tags (Optional)</label> <input type="text" class="form-control" id="tags" name="tags" placeholder="Enter Tags (comma separated)"> </div> <div class="row"> <div class="col-md-6"> <!-- Featured field --> <div class="form-group"> <label for="featured">Featured</label> <select class="form-control" name="featured" id="featured" required> <option value="0">No</option> <option value="1">Yes</option> </select> </div> </div> <div class="col-md-6"> <!-- Status field --> <div class="form-group"> <label for="status">Status</label> <select class="form-control" name="status" id="status" required> <option value="1">Active</option> <option value="0">Inactive</option> </select> </div> </div> </div> </div> <!-- /.card-body --> <div class="card-footer text-right"> <button type="submit" class="btn btn-primary">Submit</button> </div> </div> <!-- /.card --> </div> </div> </form> </div> <!-- Import from API 1 --> <div class="tab-pane fade" id="generate-api2" role="tabpanel" aria-labelledby="generate-api2-tab"> <form id="gameSearchFormApi2" method="POST"> <?php echo csrf_field(); ?> <div class="card card-primary"> <div class="card-body"> <div class="row"> <div class="col-md-3"> <div class="form-group"> <label for="num">Number of Games</label> <select class="form-control form-select" name="num" id="num"> <option value="20">20</option> <option value="50">50</option> <option value="100">100</option> <option value="200">200</option> </select> </div> </div> <div class="col-md-3"> <div class="form-group"> <label for="category">Game Category</label> <select class="form-control form-select" name="category" id="category"> <option value="">All</option> <option value="1">.IO</option> <option value="2">2 Player</option> <option value="3">3D</option> <option value="">Action</option> <option value="4">Adventure</option> <option value="5">Arcade</option> <option value="19">Baby Hazel</option> <option value="6">Bejeweled</option> <option value="7">Boys</option> <option value="8">Clicker</option> <option value="9">Cooking</option> <option value="10">Girls</option> <option value="11">Hyper-Casual</option> <option value="12">Multi Player</option> <option value="13">Puzzle</option> <option value="14">Racing</option> <option value="15">Shooting</option> <option value="16">Soccer</option> <option value="17">Sports</option> <option value="18">Stickman</option> </select> </div> </div> <div class="col-md-3"> <div class="form-group"> <label for="game_order">Platform</label> <select class="form-control form-select" name="platform" id="platform"> <option value="">All</option> <option value="1">Mobile Games</option> </select> </div> </div> <div class="col-md-3"> <div class="form-group"> <label for="links">Contains Link</label> <select class="form-control form-select" name="links" id="links"> <option value="">All</option> <option value="0">Yes</option> <option value="1">No</option> </select> </div> </div> <div class="col-md-12"> <div class="form-group"> <label for="name">Game Name Contains (Optional)</label> <input type="text" class="form-control" name="name" placeholder="Enter few words..."> </div> </div> </div> </div> <div class="card-footer text-right"> <button type="submit" class="btn btn-success">Generate</button> </div> </div> </form> <!-- Display games in the table --> <table id="gameslist_api2" style="display: none;" class="table table-bordered table-hover"> <thead> <tr> <th><input type="checkbox" id="select-all"></th> <!-- "Select All" checkbox --> <th>#</th> <th>Name</th> <th>Description</th> <th>Category</th> <th>Image</th> <th class="text-right">Action</th> </tr> </thead> <tbody> <!-- Rows will be populated here --> </tbody> </table> <div class="text-right" id="add-game-buttons" style="display: none;"> <button id="add-selected-items" class="btn btn-success"> <i class="fa fa-check"></i> Add Selected Items </button> <button id="add-all-items" class="btn btn-success"> <i class="fa fa-plus"></i> Add All </button> </div> </div> <!-- Generate From API Form --> <div class="tab-pane fade" id="generate-api" role="tabpanel" aria-labelledby="generate-api-tab"> <form id="gameSearchForm" method="POST"> <?php echo csrf_field(); ?> <div class="card card-primary"> <div class="card-body"> <div class="form-group"> <label for="game_order">Games Order By</label> <select class="form-control form-select" name="game_order" id="game_order"> <option value="">Quality</option> <option value="pubdate">Last Published</option> </select> </div> <div class="form-group"> <label for="num_games">Number of Games</label> <select class="form-control form-select" name="num_games" id="num_games"> <option value="12">12</option> <option value="24">24</option> <option value="48">48</option> <option value="96">96</option> </select> </div> </div> <div class="card-footer text-right"> <button type="submit" class="btn btn-success">Generate</button> </div> </div> </form> <!-- Display games in the table --> <table id="gameslist" class="table table-bordered table-hover"> <thead> <tr> <th>#</th> <th>Name</th> <th>Description</th> <th>Category</th> <th>Image</th> <th class="text-right">Action</th> </tr> </thead> <tbody> <!-- Game data will be injected here dynamically --> </tbody> </table> </div> <!-- /.row --> </div><!--/. container-fluid --> </section> <!-- Move the scripts and styles directly into the content section --> <style> .drop-area { border: 2px dashed #ccc; padding: 20px; text-align: center; cursor: pointer; transition: border-color 0.3s ease; } .drop-area.drag-over { border-color: #007bff; } .drop-area p { margin: 0; font-size: 16px; } </style> <script> document.addEventListener('DOMContentLoaded', function () { function initDragAndDrop(dropAreaId, inputId, previewId) { let dropArea = document.getElementById(dropAreaId); let input = document.getElementById(inputId); let preview = document.getElementById(previewId); dropArea.addEventListener('dragover', (event) => { event.preventDefault(); dropArea.classList.add('drag-over'); }); dropArea.addEventListener('dragleave', () => { dropArea.classList.remove('drag-over'); }); dropArea.addEventListener('drop', (event) => { event.preventDefault(); dropArea.classList.remove('drag-over'); input.files = event.dataTransfer.files; if (input.files.length > 0) { const file = input.files[0]; const reader = new FileReader(); reader.onload = function(e) { preview.src = e.target.result; preview.style.display = 'block'; }; reader.readAsDataURL(file); } }); dropArea.addEventListener('click', () => { input.click(); }); input.addEventListener('change', () => { if (input.files.length > 0) { const file = input.files[0]; const reader = new FileReader(); reader.onload = function(e) { preview.src = e.target.result; preview.style.display = 'block'; }; reader.readAsDataURL(file); } }); } initDragAndDrop('image-drop-area', 'image', 'image-preview'); initDragAndDrop('banner-drop-area', 'banner', 'banner-preview'); }); </script> <script> // JavaScript from your original code $(function () { $('#gameTabs a').on('click', function (e) { e.preventDefault(); $(this).tab('show'); }); }); </script> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script> $(document).ready(function () { $('#gameSearchForm').on('submit', function (e) { e.preventDefault(); // Prevent form from submitting traditionally let numGames = $('#num_games').val(); // Get the number of games from input let gameOrder = $('#game_order').val(); // Get game order from select // Build the request data for the API let requestData = { sid: '0O22G', pagination: numGames, page: 1 }; if (gameOrder) { requestData.order = gameOrder; } // Perform the AJAX request to fetch games from the API $.ajax({ url: '<?php echo e(route('admin.games.fetch')); ?>', // Use Laravel route method: 'POST', data: { _token: '<?php echo e(csrf_token()); ?>', num_games: numGames, game_order: gameOrder }, success: function (response) { // Clear the table body $('#gameslist tbody').empty(); // Check if there are any games in the response if (response.games.length > 0) { // Loop through the games and append to the table response.games.forEach((game, index) => { let row = ` <tr> <td>${index + 1}</td> <td>${game.title}</td> <td>${game.description.substring(0, 50)}...</td> <td>${game.category}</td> <td><img src="${game.image}" alt="${game.title}" width="30"></td> <td class="text-right"> <button class="btn btn-success add-game" data-title="${game.title}" data-description="${game.description}" data-image="${game.image}" data-banner="${game.banner_image}" data-url="${game.url}" data-category="${game.category}" data-slug="${game.namespace}"> Add </button> </td> </tr> `; $('#gameslist tbody').append(row); }); // Attach event listeners to dynamically added buttons attachAddGameListeners(); } else { // If no games found $('#gameslist tbody').append('<tr><td colspan="6" class="text-center">No games found.</td></tr>'); } }, error: function (error) { alert('Failed to fetch games. Please try again.'); console.log(error); } }); }); function attachAddGameListeners() { // Handle adding games to the database via AJAX $('.add-game').on('click', function () { let gameData = { title: $(this).data('title'), description: $(this).data('description'), image: $(this).data('image'), banner: $(this).data('banner'), url: $(this).data('url'), category: $(this).data('category'), slug: $(this).data('slug'), _token: '<?php echo e(csrf_token()); ?>' }; // AJAX request to add the game to the database $.ajax({ url: '<?php echo e(route('admin.games.add')); ?>', // Laravel route to handle the addition method: 'POST', data: gameData, success: function (response) { toastr.success('Game added successfully!'); }, error: function (error) { alert('Failed to add game. Please try again.'); console.log(error); } }); }); } }); </script> <script> $(document).ready(function () { // For the API 2 form $('#gameSearchFormApi2').on('submit', function (e) { e.preventDefault(); let num = $('#num').val(); let category = $('#category').val(); let platform = $('#platform').val(); let links = $('#links').val(); let name = $('#name').val(); // Build the request data for the API let requestData = { num: num, category: category, platform: platform, links: links, name: name, }; $.ajax({ url: '<?php echo e(route('admin.api2.fetch')); ?>', method: 'POST', data: requestData, headers: { 'X-CSRF-TOKEN': '<?php echo e(csrf_token()); ?>' }, success: function (response) { document.getElementById('gameslist_api2').style.display = 'table'; document.getElementById('add-game-buttons').style.display = 'block'; $('#gameslist_api2 tbody').empty(); if (response.games.length > 0) { response.games.forEach((game, index) => { let row = ` <tr> <td><input type="checkbox" class="game-checkbox" data-title="${game.title}" data-description="${game.description}" data-image="${game.thumb}" data-url="${game.url}" data-category="${game.category}" data-tags="${game.tags}"></td> <td>${index + 1}</td> <td>${game.title}</td> <td>${game.description.substring(0, 50)}...</td> <td>${game.category}</td> <td><img src="${game.thumb}" alt="${game.title}" width="30"></td> <td class="text-right"> <button class="btn btn-success add-game-api-2" data-title="${game.title}" data-description="${game.description}" data-image="${game.thumb}" data-banner="${game.thumb}" data-url="${game.url}" data-category="${game.category}" data-slug="${game.title}" data-tags="${game.tags}"> Add </button> </td> </tr> `; $('#gameslist_api2 tbody').append(row); }); attachAddGameApi2Listeners(); } else { $('#gameslist_api2 tbody').append('<tr><td colspan="6" class="text-center">No games found.</td></tr>'); } }, error: function (error) { alert('Failed to fetch games. Please try again.'); console.log(error); } }); }); // Select All functionality $('#select-all').on('click', function () { $('.game-checkbox').prop('checked', this.checked); // Check/uncheck all rows }); // Event listener for "Add Selected Items" $('#add-selected-items').on('click', function () { let selectedGames = []; $('.game-checkbox:checked').each(function () { selectedGames.push({ title: $(this).data('title'), description: $(this).data('description'), image: $(this).data('image'), url: $(this).data('url'), category: $(this).data('category'), tags: $(this).data('tags') }); }); if (selectedGames.length > 0) { addGamesWithInterval(selectedGames); } else { alert('No games selected.'); } }); // Event listener for "Add All Items" $('#add-all-items').on('click', function () { let allGames = []; $('.game-checkbox').each(function () { allGames.push({ title: $(this).data('title'), description: $(this).data('description'), image: $(this).data('image'), url: $(this).data('url'), category: $(this).data('category'), tags: $(this).data('tags') }); }); if (allGames.length > 0) { addGamesWithInterval(allGames); } else { alert('No games available to add.'); } }); // Function to send games to the server with an interval function addGamesWithInterval(games) { let index = 0; let interval = 500; // 500ms interval between each request function sendNextGame() { if (index < games.length) { $.ajax({ url: '<?php echo e(route('admin.add.dash')); ?>', // Laravel route to handle adding games method: 'POST', data: { games: [games[index]], // Send one game at a time _token: '<?php echo e(csrf_token()); ?>' }, success: function (response) { toastr.success('Game ' + (index + 1) + ' added successfully!'); index++; setTimeout(sendNextGame, interval); // Proceed to the next game after the delay }, error: function (error) { alert('Failed to add game ' + (index + 1) + '. Please try again.'); console.log(error); index++; // Move to the next game even if there was an error setTimeout(sendNextGame, interval); } }); } else { toastr.success('All games added successfully!'); } } sendNextGame(); // Start the process } function attachAddGameApi2Listeners() { $('.add-game-api-2').on('click', function () { let gameData = { title: $(this).data('title'), description: $(this).data('description'), image: $(this).data('image'), banner: $(this).data('image'), // Using the same image for the banner url: $(this).data('url'), category: $(this).data('category'), slug: $(this).data('title'), tags: $(this).data('tags'), _token: '<?php echo e(csrf_token()); ?>' }; $.ajax({ url: '<?php echo e(route('admin.add.dash')); ?>', method: 'POST', data: gameData, // Send gameData directly, no need for extra nesting success: function (response) { toastr.success('Game added successfully!'); }, error: function (error) { alert('Failed to add game. Please try again.'); console.log(error); } }); }); } }); </script> <?php $__env->stopSection(); ?> <?php echo $__env->make('backend.layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/u300416816/domains/recipeseasy.online/public_html/resources/views/backend/games/create.blade.php ENDPATH**/ ?>
| ver. 1.4 |
Github
|
.
| PHP 8.2.28 | Generation time: 0.03 |
proxy
|
phpinfo
|
Settings