Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Working with nested layouts ?

Hello,

I discover Inertia and I attemp to work with nested layouts as described in the documentation on the website.

I have created a Layout.vue view and an Index.vue view to show a list of students.

I want to display and refresh only the details of a student when I click on a student name in the list on the left.

To retieve the details, I use a controller with the show method and I render the Show.vue view.

Here is a part of my code.

Index.vue with the Layout.vue as layout.

<template>
	<div class="left-column">
		// Here is the list 
	</div>
	<div class="right-column">
		<slot>// Here are the details</slot>
	</div>
</template>

Show.vue with the Index.vue as layout.

<template>
	<div>
		// Here are the details
	</div>
</template>
<script>
	import Layout from '../Layout'
	import Index from './Index'
	export default {
  		layout: [Layout, Index],
  		props: {
    	student: Object,
  	},
}
</script>

Is it possible to do that ? Well when I click on a student in the list, the list disappears and the details appears.

I want to have always the list visible and the details change for each student.

For me it doesn't work, but I perhaps have done something wrong.

I you have any idea ;).

Thanks for your help.

Vincent

0 likes
1 reply
vincent15000's avatar

I don't know if it's the best way, but I have found a partial solution.

For the example, I use 2 routes and only one view (the Index view) :

  • for the first route the controller retrieves the list of students and renders the Index view
  • for the second route, the controller (another method) loads only the selected user and renders the same Index view with a partial reload

I don't know if it's a good idea to work so, but it works ;).

Please or to participate in this conversation.