Uploading content
This commit is contained in:
32
app/Tables/TableWithActionColumn.php
Normal file
32
app/Tables/TableWithActionColumn.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tables;
|
||||
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Tables\Traits\WithExportableProductColumns;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Mmt\GenericTable\Interfaces\IActionColumn;
|
||||
use Mmt\GenericTable\Interfaces\IEvent;
|
||||
use Mmt\GenericTable\Interfaces\IGenericTable;
|
||||
use Mmt\GenericTable\Support\EventArgs;
|
||||
|
||||
class TableWithActionColumn implements IGenericTable, IActionColumn, IEvent
|
||||
{
|
||||
use WithExportableProductColumns;
|
||||
|
||||
public Model|string $model = Product::class;
|
||||
|
||||
public int $actionColumnIndex = -1;
|
||||
|
||||
public function actionView(Model $item): \Illuminate\View\View
|
||||
{
|
||||
return view("tables_action_views.edit_delete_details", ['productId' => $item->id]);
|
||||
}
|
||||
|
||||
|
||||
public function dispatchCallback(EventArgs $arguments): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
27
app/Tables/TableWithBindedRoutes.php
Normal file
27
app/Tables/TableWithBindedRoutes.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tables;
|
||||
|
||||
use App\Tables\Traits\WithColumnFormatter;
|
||||
use Mmt\GenericTable\Attributes\MappedRoute;
|
||||
use Mmt\GenericTable\Components\Column;
|
||||
use Mmt\GenericTable\Components\ColumnCollection;
|
||||
use Mmt\GenericTable\Interfaces\IGenericTable;
|
||||
|
||||
class TableWithBindedRoutes implements IGenericTable
|
||||
{
|
||||
use WithColumnFormatter;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->columns = ColumnCollection::make(
|
||||
new Column('Id'),
|
||||
new Column('Name'),
|
||||
new Column('Description')
|
||||
->bindToRoute(MappedRoute::make('with_relationships', ['id' => ':id'])),
|
||||
new Column('Price'),
|
||||
new Column('Stock'),
|
||||
new Column('SubDepartment', 'subDepartment.name'),
|
||||
);
|
||||
}
|
||||
}
|
||||
58
app/Tables/TableWithBulkActions.php
Normal file
58
app/Tables/TableWithBulkActions.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tables;
|
||||
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Mmt\GenericTable\Components\Column;
|
||||
use Mmt\GenericTable\Components\ColumnCollection;
|
||||
use Mmt\GenericTable\Interfaces\IBulkAction;
|
||||
use Mmt\GenericTable\Interfaces\IGenericTable;
|
||||
use Mmt\GenericTable\Support\BulkAction;
|
||||
use Mmt\GenericTable\Support\BulkActionCollection;
|
||||
use Mmt\GenericTable\Support\BulkActionGroup;
|
||||
use Mmt\GenericTable\Support\BulkActionSettings;
|
||||
|
||||
class TableWithBulkActions implements IGenericTable, IBulkAction
|
||||
{
|
||||
public Model|string $model;
|
||||
|
||||
public ColumnCollection $columns;
|
||||
|
||||
public BulkActionCollection $bulkActionCollection;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new Product();
|
||||
|
||||
$this->columns = ColumnCollection::make(
|
||||
new Column('Id'),
|
||||
new Column('Description'),
|
||||
new Column('Price'),
|
||||
new Column('Stock'),
|
||||
new Column('Department', 'subDepartment.department.name'),
|
||||
new Column('SubDepartment', 'subDepartment.name'),
|
||||
);
|
||||
|
||||
|
||||
|
||||
$this->bulkActionCollection = BulkActionCollection::make(
|
||||
BulkActionGroup::make('Emails',
|
||||
BulkActionGroup::make('FxLive',
|
||||
BulkActionGroup::make('Marketing',
|
||||
BulkAction::make('100:1 Boost Fund', fn($e) => $this->ProcessMassiveEmailMarketing($e)),
|
||||
BulkAction::make('100:2 Boost Fund', fn($e) => $this->ProcessMassiveEmailMarketing($e)),
|
||||
BulkAction::make('100:3 Boost Fund', fn($e) => $this->ProcessMassiveEmailMarketing($e)),
|
||||
),
|
||||
BulkAction::make('100:3 Boost Fund', fn($e) => $this->ProcessMassiveEmailMarketing($e)),
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function ProcessMassiveEmailMarketing(BulkActionSettings $bulkActionSettings)
|
||||
{
|
||||
dd('Processing action ... ', $bulkActionSettings);
|
||||
}
|
||||
}
|
||||
11
app/Tables/TableWithColumnFormatter.php
Normal file
11
app/Tables/TableWithColumnFormatter.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tables;
|
||||
|
||||
use App\Tables\Traits\WithColumnFormatter;
|
||||
use Mmt\GenericTable\Interfaces\IGenericTable;
|
||||
|
||||
class TableWithColumnFormatter implements IGenericTable
|
||||
{
|
||||
use WithColumnFormatter;
|
||||
}
|
||||
20
app/Tables/TableWithDragDropOrdering.php
Normal file
20
app/Tables/TableWithDragDropOrdering.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tables;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Tables\Traits\WithColumnFormatter;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Mmt\GenericTable\Interfaces\IDragDropReordering;
|
||||
use Mmt\GenericTable\Interfaces\IGenericTable;
|
||||
|
||||
class TableWithDragDropOrdering implements IGenericTable, IDragDropReordering
|
||||
{
|
||||
use WithColumnFormatter;
|
||||
|
||||
public string $Order;
|
||||
|
||||
public Model|string $model = Product::class;
|
||||
|
||||
public string $orderingColumn = 'order';
|
||||
}
|
||||
25
app/Tables/TableWithExport.php
Normal file
25
app/Tables/TableWithExport.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tables;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Tables\Traits\WithExportableProductColumns;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Response;
|
||||
use Mmt\GenericTable\Components\ColumnCollection;
|
||||
use Mmt\GenericTable\Interfaces\IExportable;
|
||||
use Mmt\GenericTable\Interfaces\IGenericTable;
|
||||
use Mmt\GenericTable\Support\ExportEventArgs;
|
||||
use Mmt\GenericTable\Support\ExportSettings;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class TableWithExport implements IGenericTable, IExportable
|
||||
{
|
||||
use WithExportableProductColumns;
|
||||
|
||||
public function onExport(ExportEventArgs $args) : BinaryFileResponse|Response
|
||||
{
|
||||
$args->settings->fileName = 'products';
|
||||
return $args->export();
|
||||
}
|
||||
}
|
||||
75
app/Tables/TableWithFilters.php
Normal file
75
app/Tables/TableWithFilters.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tables;
|
||||
|
||||
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Mmt\GenericTable\Components\ColumnCollection;
|
||||
use Mmt\GenericTable\Enums\CommonDateFilter;
|
||||
use Mmt\GenericTable\Interfaces\IDateRangeFilter;
|
||||
use Mmt\GenericTable\Interfaces\IDragDropReordering;
|
||||
use Mmt\GenericTable\Interfaces\IEvent;
|
||||
use Mmt\GenericTable\Interfaces\IGenericTable;
|
||||
use Mmt\GenericTable\Interfaces\ILoadingIndicator;
|
||||
use Mmt\GenericTable\Interfaces\IMultiSelectionFilter;
|
||||
use Mmt\GenericTable\Interfaces\ISingleSelectionFilter;
|
||||
use Mmt\GenericTable\Support\DatabaseEvent;
|
||||
use Mmt\GenericTable\Support\DateFilterSettings;
|
||||
use Mmt\GenericTable\Support\EventArgs;
|
||||
use Mmt\GenericTable\Support\SelectionFilterSettings;
|
||||
|
||||
class TableWithFilters implements IGenericTable, IEvent, IDateRangeFilter, ISingleSelectionFilter, IMultiSelectionFilter, IDragDropReordering, ILoadingIndicator
|
||||
{
|
||||
public Model|string $model = Product::class;
|
||||
|
||||
public ColumnCollection $columns;
|
||||
|
||||
public DateFilterSettings $dateFilterSettings;
|
||||
|
||||
public SelectionFilterSettings $singleSelectionFilterSettings;
|
||||
|
||||
public SelectionFilterSettings $multiSelectionFilterSettings;
|
||||
|
||||
public bool $isTableLoaderEnabled = true;
|
||||
|
||||
public string $orderingColumn = 'order';
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->dateFilterSettings = new DateFilterSettings('created_at',
|
||||
CommonDateFilter::LAST_2_MONTHS,
|
||||
CommonDateFilter::LAST_3_MONTHS
|
||||
);
|
||||
|
||||
$this->singleSelectionFilterSettings = new SelectionFilterSettings('status')
|
||||
->add('Out of stock', 'out_of_stock')
|
||||
->add('Discontinued', 'discontinued')
|
||||
->add('Available', 'available');
|
||||
|
||||
$this->multiSelectionFilterSettings = new SelectionFilterSettings('name')
|
||||
->add('Be a man', 'quod 36840466')
|
||||
->add('Do the right', 'blanditiis 469800')
|
||||
->add('Things happens', 'tempore 71086');
|
||||
}
|
||||
|
||||
|
||||
public function dispatchCallback(EventArgs $arguments): void
|
||||
{
|
||||
if($arguments instanceof DatabaseEvent)
|
||||
{
|
||||
if($arguments->injectedArguments['tabView'] == 1)
|
||||
$arguments->builder->where('status', 'discontinued');
|
||||
else
|
||||
$arguments->builder->where('status', 'available');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function tableLoadingIndicatorView(): \Illuminate\View\View
|
||||
{
|
||||
return view('custom-loader');
|
||||
}
|
||||
}
|
||||
54
app/Tables/TableWithMySettings.php
Normal file
54
app/Tables/TableWithMySettings.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tables;
|
||||
|
||||
use App\Models\Product;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Mmt\GenericTable\Attributes\BulkAction;
|
||||
use Mmt\GenericTable\Attributes\Column;
|
||||
use Mmt\GenericTable\Attributes\ColumnFilter;
|
||||
use Mmt\GenericTable\Attributes\ColumnSettings;
|
||||
use Mmt\GenericTable\Attributes\MappedColumn;
|
||||
use Mmt\GenericTable\Enums\ColumnSettingFlags;
|
||||
use Mmt\GenericTable\Enums\CommonDateFilter;
|
||||
use Mmt\GenericTable\Enums\FilterType;
|
||||
use Mmt\GenericTable\Interfaces\IDateRangeFilter;
|
||||
use Mmt\GenericTable\Interfaces\IGenericTable;
|
||||
use Mmt\GenericTable\Support\DateFilterSettings;
|
||||
|
||||
class TableWithMySettings implements IGenericTable
|
||||
{
|
||||
public Model|string $model = Product::class;
|
||||
|
||||
public DateFilterSettings $dateRanges;
|
||||
|
||||
#[MappedColumn]
|
||||
public int $Id;
|
||||
|
||||
|
||||
#[MappedColumn]
|
||||
public string $Name;
|
||||
|
||||
|
||||
#[MappedColumn('subDepartment.department.name')]
|
||||
public string $Department;
|
||||
|
||||
|
||||
#[MappedColumn]
|
||||
public string $CreatedAt;
|
||||
|
||||
|
||||
|
||||
|
||||
// #[ColumnFilter('created_at', FilterType::DATE_RANGE)]
|
||||
// public function sijsjm()
|
||||
// {
|
||||
// return setFlags(
|
||||
// CommonDateFilter::LAST_3_MONTHS,
|
||||
// CommonDateFilter::LAST_3_MONTHS,
|
||||
// CommonDateFilter::LAST_3_MONTHS
|
||||
// );
|
||||
// }
|
||||
}
|
||||
29
app/Tables/TableWithPaginationSettings.php
Normal file
29
app/Tables/TableWithPaginationSettings.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tables;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Tables\Traits\WithColumnFormatter;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Mmt\GenericTable\Enums\PaginationRack;
|
||||
use Mmt\GenericTable\Interfaces\IGenericTable;
|
||||
use Mmt\GenericTable\Interfaces\IPaginationRack;
|
||||
use Mmt\GenericTable\Interfaces\IRowsPerPage;
|
||||
|
||||
class TableWithPaginationSettings implements IGenericTable, IPaginationRack, IRowsPerPage
|
||||
{
|
||||
use WithColumnFormatter;
|
||||
|
||||
public Model|string $model = Product::class;
|
||||
|
||||
public int $paginationRack = 0;
|
||||
|
||||
public int $rowsPerPage = 10;
|
||||
|
||||
public array $rowsPerPageOptions = [10,20,40,60,80];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
PaginationRack::addFlags($this->paginationRack, PaginationRack::TOP, PaginationRack::BOTTOM);
|
||||
}
|
||||
}
|
||||
29
app/Tables/TableWithRelationships.php
Normal file
29
app/Tables/TableWithRelationships.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tables;
|
||||
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Mmt\GenericTable\Components\Column;
|
||||
use Mmt\GenericTable\Components\ColumnCollection;
|
||||
use Mmt\GenericTable\Interfaces\IGenericTable;
|
||||
|
||||
class TableWithRelationships implements IGenericTable
|
||||
{
|
||||
public Model|string $model;
|
||||
|
||||
public ColumnCollection $columns;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new Product();
|
||||
|
||||
$this->columns = new ColumnCollection()->add(
|
||||
new Column('Name'),
|
||||
new Column('Department', 'subDepartment.department.name'),
|
||||
new Column('SubDepartment', 'subDepartment.name'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
15
app/Tables/TableWithnNoSettings.php
Normal file
15
app/Tables/TableWithnNoSettings.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tables;
|
||||
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Mmt\GenericTable\Components\ColumnCollection;
|
||||
use Mmt\GenericTable\Interfaces\IGenericTable;
|
||||
|
||||
class TableWithnNoSettings implements IGenericTable
|
||||
{
|
||||
public Model|string $model = Product::class;
|
||||
|
||||
public ColumnCollection $columns;
|
||||
}
|
||||
43
app/Tables/Traits/WithColumnFormatter.php
Normal file
43
app/Tables/Traits/WithColumnFormatter.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tables\Traits;
|
||||
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Mmt\GenericTable\Attributes\CellFormatter;
|
||||
use Mmt\GenericTable\Attributes\MappedColumn;
|
||||
use Mmt\GenericTable\Components\Column;
|
||||
use Mmt\GenericTable\Components\ColumnCollection;
|
||||
|
||||
trait WithColumnFormatter
|
||||
{
|
||||
public Model|string $model = Product::class;
|
||||
|
||||
public ColumnCollection $columns;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->columns = ColumnCollection::make(
|
||||
new Column('Id'),
|
||||
new Column('Name'),
|
||||
new Column('Description'),
|
||||
new Column('Price'),
|
||||
new Column('Stock'),
|
||||
new Column('SubDepartment', 'subDepartment.name'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
#[CellFormatter('price')]
|
||||
public function priceFormatter(Model $modelItem)
|
||||
{
|
||||
return "<b class = 'text-primary'>\$</b> {$modelItem->price}";
|
||||
}
|
||||
|
||||
#[CellFormatter('id')]
|
||||
public function idFormatter(Model $modelItem)
|
||||
{
|
||||
return '<b class = "text-primary">#</b> '.$modelItem->id;
|
||||
}
|
||||
}
|
||||
26
app/Tables/Traits/WithExportableProductColumns.php
Normal file
26
app/Tables/Traits/WithExportableProductColumns.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tables\Traits;
|
||||
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Mmt\GenericTable\Components\Column;
|
||||
use Mmt\GenericTable\Components\ColumnCollection;
|
||||
use Mmt\GenericTable\Enums\ColumnSettingFlags;
|
||||
|
||||
trait WithExportableProductColumns
|
||||
{
|
||||
public Model|string $model = Product::class;
|
||||
|
||||
public ColumnCollection $columns;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->columns = ColumnCollection::make(
|
||||
new Column('Name')->withSettings(ColumnSettingFlags::EXPORTABLE),
|
||||
new Column('Description')->withSettings(ColumnSettingFlags::EXPORTABLE),
|
||||
new Column('Price')->withSettings(ColumnSettingFlags::EXPORTABLE),
|
||||
new Column('Stock')->withSettings(ColumnSettingFlags::EXPORTABLE)
|
||||
);
|
||||
}
|
||||
}
|
||||
27
app/Tables/Traits/WithFilterColumns.php
Normal file
27
app/Tables/Traits/WithFilterColumns.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tables\Traits;
|
||||
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Mmt\GenericTable\Components\Column;
|
||||
use Mmt\GenericTable\Components\ColumnCollection;
|
||||
|
||||
trait WithFilterColumns
|
||||
{
|
||||
public Model|string $model = Product::class;
|
||||
|
||||
public ColumnCollection $columns;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->columns = ColumnCollection::make(
|
||||
new Column('Id'),
|
||||
new Column('Description'),
|
||||
new Column('Price'),
|
||||
new Column('Stock'),
|
||||
new Column('Department', 'subDepartment.department.name'),
|
||||
new Column('SubDepartment', 'subDepartment.name'),
|
||||
);
|
||||
}
|
||||
}
|
||||
25
app/Tables/Traits/WithRelationshipsColumns.php
Normal file
25
app/Tables/Traits/WithRelationshipsColumns.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tables\Traits;
|
||||
|
||||
use Mmt\GenericTable\Attributes\Column;
|
||||
use Mmt\GenericTable\Attributes\ColumnTitle;
|
||||
use Mmt\GenericTable\Attributes\MappedColumn;
|
||||
|
||||
trait WithRelationshipsColumns
|
||||
{
|
||||
#[ColumnTitle('Id')]
|
||||
public int $Id;
|
||||
|
||||
#[ColumnTitle('Name')]
|
||||
public string $Name;
|
||||
|
||||
#[ColumnTitle('Description')]
|
||||
public string $Description;
|
||||
|
||||
#[MappedColumn('subDepartment.department.name')]
|
||||
public string $Department;
|
||||
|
||||
#[MappedColumn('subDepartment.name')]
|
||||
public string $SubDepartment;
|
||||
}
|
||||
Reference in New Issue
Block a user