212 lines
6.4 KiB
PHP
212 lines
6.4 KiB
PHP
<?php
|
|
|
|
namespace Koneko\VuexyStoreManager\Livewire\WorkCenters;
|
|
|
|
use Koneko\VuexyAdmin\Livewire\Table\AbstractIndexComponent;
|
|
use Koneko\VuexyStoreManager\Models\StoreWorkCenter;
|
|
use Koneko\VuexyStoreManager\Services\StoreCatalogService;
|
|
|
|
/**
|
|
* Index para Centros de Trabajo, extendiendo la clase base AbstractIndexComponent.
|
|
*/
|
|
class WorkCenterIndex extends AbstractIndexComponent
|
|
{
|
|
/**
|
|
* Usado para filtrar (opcional) o cargar catálogos en la vista.
|
|
*/
|
|
public $store_id;
|
|
|
|
/**
|
|
* Opciones de tiendas (por ejemplo, para un select de filtrado).
|
|
*/
|
|
public $storeOptions = [];
|
|
|
|
/**
|
|
* Montamos (inicializamos) el componente y llamamos al mount() del padre
|
|
* para configurar la tabla y setear $tagName, $singularName, $formId, etc.
|
|
*/
|
|
public function mount(): void
|
|
{
|
|
parent::mount();
|
|
|
|
// Ahora cargamos las opciones de tienda, usando el servicio necesario.
|
|
$storeCatalogService = app(StoreCatalogService::class);
|
|
$this->storeOptions = $storeCatalogService->searchCatalog('stores', '', ['limit' => -1]);
|
|
}
|
|
|
|
/**
|
|
* Indica la clase (o instancia) de tu modelo.
|
|
*
|
|
* @return string
|
|
*/
|
|
protected function model(): string
|
|
{
|
|
// Retornamos la clase del modelo
|
|
return StoreWorkCenter::class;
|
|
}
|
|
|
|
/**
|
|
* Retorna las columnas (header) de tu tabla.
|
|
*
|
|
* @return array
|
|
*/
|
|
protected function columns(): array
|
|
{
|
|
return [
|
|
'action' => 'Acciones',
|
|
'stores_code' => 'Código de Tienda',
|
|
'stores_name' => 'Nombre de la Tienda',
|
|
'code' => 'Código del Centro',
|
|
'name' => 'Nombre del Centro',
|
|
'description' => 'Descripción',
|
|
'manager_name' => 'Gerente',
|
|
'tel' => 'Teléfono',
|
|
'tel2' => 'Teléfono Alternativo',
|
|
'codigo_postal' => 'Código Postal',
|
|
'pais' => 'País',
|
|
'estado' => 'Estado',
|
|
'localidad' => 'Localidad',
|
|
'municipio' => 'Municipio',
|
|
'colonia' => 'Colonia',
|
|
'direccion' => 'Dirección',
|
|
'lat' => 'Latitud',
|
|
'lng' => 'Longitud',
|
|
'status' => 'Estatus',
|
|
'created_at' => 'Creado',
|
|
'updated_at' => 'Actualizado',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Retorna el formato (formatter) de las columnas.
|
|
*
|
|
* @return array
|
|
*/
|
|
protected function format(): array
|
|
{
|
|
return [
|
|
'action' => [
|
|
'formatter' => 'workCenterActionFormatter',
|
|
'onlyFormatter' => true,
|
|
],
|
|
'stores_code' => [
|
|
'formatter' => [
|
|
'name' => 'dynamicBadgeFormatter',
|
|
'params' => ['color' => 'secondary'],
|
|
],
|
|
'align' => 'center',
|
|
],
|
|
'stores_name' => [
|
|
'visible' => false,
|
|
],
|
|
'code' => [
|
|
'formatter' => [
|
|
'name' => 'dynamicBadgeFormatter',
|
|
'params' => ['color' => 'secondary'],
|
|
],
|
|
'align' => 'center',
|
|
'switchable' => false,
|
|
],
|
|
'name' => [
|
|
'switchable' => false,
|
|
],
|
|
'description' => [
|
|
'visible' => false,
|
|
],
|
|
'manager_name' => [
|
|
'formatter' => 'managerFormatter',
|
|
],
|
|
'tel' => [
|
|
'formatter' => 'telFormatter',
|
|
'align' => 'center',
|
|
],
|
|
'tel2' => [
|
|
'formatter' => 'telFormatter',
|
|
'align' => 'center',
|
|
'visible' => false,
|
|
],
|
|
'pais' => [
|
|
'align' => 'center',
|
|
'visible' => false,
|
|
],
|
|
'estado' => [
|
|
'formatter' => 'textNowrapFormatter',
|
|
'visible' => false,
|
|
],
|
|
'localidad' => [
|
|
'formatter' => 'textNowrapFormatter',
|
|
'visible' => false,
|
|
],
|
|
'municipio' => [
|
|
'formatter' => 'textNowrapFormatter',
|
|
'visible' => false,
|
|
],
|
|
'codigo_postal' => [
|
|
'align' => 'center',
|
|
'visible' => false,
|
|
],
|
|
'colonia' => [
|
|
'formatter' => 'textNowrapFormatter',
|
|
'visible' => false,
|
|
],
|
|
'direccion' => [
|
|
'formatter' => 'direccionFormatter',
|
|
'visible' => false,
|
|
],
|
|
'lat' => [
|
|
'align' => 'center',
|
|
'visible' => false,
|
|
],
|
|
'lng' => [
|
|
'align' => 'center',
|
|
'visible' => false,
|
|
],
|
|
'status' => [
|
|
'formatter' => [
|
|
'name' => 'dynamicBooleanFormatter',
|
|
'params' => ['tag' => 'activo'],
|
|
],
|
|
'align' => 'center',
|
|
],
|
|
'created_at' => [
|
|
'formatter' => 'textNowrapFormatter',
|
|
'align' => 'center',
|
|
'visible' => false,
|
|
],
|
|
'updated_at' => [
|
|
'formatter' => 'textNowrapFormatter',
|
|
'align' => 'center',
|
|
'visible' => false,
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Sobrescribe la config base para adaptarla al caso de los Centros de Trabajo.
|
|
*
|
|
* @return array
|
|
*/
|
|
protected function bootstraptableConfig(): array
|
|
{
|
|
// Llamamos al padre y luego ajustamos lo que necesitemos.
|
|
return array_merge(parent::bootstraptableConfig(), [
|
|
'sortName' => 'code',
|
|
'exportFileName' => 'Centros de Trabajo',
|
|
'showFullscreen' => false,
|
|
'showPaginationSwitch'=> false,
|
|
'showRefresh' => false,
|
|
'pagination' => false,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Retorna la vista que se usará para renderizar este componente.
|
|
*
|
|
* @return string
|
|
*/
|
|
protected function viewPath(): string
|
|
{
|
|
return 'vuexy-store-manager::livewire.work-center.index';
|
|
}
|
|
}
|