Datatables Plugin Not Working with no error or hint

I have already installed DataTables on my web app , i have configured its JS dan CSS as below :

here is the head JS include

<!--   Core JS Files   -->
<script src="<?= base_url('assets/js/core/jquery-3.7.1.min.js') ?>"></script>

<!-- Custom Plugins Sweetalert, Cookies, Etc -->
<script src="<?= base_url('assets/js/plugins.js') ?>" type="text/javascript"></script>
<script src="<?= base_url('assets/js/core/bootstrap.bundle.min.js') ?>"></script>
<script src="<?= base_url('assets/js/core/popper.min.js') ?>"></script>
<script src="<?= base_url('assets/js/core/bootstrap-material-design.min.js') ?>"></script>

<!-- DataTables JavaScript -->
<script src="<?= base_url('assets/js/core/datatables.min.js') ?>"></script>
<script src="<?= base_url('assets/js/core/dataTables.bootstrap5.js') ?>"></script>

<script src="<?= base_url('assets/js/plugins/perfect-scrollbar.jquery.min.js') ?>"></script>
<!--  Plugin for the Sliders, full documentation here: http://refreshless.com/nouislider/ -->
<script src="<?= base_url('assets/js/plugins/nouislider.min.js') ?>"></script>
<!-- Control Center for Material Dashboard: parallax effects, scripts for the example pages etc -->
<script src="<?= base_url('assets/js/material-dashboard.js') ?>" type="text/javascript"></script>
<!-- Custom JS App -->
<script src="<?= base_url('assets/js/plugins/file-uploader/js/jquery.dm-uploader.min.js'); ?>"></script>
<script src="<?= base_url('assets/js/plugins/file-uploader/js/ui.js'); ?>"></script>

<script src="<?= base_url('assets/js/custom.js') ?>" type="text/javascript"></script>

the CSS file

<!-- CSS Files -->
<link href="<?= base_url('assets/css/dataTables.bootstrap5.css'); ?>" rel="stylesheet" />
<link href="<?= base_url('assets/css/bootstrap.min.css'); ?>" rel="stylesheet" />
<link href="<?= base_url('assets/fonts/fonts.css?v=1.0.0'); ?>" rel="stylesheet" />
<link href="<?= base_url('assets/css/material-dashboard.css'); ?>" rel="stylesheet" />
<link href="<?= base_url('assets/css/style.css?v=1.0.0'); ?>" rel="stylesheet" />
<link rel="stylesheet" href="<?= base_url('assets/js/plugins/file-uploader/css/jquery.dm-uploader.min.css'); ?>" />
<link rel="stylesheet" href="<?= base_url('assets/js/plugins/file-uploader/css/styles-1.0.css'); ?>" />

<link rel="apple-touch-icon" sizes="76x76" href="<?= base_url('assets/img/apple-icon.png'); ?>">
<link rel="icon" type="image/png" href="<?= base_url('assets/img/favicon.png'); ?>">

the script on the head :

<script>
     $(document).ready(function() {
         $('#example').DataTable({
            responsive: true
        });
    });
</script>

the Data Table Section with id “example” :

<div class="card-body">
   <?php if (!$empty) : ?>
      <table class="table table-striped" id="example">
         <thead class="text-primary">
            <th width="20"><input type="checkbox" class="checkbox-table" id="checkAll"></th>
            <th><b>No</b></th>
            <th><b>#</b></th>
            <th><b>NIS</b></th>
            <th><b>Nama Siswa</b></th>
            <th><b>Jenis Kelamin</b></th>
            <th><b>Kelas</b></th>
            <th><b>Jurusan</b></th>
            <th><b>No HP</b></th>
            <th width="1%"><b>Aksi</b></th>
         </thead>
         <tbody>
            <?php $i = 1;
            
            foreach ($data as $value) : 
            
            $photo = $value['photo'];
            if($photo == NULL || $photo == '' || empty($photo)){
                $photo = "profil.png";
            }
            
            ?>
               <tr>
                  <td><input type="checkbox" name="checkbox-table" class="checkbox-table" value="<?= $value['id_siswa']; ?>"></td>
                  <td><?= $i; ?></td>
                  <td><img src="<?= base_url('uploads/photo/'.$photo) ?>" width="50px" height="50px"></td>
                  <td><?= $value['nis']; ?></td>
                  <td><b><?= $value['nama_siswa']; ?></b></td>
                  <td><?= $value['jenis_kelamin']; ?></td>
                  <td><?= $value['kelas']; ?></td>
                  <td><?= $value['jurusan']; ?></td>
                  <td><?= $value['no_hp']; ?></td>
                  <td>
                     <div class="d-flex justify-content-center">
                        <a title="Edit" href="<?= base_url('admin/siswa/edit/' . $value['id_siswa']); ?>" class="btn btn-primary p-2" id="<?= $value['nis']; ?>">
                           <i class="material-icons">edit</i>
                        </a>
                        <form action="<?= base_url('admin/siswa/delete/' . $value['id_siswa']); ?>" method="post" class="d-inline">
                           <?= csrf_field(); ?>
                           <input type="hidden" name="_method" value="DELETE">
                           <button title="Delete" onclick="return confirm('Konfirmasi untuk menghapus data');" type="submit" class="btn btn-danger p-2" id="<?= $value['nis']; ?>">
                              <i class="material-icons">delete_forever</i>
                           </button>
                        </form>
                        <a title="Download QR Code" href="<?= base_url('admin/qr/siswa/' . $value['id_siswa'] . '/download'); ?>" class="btn btn-success p-2">
                           <i class="material-icons">qr_code</i>
                        </a>
                     </div>
                  </td>
               </tr>
            <?php $i++;
            endforeach; ?>
         </tbody>
      </table>
   <?php else : ?>
      <div class="row">
         <div class="col">
            <h4 class="text-center text-danger">Data tidak ditemukan</h4>
         </div>
      </div>
   <?php endif; ?>
</div>

the html view still not work like this :

enter image description here

can somebody tell me what am i doing wrong ?

‘class name is already in use’ using Vich Uploader

I’m following VichUploader instructions to add a file upload to my form for the Item entity.
Now, if I go to any page of the site I get a raw error (without Symfony profiler and not pretty printed) about two entity names already in use :

Fatal error: Cannot declare class AppEntityItemCategory, because the name is already in use in /Users/corentoulf/DEV/boite-a-partage/src/Entity/ItemCategory.php on line 11.   
Fatal error: Cannot declare class AppEntityItemType, because the name is already in use in /Users/corentoulf/DEV/boite-a-partage/src/Entity/ItemType.php on line 11

If I go to the page where the concerned form is, I get a raw error + pretty Symofny error about only the ItemType entity:

Fatal error: Cannot declare class AppEntityItemType, because the name is already in use in /Users/corentoulf/DEV/boite-a-partage/src/Entity/ItemType.php on line 11

What am I missing in VichUploader configuration that causes such errors ?

Configuration
Vich version : 2.7.0
Symfony version : 7.3.1
PHP version : 8.3.6

Vich config file

vich_uploader:
    db_driver: orm

metadata:
    type: attribute
    auto_detection: true

mappings:
    items:
        uri_prefix: /images/items
        upload_destination: '%kernel.project_dir%/public/images/items'
        namer: VichUploaderBundleNamingSmartUniqueNamer

Item Entity

namespace AppEntity;

use AppRepositoryItemRepository;
use DoctrineCommonCollectionsArrayCollection;
use DoctrineCommonCollectionsCollection;
use DoctrineORMMapping as ORM;

use SymfonyComponentHttpFoundationFileFile;
use VichUploaderBundleMappingAnnotation as Vich;

#[ORMEntity(repositoryClass: ItemRepository::class)]
#[VichUploadable]
class Item
{
    #[ORMId]
    #[ORMGeneratedValue]
    #[ORMColumn]
    private ?int $id = null;

    #[ORMManyToOne(inversedBy: 'items')]
    #[ORMJoinColumn(nullable: false)]
    private ?User $owner = null;

    #[ORMColumn]
    private ?DateTimeImmutable $created_at = null;

    /**
     * @var Collection<int, ItemCircle>
     */
    #[ORMOneToMany(targetEntity: ItemCircle::class, mappedBy: 'item', cascade: ['persist'], orphanRemoval: true)]
    private Collection $itemCircles;

    #[ORMManyToOne(inversedBy: 'items')]
    private ?itemType $itemType = null;

    #[ORMColumn(length: 255, nullable: true)]
    private ?string $property_1 = null;

    #[ORMColumn(length: 255, nullable: true)]
    private ?string $property_2 = null;

    #[ORMColumn(length: 255, nullable: true)]
    private ?string $property_3 = null;

    #[ORMColumn(length: 255, nullable: true)]
    private ?string $property_4 = null;

    #[ORMColumn(length: 255, nullable: true)]
    private ?string $property_5 = null;

    // NOTE: This is not a mapped field of entity metadata, just a simple property.
    #[VichUploadableField(mapping: 'items', fileNameProperty: 'imageName', size: 'imageSize', mimeType: "imageMimeType")]
    private ?File $imageFile = null;

    #[ORMColumn(nullable: true)]
    private ?string $imageName = null;

    #[ORMColumn(nullable: true)]
    private ?int $imageSize = null;

    #[ORMColumn(nullable: true)]
    private ?int $imageMimeType = null;

    #[ORMColumn(nullable: true)]
    private ?DateTimeImmutable $updated_at = null;

    /**
     * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
     * of 'UploadedFile' is injected into this setter to trigger the update. If this
     * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
     * must be able to accept an instance of 'File' as the bundle will inject one here
     * during Doctrine hydration.
     *
     * @param File|SymfonyComponentHttpFoundationFileUploadedFile|null $imageFile
     */
    public function setImageFile(?File $imageFile = null): void
    {
        $this->imageFile = $imageFile;

        if (null !== $imageFile) {
            // It is required that at least one field changes if you are using doctrine
            // otherwise the event listeners won't be called and the file is lost
            $this->updated_at = new DateTimeImmutable();
        }
    }

    public function getImageFile(): ?File
    {
        return $this->imageFile;
    }

    public function setImageName(?string $imageName): void
    {
        $this->imageName = $imageName;
    }

    public function getImageMimeType(): ?string
    {
        return $this->imageMimeType;
    }

    public function setImageMimeType(?string $imageMimeType): void
    {
        $this->imageMimeType = $imageMimeType;
    }

    public function getImageName(): ?string
    {
        return $this->imageName;
    }

    public function setImageSize(?int $imageSize): void
    {
        $this->imageSize = $imageSize;
    }

    public function getImageSize(): ?int
    {
        return $this->imageSize;
    }

    public function __construct()
    {
        $this->itemCircles = new ArrayCollection();
    }

    public function __toString()
    {
        return $this->property_1;
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getOwner(): ?User
    {
        return $this->owner;
    }

    public function setOwner(?User $owner): static
    {
        $this->owner = $owner;

        return $this;
    }

    public function getCreatedAt(): ?DateTimeImmutable
    {
        return $this->created_at;
    }

    public function setCreatedAt(DateTimeImmutable $created_at): static
    {
        $this->created_at = $created_at;

        return $this;
    }

    /**
     * @return Collection<int, ItemCircle>
     */
    public function getItemCircles(): Collection
    {
        return $this->itemCircles;
    }

    public function addItemCircle(ItemCircle $itemCircle): static
    {
        if (!$this->itemCircles->contains($itemCircle)) {
            $this->itemCircles->add($itemCircle);
            $itemCircle->setItem($this);
        }

        return $this;
    }

    public function removeItemCircle(ItemCircle $itemCircle): static
    {
        if ($this->itemCircles->removeElement($itemCircle)) {
            // set the owning side to null (unless already changed)
            if ($itemCircle->getItem() === $this) {
                $itemCircle->setItem(null);
            }
        }

        return $this;
    }

    public function getItemType(): ?itemType
    {
        return $this->itemType;
    }

    public function setItemType(?itemType $itemType): static
    {
        $this->itemType = $itemType;

        return $this;
    }

    public function getProperty1(): ?string
    {
        return $this->property_1;
    }

    public function setProperty1(?string $property_1): static
    {
        $this->property_1 = $property_1;

        return $this;
    }

    public function getProperty2(): ?string
    {
        return $this->property_2;
    }

    public function setProperty2(?string $property_2): static
    {
        $this->property_2 = $property_2;

        return $this;
    }

    public function getProperty3(): ?string
    {
        return $this->property_3;
    }

    public function setProperty3(?string $property_3): static
    {
        $this->property_3 = $property_3;

        return $this;
    }

    public function getProperty4(): ?string
    {
        return $this->property_4;
    }

    public function setProperty4(?string $property_4): static
    {
        $this->property_4 = $property_4;

        return $this;
    }

    public function getProperty5(): ?string
    {
        return $this->property_5;
    }

    public function setProperty5(?string $property_5): static
    {
        $this->property_5 = $property_5;

        return $this;
    }
}

preg_match_all only getting the first match [duplicate]

Here is my pattern:

/^(?:include|require)(?:_once)*[^"']*['"]([^'"]+)['"]/i

I want to find all three of these lines:

include MODX_CORE_PATH . 'test.php';
require_once MODX_CORE_PATH . 'components/dirwalker/model/dirwalker/dirwalker.class.php';
include MODX_CORE_PATH . 'aaaDummy/aaaDummy.txt';

The Rubular regex tester finds all three, but in my code I’m only getting the first one. I’m sure it’s something simple and obvious, but I can’t see it.

How to extend WordPress REST API to include custom meta fields for a custom post type?

I’m working on a custom WordPress project where I’ve registered a custom post type called parcel. It has several custom meta fields like pickup_pincode, drop_pincode, and delivery_type.

I want to expose these custom fields via the WordPress REST API when fetching the parcel posts (e.g., /wp-json/wp/v2/parcel).

I’ve registered the custom post type using register_post_type, and the meta fields using register_post_meta.

Here’s what I’ve tried in functions.php:

function register_parcel_meta_fields() {
    register_post_meta('parcel', 'pickup_pincode', [
        'show_in_rest' => true,
        'type'         => 'string',
        'single'       => true,
    ]);
}
add_action('init', 'register_parcel_meta_fields');

I registered the meta fields using register_post_meta() with 'show_in_rest' => true, expecting them to appear automatically in the REST API response for my custom post type parcel. However, when I fetch the data via /wp-json/wp/v2/parcel, the custom fields like pickup_pincode are missing. I expected them to be visible in the JSON response but they’re not showing up. I’m unsure if I need to do more or hook into a different filter.

Retrieve values using array_udiff in PHP

I am using array_udiff function on Multi-dimensional Arrays:

$old_list = Array ( [0] => Array ( [name] => John [src] => S ) [1] => Array ( [name] => Mary [src] => S ) )

$new_list = Array ( [0] => Array ( [name] =>John [src] => S ) [1] => Array ( [name] => Mary [src] => S ) [2] => Array ( [name] => Peter [src] => S ))

$differences = array_udiff($new_list, $old_list, function($a, $b) {

return strcmp($a["name"], $b["name"]);

});

print_r($differences);

The result is

Array ( [2] => Array ( [name] => Peter [src] => S ) )

How can I get the values Peter & S (name and src) from the variable $differences?

How to visually hide or mask /wp-admin URL in WordPress (for editors users)?

I’m working on a WordPress site and I want to hide the /wp-admin URL from users, especially when they try to access something like:
https://example.com/wp-admin/edit.php or https://example.com/wp-admin/edit.php?post_type=page

My Goal:
When someone types or clicks a link to /wp-admin/…, they should be redirected or see a custom-looking URL, like:
https://example.com/custom-admin/edit.php or https://example.com/custom-admin/edit.php?post_type=page

I know that WordPress core uses /wp-admin as the fixed admin area, Is it possible or not.

Bonus if it can be done only for specific roles like Editors.

Question:
Is there any safe and WordPress-compatible method to visually change or redirect /wp-admin URLs?

Can I set up a role-specific dashboard without completely removing access to core admin?

Finally, In WordPress, I want the /wp-admin URL to function normally, but in the browser address bar, I want to show a different custom path (like /custom-admin) instead of showing /wp-admin.

Thanks in advance!

Updating bitnami stack, WordPress, deprecated errors [duplicate]

Thanks in advance, at one time I was on top of all things PHP related. I’m attempting to update a website on the bitnami stack. The theme is out of support and I’m tasked with fixing everything.

I’m getting many deprecated errors as show below. Can someone point me in the right direction? Google isn’t much help.

   function init() {
        $this->dir = dirname( __FILE__ );


[06-Jul-2025 17:48:42 UTC] PHP Deprecated:  Creation of dynamic property Carell_Custom_Fields::$dir is deprecated in /bitnami/wordpress/wp-content/plugins/carell-custom-fields/ccf.php on line 39
[06-Jul-2025 17:48:42 UTC] PHP Deprecated:  Creation of dynamic property Carell_Custom_Fields::$url is deprecated in /bitnami/wordpress/wp-content/plugins/carell-custom-fields/ccf.php on line 40
[06-Jul-2025 17:48:42 UTC] PHP Deprecated:  Creation of dynamic property Carell_Custom_Fields::$api is deprecated in /bitnami/wordpress/wp-content/plugins/carell-custom-fields/ccf.php on line 60
[06-Jul-2025 17:48:42 UTC] PHP Deprecated:  Creation of dynamic property Carell_Custom_Fields::$form is deprecated in /bitnami/wordpress/wp-content/plugins/carell-custom-fields/ccf.php on line 61
[06-Jul-2025 17:48:42 UTC] PHP Deprecated:  Creation of dynamic property Carell_Custom_Fields::$field_group is deprecated in /bitnami/wordpress/wp-content/plugins/carell-custom-fields/ccf.php on line 62
[06-Jul-2025 17:48:42 UTC] PHP Deprecated:  Creation of dynamic property Carell_Custom_Fields::$fields is deprecated in /bitnami/wordpress/wp-content/plugins/carell-custom-fields/ccf.php on line 63

retrieve data using where condition and sort in descending order

I am trying to retrieve category (id, category_name, status) table data using where condition and sort in descending order for id. I am writing query like::

public function category()
    {
        $category = Category::where('status', 'true');
        return view('admin.services.category', compact('category'));
    }

this is showing error
Attempt to read property "category_name" on array. How to fetch data using where condition as status == true and order id in descending order?

Telegram Bot Not Responding to /start Command

I’m developing a Telegram bot using PHP, and it responds to Telegram updates, but when I send the /start command, it does not react. I’m trying to understand why the bot is not responding to /start.

Key points:
Webhook is enabled and correctly set up with the bot URL (I verified that the URL is correct).
In bot.php, I’m using json_decode(file_get_contents(“php://input”), true) to read the updates from Telegram.
In start.php, I’m handling the /start command, but the bot doesn’t send any message.
I’m using PHP to connect to a MySQL database and store user data in the users table.
I checked the log.txt file, and it correctly receives the updates, but the /start command is not being handled.

Problems I am facing:
The bot does not respond to the /start command.
I’m using send_reply(“sendMessage”, …) to send messages, but nothing happens when /start is sent.
I’m not seeing any errors in the logs when I send /start to the bot.

Anybody would help me?

Index.php can’t find the route/path of the desired files [closed]

Explanation:

I’m making a website (new to this) and wanted to make a system to handle all requests to make maintainece easier.

Idea

When a file needs to go to another path, it would go through index.php and index will reveal the path and direct it there. (A router)
And when the webserver files need to access the database(which is private) they will ask index.php to ask hub.php and hub.php will give the desired information from database.

Issues

Index.php isn’t able to find the path or connect them even though i gave the correct code.

My Files:

Folder/
    ├── database/
    │   ├── accounts/
    │   │   ├── orders/
    │   │   ├── reviews/
    │   │   └── users.json
    │   ├── designs/
    │   └── system/
    │       └── logo.png
    ├── root/
    │   ├── 0/
    │   │   ├── admin.php
    │   ├── 1/
    │   │   └── main.php
    │   ├── 2/
    │   │   ├── catalog.php
    │   │   ├── checkout_system/
    │   │   ├── design.php
    │   │   ├── functions.php
    │   │   └── list-catalog/
    │   ├── 3/
    │   │   └── contact.php
    │   ├── 4/
    │   │   ├── reviews.php
    │   │   └── submit_review.php
    │   ├── 5/
    │   │   ├── bulk-purchase/
    │   │   └── list.php
    │   ├── 6/
    │   │   └── login.php
    │   ├── 7/
    │   │   ├── footer.php
    │   │   └── header.php
    │   └── index.php
    └── hub.php

My index.php code:

<?php
error_reporting(0);
ini_set('display_errors', 0);
define('LOG_FILE', __DIR__.'/security.log');
register_shutdown_function(function() {
    if ($error = error_get_last()) {
        error_log(date('[Y-m-d H:i:s] ').print_r($error,1)."n", 3, LOG_FILE);
    }
});

session_start([
    'cookie_httponly' => 1,
    'cookie_samesite' => 'Strict',
    'sid_length' => 128,
    'sid_bits_per_character' => 6
]);

// Route mapping
$routes = [
    '/' => '/1/main.php',
    '/main' => '/1/main.php',
    '/catalog' => '/2/catalog.php',
    '/design' => '/2/design.php',
    '/contact' => '/3/contact.php',
    '/reviews' => '/4/reviews.php',
    '/submit-review' => '/4/submit_review.php',
    '/login' => '/6/login.php',
    '/logout' => '/6/logout.php',
    '/admin' => '/0/admin.php'
];

// Get requested path
$requestPath = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH);

// Find matching route
foreach ($routes as $route => $file) {
    if ($requestPath === $route) {
        $absolutePath = __DIR__.$file;
        
        // 100% file existence guarantee
        if (!file_exists($absolutePath)) {
            error_log("Missing route file: $absolutePath", 3, LOG_FILE);
            http_response_code(500);
            exit('System configuration error. Admin notified.');
        }
        
        // Generate CSRF token (once per session)
        if (empty($_SESSION['csrf_token'])) {
            $_SESSION['csrf_token'] = bin2hex(random_bytes(32));
        }
        
        // Authentication check
        $protectedRoutes = ['/admin', '/submit-review'];
        if (in_array($route, $protectedRoutes) && empty($_SESSION['user'])) {
            header('Location: /login');
            exit;
        }
        
        include $absolutePath;
        exit;
    }
}

// 404 Handling
http_response_code(404);
$contactPath = __DIR__.'/root/3/contact.php';
if (file_exists($contactPath)) {
    include $contactPath;
} else {
    echo '<h1>404 - Page Not Found</h1>';
}

My hub.php code:

<?php
// Armored session
session_start([
    'cookie_httponly' => 1,
    'cookie_samesite' => 'Strict'
]);

// JSON responses
header('Content-Type: application/json');

// Request validation fortress
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    http_response_code(405);
    exit(json_encode(['error' => 'POST requests only']));
}

$refererHost = parse_url($_SERVER['HTTP_REFERER'] ?? '', PHP_URL_HOST);
$serverHost = $_SERVER['HTTP_HOST'] ?? '';
if ($refererHost !== $serverHost) {
    http_response_code(403);
    exit(json_encode(['error' => 'Cross-origin requests forbidden']));
}

// CSRF vault
$token = $_POST['csrf_token'] ?? '';
if (!isset($_SESSION['csrf_token']) || !hash_equals($_SESSION['csrf_token'], $token)) {
    http_response_code(403);
    exit(json_encode(['error' => 'Security token mismatch']));
}

function verifyAuth() {
    if (empty($_SESSION['user'])) {
        http_response_code(401);
        exit(json_encode(['error' => 'Authentication required']));
    }
}

try {
    $action = $_POST['action'] ?? '';
    
    switch ($action) {
        case 'login':
            $username = $_POST['username'] ?? '';
            $password = $_POST['password'] ?? '';
            
            // Load users
            $users = json_decode(file_get_contents(__DIR__.'/database/accounts/users.json'), true) ?: [];
            foreach ($users as $id => $user) {
                if ($user['username'] === $username && password_verify($password, $user['password'])) {
                    $_SESSION['user'] = [
                        'id' => $id,
                        'name' => $user['name'],
                        'level' => $user['level'] ?? 1
                    ];
                    session_regenerate_id(true);
                    exit(json_encode(['success' => true]));
                }
            }
            exit(json_encode(['success' => false, 'error' => 'Invalid credentials']));
            
        case 'get_designs':
            $designs = [];
            $path = __DIR__.'/database/designs/';
            
            // Glob with absolute security
            foreach (glob($path.'*.{jpg,png,webp}', GLOB_BRACE) as $file) {
                $designs[] = [
                    'name' => basename($file),
                    'url' => '/database/designs/'.rawurlencode(basename($file))
                ];
            }
            exit(json_encode(['designs' => $designs]));
            
        case 'submit_review':
            verifyAuth();
            $data = [
                'id' => 'rev_'.bin2hex(random_bytes(8)),
                'user_id' => $_SESSION['user']['id'],
                'name' => $_POST['name'] ?? '',
                'rating' => max(1, min(5, (int)($_POST['rating'] ?? 5))),
                'comment' => substr($_POST['comment'] ?? '', 0, 500),
                'date' => date('Y-m-d H:i:s')
            ];
            
            // Write with atomic safety
            $tmpFile = tempnam(sys_get_temp_dir(), 'rev');
            file_put_contents($tmpFile, json_encode($data));
            rename($tmpFile, __DIR__."/database/accounts/reviews/pending/{$data['id']}.json");
            
            exit(json_encode(['success' => true]));
            
        default:
            http_response_code(400);
            exit(json_encode(['error' => 'Invalid action']));
    }
} catch (Throwable $e) {
    http_response_code(500);
    exit(json_encode(['error' => 'System processing error']));
}

Attempted Troubleshooting:

  • I made sure they are the exact path
  • i asked ai if there is error in the code and it said no

How to write a SQL query to produce a result which has more than 2 levels of depth

tell me, is it possible to get all the data from 4 tables with one SQL query?

Here is the DB diagram with connections:
enter image description here

Thus, a product can have 1 category, many configurations in which many options.

I would like to get something like this result after the request:

{
  "product_1": {
    "name": "product1",
    "category": "cat1",
    "equipments": {
      "0": {
        "name": "equip1",
        "options": {
          "options1": "options 1",
          "options2": "options 2",
          "options3": "options 3"
        }
      },
      "1": {
        "name": "equip2",
        "options": {
          "options1": "options 3",
          "options2": "options 2"
        }
      }
    }
  },
  "product_2": {
    "name": "product2",
    "category": "cat2",
    "equipments": {
      "0": {
        "name": "equip1",
        "options": {
          "options1": "options 1",
          "options2": "options 3"
        }
      },
      "1": {
        "name": "equip2",
        "options": {
          "options1": "options 3"
        }
      }
    }
  }
}

Is it possible to get this with one query? I’m already tired of these Join and JSON_ARRAYAGG functions, it doesn’t work, I tried to combine them, nothing… Maybe I’m wasting my time and should I use several queries? Or is it possible to get all the data for all the connections in one query? I’m writing in PHP using PDO. Please help me with my problem.

UPD:

Here is an example of what I tried, this is one of the options. Here I was able to get a value only from two tables “Equipments” and “Options”, then I tried to combine another JOIN and it doesn’t work at all.

$stmt = $link->prepare("select equipment.*, JSON_ARRAYAGG(JSON_OBJECT(
            'name', options.name,
            'descript', options.descript
            )) AS Options FROM equipment
            LEFT JOIN options ON equipment.id=options.equipment_id GROUP BY equipment.id
          ");

Why does bybit api return an empty list after requesting trade history?

I am trying to get my trade history from the Bybit api V5, but it keeps returning an empty list although getting my wallet balance works.

I wrote this code below and although the “getBybitWalletBalance” function works perfectly, the “getBybitTradeHistory” function keeps returning an empty list. My last trade on BTCUSDT perpetuals was a month ago. I also tried the other categories, but they all give the same output.

bybit.php

<?php

    $apiKey = '...';
    $apiSecret = '...';
    $window = "5000";

    // Global
    function bybitSignature($method, $path, $query, $body) {
        global $apiKey, $apiSecret, $window;
        $timestamp = round(microtime(true) * 1000);
        if($method === "GET") {
            return hash_hmac("sha256", $timestamp . $apiKey . $window . $query, $apiSecret);
        } else {
            return hash_hmac("sha256", $timestamp . $apiKey . $window . $body, $apiSecret);
        }
    }

    function bybitCurl($url, $signature) {
        global $apiKey, $window;
        $timestamp = round(microtime(true) * 1000);
        $ch = curl_init();
        
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            "Accept: application/json",
            "X-BAPI-API-KEY: " . $apiKey,
            "X-BAPI-TIMESTAMP: " . $timestamp,
            "X-BAPI-SIGN: " . $signature,
            "X-BAPI-RECV-WINDOW: " . $window
        ));
        
        if(curl_errno($ch)) {
            return curl_error($ch);
        } else {
            return curl_exec($ch);
        }
        
        curl_close($ch);
    }

    // Trade
    function getBybitTradeHistory($category) {
        return bybitCurl("https://api.bybit.com/v5/execution/list?category=" . $category, bybitSignature("GET", "/v5/execution/list", "category=" . $category, ""));
    }

    // Account
    function getBybitWalletBalance($accountType) {
        return bybitCurl("https://api.bybit.com/v5/account/wallet-balance?accountType=" . $accountType, bybitSignature("GET", "/v5/account/wallet-balance", "accountType=" . $accountType, ""));
    }

    var_dump(json_decode(getBybitTradeHistory("linear"), true));

?>

output
array(5) { ["retCode"]=> int(0) ["retMsg"]=> string(2) "OK" ["result"]=> array(3) { ["nextPageCursor"]=> string(0) "" ["category"]=> string(6) "linear" ["list"]=> array(0) { } } ["retExtInfo"]=> array(0) { } ["time"]=> int(1751725711326) }

Do I still need an Eloquent decimal cast for DECIMAL(10,6) columns in Laravel 12 / PHP 8.2?

I’m building a Laravel 12 e‑commerce site (PHP 8.2).
Product prices are stored in MySQL as DECIMAL(10,6):

base_price DECIMAL(10,6),
profit     DECIMAL(10,6)

Many articles recommend adding a cast in the model to avoid floating‑point errors:

AppModelsProduct
protected function casts(): array
{
    return [
        'base_price' => 'decimal:6',
        'profit'     => 'decimal:6',
    ];
}

What I tried

  • With no cast and with the decimal:6 cast I get exactly the same results in my calculations.
  • Simple test:
$a = "1097.500000";
$b = "835.700000";
$c = $a - $b;
dd($c);   // 261.8  (as expected)

No visible precision problems.

  • I also have more complex code that deals with profit, base_price, offer_price, and user discount calculations — and so far, I haven’t encountered any floating-point issues or inaccuracies in the results.
$priceSource = (is_numeric($product->offer_price) && $product->offer_price != 0)
    ? $product->offer_price
    : $product->base_price;

$grossPrice = $priceSource + $product->profit; 
$price = $grossPrice - ($grossPrice * $userVipDiscount / 100);

My confusion

  • If the column is already DECIMAL(10,6), does Eloquent still need the cast?

  • Have PHP 8.2 and Laravel 12 improved this enough that the extra cast is redundant?

  • In what practical situations would the decimal:6 cast still make a difference?
    I’d like to understand whether the cast is just defensive habit or still necessary for real‑world money calculations.