Laravel Nova getting the relations in the custom Text field

时间:2019-01-09 22:19:35

标签: laravel one-to-many laravel-nova

I am developing a Laravel application. I am using Nova for the admin panel. I am having a problem with finding a way to display the data from the relations. This is my scenario.

I have two tables/models.

interviews
---------
id
created_at
address
about

interview_logs
--------------
id
stage
interview_id

I have nova resource for interview.

public function fields(Request $request)
{
    return [
        ID::make()->sortable(),
        Text::make("Address"),
        Text::make("Stage", function () {
           //here I got problem.
           //this is what I want to do
           //return $this->interview_logs()->orderBy('created_at', 'desc')->first()->stage;
        })

}

I commented what I want to do in the code. Basically I like to display a column of the relation in the custom field. How can I do that?

0 个答案:

没有答案
相关问题