Uploading content

This commit is contained in:
David
2025-03-12 00:41:31 -04:00
parent b192e57eb5
commit f70ef52f9e
108 changed files with 13255 additions and 0 deletions

View File

@@ -0,0 +1,215 @@
<?php
namespace App\Livewire\Examples;
use App\Models\Product;
use Illuminate\Database\Eloquent\Model;
use Illuminate\View\View;
use Livewire\Attributes\On;
use Mmt\GenericTable\Attributes\BulkAction;
use Mmt\GenericTable\Attributes\BulkActionGroup;
use Mmt\GenericTable\Attributes\CellFormatter;
use Mmt\GenericTable\Attributes\Column;
use Mmt\GenericTable\Attributes\ColumnFilter;
use Mmt\GenericTable\Attributes\ColumnSettings;
use Mmt\GenericTable\Attributes\MappedColumn;
use Mmt\GenericTable\Attributes\MappedRoute;
use Mmt\GenericTable\Attributes\OnReorder;
use Mmt\GenericTable\BulkActionSettings;
use Mmt\GenericTable\ColumnSettingFlags;
use Mmt\GenericTable\CommonDateFilter;
use Mmt\GenericTable\ExportSettings;
use Mmt\GenericTable\FilterType;
use Mmt\GenericTable\Interfaces\IActionColumn;
use Mmt\GenericTable\Interfaces\IDragDropReordering;
use Mmt\GenericTable\Interfaces\IExportable;
use Mmt\GenericTable\Interfaces\IGenericTable;
use Mmt\GenericTable\Interfaces\IPaginationRack;
use Mmt\GenericTable\Interfaces\IRowsPerPage;
use Mmt\GenericTable\PaginationRack;
class BasicTableComponent implements IGenericTable
{
#[MappedColumn]
#[ColumnSettings(ColumnSettingFlags::NONE, ColumnSettingFlags::SORTEABLE)]
public int $Id;
#[Column('Name')]
#[ColumnSettings(ColumnSettingFlags::SORTEABLE, ColumnSettingFlags::EXPORTABLE, ColumnSettingFlags::SEARCHABLE)]
#[MappedRoute('product_details', ['id' => ':id'])]
public string $Name;
#[MappedColumn]
#[ColumnSettings(ColumnSettingFlags::SORTEABLE, ColumnSettingFlags::SEARCHABLE)]
public string $Description;
#[MappedColumn]
#[ColumnSettings(ColumnSettingFlags::SORTEABLE, ColumnSettingFlags::SEARCHABLE, ColumnSettingFlags::EXPORTABLE)]
public float $Price;
#[MappedColumn]
#[ColumnSettings(ColumnSettingFlags::SORTEABLE)]
public string $Status;
#[MappedColumn('subDepartment.name')]
public string $SubDepartment;
#[MappedColumn('subDepartment.department.name')]
#[ColumnSettings(ColumnSettingFlags::EXPORTABLE)]
public string $Department;
#[MappedColumn]
#[ColumnSettings(ColumnSettingFlags::DEFAULT_SORT_ASC)]
public string $Order;
// #[MappedColumn]
// #[ColumnSettings(ColumnSettingFlags::HIDDEN)]
// public string $DepartmentId;
public Model|string $model;
public int $rowsPerPage = 10;
public array $rowsPerPageOptions = [10,20,40,60,100];
public int $actionColumnIndex = -1;
public function __construct()
{
$this->model = Product::class;
}
#[CellFormatter('price')]
public function priceFormatter(Model $row)
{
return "$$row->price";
}
// #[CellFormatter('department.name')]
// public function categoryFormatter(Model $row)
// {
// return '--eep--';
// }
#[ColumnFilter('status', FilterType::SINGLE_SELECTION)]
public function statusFilter()
{
return [
'out_of_stock',
'discontinued',
'available',
'All' => -1
];
}
// #[ColumnFilter('name', FilterType::MULTI_SELECTION)]
// public function brandsFilter()
// {
// return [
// 'product 1',
// 'product 2',
// 'Addidas',
// 'All'
// ];
// }
// #[ColumnFilter('price', FilterType::MULTI_SELECTION)]
// public function namesFilter()
// {
// return [
// 'Pedro',
// 'Pablo',
// 'Juan',
// 'All'
// ];
// }
// #[ColumnFilter('created_at', FilterType::DATE_RANGE)]
// public function dateRangeFilter()
// {
// $flags = 0;
// CommonDateFilter::addFlag($flags,
// CommonDateFilter::ALL_RANGES,
// );
// return $flags;
// }
// public function onBeforeExport(): ExportSettings
// {
// return new ExportSettings();
// }
public function onExport(array &$headers, array &$rows): void
{
dd($headers, $rows);
}
public function actionView() : View
{
return view('action-column');
}
public function edit()
{
throw new \Exception('Not implemented');
}
#[OnReorder]
public function onReorderCallback(int $newPosition, $oldPosition, Model $model)
{
/**
* If method exists, should return TRUE indicating to the subsystem that
* this method will handle the reording.
* If you do not explicitly return boolean, the subsystem will use FALSE as a default returned value
*/
return false;
}
#[BulkAction]
public function deleteAllUsers($data)
{
dd($data);
}
#[BulkActionGroup('Marketing', 'Promotions')]
#[BulkAction]
public function sendHedgeFundPromotions($data)
{
dd($data);
}
#[BulkActionGroup('Marketing', 'Promotions')]
#[BulkAction]
public function sendFundingPromotions($data)
{
dd($data);
}
#[BulkActionGroup('Marketing', 'Promotions')]
#[BulkAction(requestConfirmation: false)]
public function uniqueTest($data)
{
dd($data);
}
// #[BulkActionGroup('Accounts')]
// #[BulkAction]
// public function sendVerificationEmails(BulkActionSettings $data)
// {
// dd($data->getSelection());
// }
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Livewire\Examples;
use Livewire\Component;
class FrameComponent extends Component
{
public function render()
{
return view('livewire.examples.frame-component')
->extends('components.layouts.app')
->section('content');
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Livewire\Examples;
use App\Tables\TableWithMySettings;
use Livewire\Component;
class MyCustomSettingsTableComponent extends Component
{
public function render()
{
return view('livewire.examples.my-custom-settings-table-component', [
'table' => TableWithMySettings::class
])
->extends('components.layouts.app')
->section('content');
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Livewire\Examples;
use App\Tables\TableWithActionColumn;
use Livewire\Attributes\On;
use Livewire\Component;
class TableWithActionColumnComponent extends Component
{
public function render()
{
return view('livewire.examples.with-action-column-component', [
'table' => TableWithActionColumn::class,
])
->extends('components.layouts.app')
->section('content');
}
#[On('edit')]
public function edit(int $productId)
{
dd('Editing product: ' . $productId);
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Livewire\Examples;
use App\Tables\TableWithBindedRoutes;
use Livewire\Component;
class TableWithBindedRoutesComponent extends Component
{
public function render()
{
return view('livewire.examples.table-with-binded-routes', [
'table' => TableWithBindedRoutes::class,
])
->extends('components.layouts.app')
->section('content');
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Livewire\Examples;
use App\Tables\TableWithBulkActions;
use Livewire\Component;
class TableWithBulkActionsComponent extends Component
{
public function render()
{
return view('livewire.table-with-bulk-actions-component', [
'table' => TableWithBulkActions::class,
])
->extends('components.layouts.app')
->section('content');
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Livewire\Examples;
use App\Tables\TableWithColumnFormatter;
use Livewire\Component;
class TableWithColumnFormatterComponent extends Component
{
public function render()
{
return view('livewire.examples.table-with-column-formatter', [
'table' => TableWithColumnFormatter::class,
])
->extends('components.layouts.app')
->section('content');
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Livewire\Examples;
use App\Tables\TableWithDragDropOrdering;
use Livewire\Component;
class TableWithDragDropOrderingComponent extends Component
{
public function render()
{
return view('livewire.table-with-drag-drop-ordering-component', [
'table' => TableWithDragDropOrdering::class
])
->extends('components.layouts.app')
->section('content');
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace App\Livewire\Examples;
use App\Tables\TableWithExport;
use Livewire\Component;
class TableWithExportComponent extends Component
{
public function render()
{
return view('livewire.examples.table-with-export', ['table' => TableWithExport::class])
->extends('components.layouts.app')
->section('content');
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Livewire\Examples;
use App\Tables\TableWithFilters;
use Livewire\Component;
class TableWithFiltersComponent extends Component
{
public int $tab;
public function mount()
{
$this->tab = 1;
}
public function render()
{
return view('livewire.examples.table-with-filters-component', [
'table' => TableWithFilters::class
])
->extends('components.layouts.app')
->section('content');
}
public function updatedTab($val)
{
$this->dispatch('injectParams', ['tabView' => $val]);
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace App\Livewire\Examples;
use App\Tables\TableWithnNoSettings;
use Livewire\Component;
class TableWithNoSettingsComponent extends Component
{
public function render()
{
return view('livewire.examples.table-with-no-settings-component', ['noSettingsTable' => TableWithnNoSettings::class])
->extends('components.layouts.app')
->section('content');
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Livewire\Examples;
use App\Tables\TableWithPaginationSettings;
use Livewire\Component;
class TableWithPaginationSettingsComponent extends Component
{
public function render()
{
return view('livewire.examples.table-with-pagination-settings-component', [
'table' => TableWithPaginationSettings::class
])
->extends('components.layouts.app')
->section('content');
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Livewire\Examples;
use App\Tables\TableWithRelationships;
use Livewire\Component;
class TableWithRelationshipsComponent extends Component
{
public $kil = [];
public function render()
{
// $this->test('hola', 'mundo');
return view('livewire.examples.table-with-relationships', [
'table' => TableWithRelationships::class
])
->extends('components.layouts.app')
->section('content');
}
public function test(string ...$e)
{
array_push($this->kil, ...$e);
dd($this->kil);
}
}