Forms\Components\Select::make('product_id')
->label('Product')
->searchable()
->getSearchResultsUsing(function (RelationManager $livewire, string $search) {
/** @var VendingMachine $ownerRecord */
$ownerRecord = $livewire->ownerRecord;
return $ownerRecord
->sellingPoint
->zone
->zoneProducts()
->join('products', 'product_id', '=', 'products.id')
->where('products.name', 'like', "%$search%")
->select('zones_products.id', 'zones_products.product_id', 'products.name', 'products.id')
->limit(50)
->pluck('product.name', 'product.id');
}),
Forms\Components\Select::make('product_id')
->label('Product')
->searchable()
->getSearchResultsUsing(function (RelationManager $livewire, string $search) {
/** @var VendingMachine $ownerRecord */
$ownerRecord = $livewire->ownerRecord;
return $ownerRecord
->sellingPoint
->zone
->zoneProducts()
->join('products', 'product_id', '=', 'products.id')
->where('products.name', 'like', "%$search%")
->select('zones_products.id', 'zones_products.product_id', 'products.name', 'products.id')
->limit(50)
->pluck('product.name', 'product.id');
}),