<?php
//CourierStopsResource.php
use \koolreport\dashboard\admin\Resource;
use \koolreport\dashboard\fields\ID;
use \koolreport\dashboard\fields\Text;
use \koolreport\dashboard\fields\Date;
use \koolreport\dashboard\fields\Number;
class CourierStopsResource extends Resource
{
protected function onCreated()
{
$this->manageTable("mec_courierstops")->inSource(MECLogs::class);
}
protected function fields()
{
return [
ID::create("stopNumber")
->showOnCreate(false)
->showOnIndex(false),
Date::create("stopDate")
->sortable(true)
->sort("desc"),
Text::create("locationName")
->inputWidget(
Select::create()
->dataSource(function(){
return MECLogs::table("mec_locations")
->select("locationId,locationName");
})
->fields(function(){
return [
Text::create("locationName")
];
})
),
Number::create("covidCount")
->label("COVID Count"),
Number::create("utiCount")
->label("UTI Count"),
Text::create("notes")
->label("Notes"),
];
}
}
On Resource Table List, I want to see: Stop Date, Location Name, Covid Count, UTI Count, Notes
On Create page, I want to enter: Stop Date, Location ID, Covid Count, UTI Count, Notes
Create page works but on list page, I see the Location Id instead of Location Name. How can I change it to show the Location Name from the Locations table?