1

I am using Laravel orchid package and in layout file, I have this function:

 protected function columns(): iterable
    {
        $org = '';
        $employeeDetails = '';
        return [
            TD::make('Userid', __('User Id'))
            ->cantHide()
            ->sort()
            ->filter(Input::make()),
            TD::make($employeeDetails, __('Employee Name'))
            ->filter(Input::make())
            ->render(function(DailyAttendance $attendance) {
                $employeeDetails = Employee::where('employeeCode', $attendance->Userid)->first(['employeeName']);
                
                return $employeeDetails;
                
            })
            ->sort(),
           
        ];
    }

The result is not picking employee name but whole with field name like this:

enter image description here

There are 2 tables one which is getting attendance logs based on userid and another table which is storing employee records like name and organizaion based on userid.

How can I only get the employee name using first or get.

I tried get('fieldname') but it is also returning the same result.

samir chauhan
  • 1,543
  • 1
  • 17
  • 42

1 Answers1

1

You can try remove the initialization of $employeeDetails and pass employeeName as the first argument to TD::make() in the second column definition. Then in the render() method, you can use pluck('employeeName') instead of first(['employeeName']) to get only the employee name:

 TD::make('employeeName', __('Employee Name'))

and

$employeeDetails = Employee::where('employeeCode', $attendance->Userid)->pluck('employeeName')->first();
Balaji Kandasamy
  • 4,446
  • 10
  • 40
  • 58