231 lines
7.3 KiB
PHP
231 lines
7.3 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Koneko\VuexyStoreManager\Livewire\Stores;
|
||
|
|
||
|
use Koneko\VuexyAdmin\Livewire\Table\AbstractIndexComponent;
|
||
|
use Koneko\VuexyStoreManager\Models\Store;
|
||
|
|
||
|
/**
|
||
|
* Listado de Tiendas, extiende de la clase base AbstractIndexComponent
|
||
|
* para reutilizar la lógica de configuración y renderizado de tablas.
|
||
|
*/
|
||
|
class StoreIndex extends AbstractIndexComponent
|
||
|
{
|
||
|
/**
|
||
|
* Almacena rutas útiles para la funcionalidad de edición o eliminación.
|
||
|
* (En tu caso, lo llenas en mount())
|
||
|
*/
|
||
|
public $routes = [];
|
||
|
|
||
|
/**
|
||
|
* Método que define la clase o instancia del modelo a usar en este Index.
|
||
|
*
|
||
|
* @return string
|
||
|
*/
|
||
|
protected function model(): string
|
||
|
{
|
||
|
return Store::class;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Retorna las columnas (header) de la tabla.
|
||
|
*
|
||
|
* @return array
|
||
|
*/
|
||
|
protected function columns(): array
|
||
|
{
|
||
|
return [
|
||
|
'action' => 'Acciones',
|
||
|
'code' => 'Código',
|
||
|
'name' => 'Nombre de la tienda',
|
||
|
'description' => 'Descripción',
|
||
|
'manager_name' => 'Gerente',
|
||
|
'pais' => 'País',
|
||
|
'estado' => 'Estado',
|
||
|
'localidad' => 'Localidad',
|
||
|
'municipio' => 'Municipio',
|
||
|
'codigo_postal' => 'Código Postal',
|
||
|
'colonia' => 'Colonia',
|
||
|
'direccion' => 'Dirección',
|
||
|
'lat' => 'Latitud',
|
||
|
'lng' => 'Longitud',
|
||
|
'email' => 'Correo de la tienda',
|
||
|
'tel' => 'Teléfono',
|
||
|
'tel2' => 'Teléfono Alternativo',
|
||
|
'rfc' => 'RFC',
|
||
|
'nombre_fiscal' => 'Nombre Fiscal',
|
||
|
'regimen_fiscal' => 'Régimen Fiscal',
|
||
|
'domicilio_fiscal' => 'Domicilio Fiscal',
|
||
|
'show_on_website' => 'Visible en Sitio Web',
|
||
|
'enable_ecommerce' => 'eCommerce',
|
||
|
'status' => 'Estatus',
|
||
|
'created_at' => 'Creada',
|
||
|
'updated_at' => 'Modificada',
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Retorna el formato (formatter) para cada columna (similar a 'bt_datatable.format').
|
||
|
*
|
||
|
* @return array
|
||
|
*/
|
||
|
protected function format(): array
|
||
|
{
|
||
|
return [
|
||
|
'action' => [
|
||
|
'formatter' => 'storeActionFormatter',
|
||
|
'onlyFormatter' => true,
|
||
|
],
|
||
|
'code' => [
|
||
|
'formatter' => [
|
||
|
'name' => 'dynamicBadgeFormatter',
|
||
|
'params' => ['color' => 'secondary'],
|
||
|
],
|
||
|
'align' => 'center',
|
||
|
'switchable' => false,
|
||
|
],
|
||
|
'name' => [
|
||
|
'switchable' => false,
|
||
|
],
|
||
|
'description' => [
|
||
|
'visible' => false,
|
||
|
],
|
||
|
'codigo_postal' => [
|
||
|
'align' => 'center',
|
||
|
'visible' => false,
|
||
|
],
|
||
|
'manager_name' => [
|
||
|
'formatter' => 'managerFormatter',
|
||
|
'visible' => true,
|
||
|
],
|
||
|
'pais' => [
|
||
|
'align' => 'center',
|
||
|
],
|
||
|
'estado' => [
|
||
|
'formatter' => 'textNowrapFormatter',
|
||
|
'align' => 'center',
|
||
|
],
|
||
|
'localidad' => [
|
||
|
'formatter' => 'textNowrapFormatter',
|
||
|
'visible' => false,
|
||
|
],
|
||
|
'municipio' => [
|
||
|
'formatter' => 'textNowrapFormatter',
|
||
|
'visible' => false,
|
||
|
],
|
||
|
// la segunda definición de 'codigo_postal' la omites, pues ya está arriba
|
||
|
'colonia' => [
|
||
|
'formatter' => 'textNowrapFormatter',
|
||
|
'visible' => false,
|
||
|
],
|
||
|
'direccion' => [
|
||
|
'formatter' => 'direccionFormatter',
|
||
|
'visible' => false,
|
||
|
],
|
||
|
'lat' => [
|
||
|
'align' => 'center',
|
||
|
'visible' => false,
|
||
|
],
|
||
|
'lng' => [
|
||
|
'align' => 'center',
|
||
|
'visible' => false,
|
||
|
],
|
||
|
'email' => [
|
||
|
'visible' => true,
|
||
|
'formatter' => 'emailFormatter',
|
||
|
],
|
||
|
'tel' => [
|
||
|
'formatter' => 'telFormatter',
|
||
|
],
|
||
|
'tel2' => [
|
||
|
'formatter' => 'telFormatter',
|
||
|
'visible' => false,
|
||
|
],
|
||
|
'rfc' => [
|
||
|
'align' => 'center',
|
||
|
'visible' => false,
|
||
|
],
|
||
|
'nombre_fiscal' => [
|
||
|
'formatter' => 'textNowrapFormatter',
|
||
|
'visible' => false,
|
||
|
],
|
||
|
'regimen_fiscal' => [
|
||
|
'visible' => false,
|
||
|
],
|
||
|
'domicilio_fiscal' => [
|
||
|
'align' => 'center',
|
||
|
'visible' => false,
|
||
|
],
|
||
|
'show_on_website' => [
|
||
|
'formatter' => 'dynamicBooleanFormatter',
|
||
|
'align' => 'center',
|
||
|
],
|
||
|
'enable_ecommerce' => [
|
||
|
'formatter' => 'dynamicBooleanFormatter',
|
||
|
'align' => 'center',
|
||
|
],
|
||
|
'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 de la tabla para inyectar
|
||
|
* tus valores (similar a 'bt_datatable').
|
||
|
*
|
||
|
* @return array
|
||
|
*/
|
||
|
protected function bootstraptableConfig(): array
|
||
|
{
|
||
|
// Llamamos al padre y reemplazamos/ajustamos lo que necesitemos.
|
||
|
return array_merge(parent::bootstraptableConfig(), [
|
||
|
'sortName' => 'code',
|
||
|
'exportFileName' => 'Tiendas',
|
||
|
'showFullscreen' => false,
|
||
|
'showPaginationSwitch'=> false,
|
||
|
'showRefresh' => false,
|
||
|
'pagination' => false,
|
||
|
]);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Montamos el componente (ajustando rutas o algo adicional),
|
||
|
* y llamamos al parent::mount() para que se configure la tabla.
|
||
|
*/
|
||
|
public function mount(): void
|
||
|
{
|
||
|
parent::mount();
|
||
|
|
||
|
// Definimos las rutas específicas de este componente
|
||
|
$this->routes = [
|
||
|
'admin.store-manager.stores.edit' => route('admin.store-manager.stores.edit', ['store' => ':id']),
|
||
|
'admin.store-manager.stores.delete' => route('admin.store-manager.stores.delete', ['store' => ':id']),
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Retorna la vista a renderizar por este componente.
|
||
|
*
|
||
|
* @return string
|
||
|
*/
|
||
|
protected function viewPath(): string
|
||
|
{
|
||
|
return 'vuexy-store-manager::livewire.stores.index';
|
||
|
}
|
||
|
}
|