Skip to content

Commit

Permalink
fix #1516, check inertia component array key (#1525)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikn69 authored Feb 14, 2024
1 parent 0f74197 commit 4b90deb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/DataCollector/ViewCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public function addView(View $view)
// Prevent duplicates
$hash = $type . $path . $name . $this->collect_data ? implode(array_keys($view->getData())) : '';

if (class_exists('\Inertia\Inertia') && isset($data['page'], $data['component'])) {
$data = $data['page'];
$name = $data['component'];
if (class_exists('\Inertia\Inertia') && isset($data['page']['props'], $data['page']['component'])) {
$name = $data['page']['component'];
$data = $data['page']['props'];

if (!@file_exists($path = resource_path('js/Pages/' . $name . '.js'))) {
if (!@file_exists($path = resource_path('js/Pages/' . $name . '.vue'))) {
Expand Down Expand Up @@ -106,7 +106,7 @@ public function addView(View $view)
}

if ($this->collect_data === 'keys') {
$params = array_keys($view->getData());
$params = array_keys($data);
} elseif ($this->collect_data) {
$params = array_map(
fn ($value) => $this->getDataFormatter()->formatVar($value),
Expand Down

0 comments on commit 4b90deb

Please sign in to comment.