What should I do when I want to get an id like 6
without id
on [{ "id": 6 }]
?
if I do:
public function index(string $name)
{
$category_id = Category::where('name', $name)->get('id');
return Inertia::render('Category', [
'category_id' => $category_id,
'category' => $name,
'product' => Product::where('category', $category_id)->get()
]);
}
the $page.props.category_id
result is
[
{
"id": 6
}
]
And $page.props.product
result is:
[]
And if I run $category_id = Category::where('name', $name)->get();
, the result is:
[
{
"id": 6,
"name": "Arts & Crafts"
}
]
And nothing changes for $page.props.product
.