no, its not enough.
Don't assume we know what moonshine is
Those lines of code are meaningless out of context
Show what you tried and what you got.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello everyone,
I am currently working with Moonshine, a Laravel-based admin panel package, and I’m facing an issue with displaying a specific column from the data coming through StudentResource.
About my current task: I’m building an admin panel where users can manage student records. Each student record has a relation to the User model (the person who is responsible for that student). I am using Moonshine to create an admin interface, and I want to show a list of users that can be assigned to students. However, I need to display a specific column (e.g., just the user's name) from the StudentResource instead of showing the whole resource.
Here’s what I’m trying to do:
I want to display the name of the user (e.g., "John Doe") in the dropdown field where the admin selects the user for a student, but Moonshine is showing all the data from the StudentResource, which I don't need.
For example, the dropdown should show something like:
John Doe
Jane Smith
But it’s currently showing something like:
User id: 1
User id: 2
The problem: I want to display only the name field in the dropdown, but I’m not sure how to extract just the specific column (e.g., name) from the StudentResource or the associated User model.
Here is the code I am using:
BelongsTo::make('User id', 'user', resource: StudentResource::class)->searchable(),
This code links the User model to the StudentResource, but it’s not displaying just the name field from the User model.
My setup:
Laravel version: 11.31
Moonshine version: 3.2
StudentResource is a resource for the student model, and I'm trying to link it to the User model.
Could anyone point me in the right direction? How can I specify which column to display from the User model or StudentResource? I’m looking to show just the user’s name in the dropdown field.
Thank you in advance!
no, its not enough.
Don't assume we know what moonshine is
Those lines of code are meaningless out of context
Show what you tried and what you got.
Please or to participate in this conversation.