Uploading content
This commit is contained in:
8
app/Http/Controllers/Controller.php
Normal file
8
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
215
app/Livewire/Examples/BasicTableComponent.php
Normal file
215
app/Livewire/Examples/BasicTableComponent.php
Normal 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());
|
||||
// }
|
||||
}
|
||||
18
app/Livewire/Examples/FrameComponent.php
Normal file
18
app/Livewire/Examples/FrameComponent.php
Normal 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');
|
||||
}
|
||||
}
|
||||
18
app/Livewire/Examples/MyCustomSettingsTableComponent.php
Normal file
18
app/Livewire/Examples/MyCustomSettingsTableComponent.php
Normal 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');
|
||||
}
|
||||
}
|
||||
26
app/Livewire/Examples/TableWithActionColumnComponent.php
Normal file
26
app/Livewire/Examples/TableWithActionColumnComponent.php
Normal 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);
|
||||
}
|
||||
}
|
||||
18
app/Livewire/Examples/TableWithBindedRoutesComponent.php
Normal file
18
app/Livewire/Examples/TableWithBindedRoutesComponent.php
Normal 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');
|
||||
}
|
||||
}
|
||||
18
app/Livewire/Examples/TableWithBulkActionsComponent.php
Normal file
18
app/Livewire/Examples/TableWithBulkActionsComponent.php
Normal 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');
|
||||
}
|
||||
}
|
||||
18
app/Livewire/Examples/TableWithColumnFormatterComponent.php
Normal file
18
app/Livewire/Examples/TableWithColumnFormatterComponent.php
Normal 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');
|
||||
}
|
||||
}
|
||||
18
app/Livewire/Examples/TableWithDragDropOrderingComponent.php
Normal file
18
app/Livewire/Examples/TableWithDragDropOrderingComponent.php
Normal 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');
|
||||
}
|
||||
}
|
||||
16
app/Livewire/Examples/TableWithExportComponent.php
Normal file
16
app/Livewire/Examples/TableWithExportComponent.php
Normal 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');
|
||||
}
|
||||
}
|
||||
30
app/Livewire/Examples/TableWithFiltersComponent.php
Normal file
30
app/Livewire/Examples/TableWithFiltersComponent.php
Normal 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]);
|
||||
}
|
||||
}
|
||||
16
app/Livewire/Examples/TableWithNoSettingsComponent.php
Normal file
16
app/Livewire/Examples/TableWithNoSettingsComponent.php
Normal 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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
27
app/Livewire/Examples/TableWithRelationshipsComponent.php
Normal file
27
app/Livewire/Examples/TableWithRelationshipsComponent.php
Normal 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);
|
||||
}
|
||||
}
|
||||
28
app/Livewire/Test/ChildComponent.php
Normal file
28
app/Livewire/Test/ChildComponent.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Test;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class ChildComponent extends Component
|
||||
{
|
||||
|
||||
public $id = 0;
|
||||
|
||||
public function mount($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.test.child-component');
|
||||
}
|
||||
|
||||
|
||||
public function doSome()
|
||||
{
|
||||
$this->dispatch('did');
|
||||
}
|
||||
}
|
||||
21
app/Livewire/Test/ParentComponent.php
Normal file
21
app/Livewire/Test/ParentComponent.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Test;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class ParentComponent extends Component
|
||||
{
|
||||
public int $count = 0;
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.test.parent-component')
|
||||
->extends('components.layouts.app')
|
||||
->section('content');
|
||||
}
|
||||
|
||||
public function counting()
|
||||
{
|
||||
$this->count++;
|
||||
}
|
||||
}
|
||||
10
app/Models/Department.php
Normal file
10
app/Models/Department.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Department extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
22
app/Models/Product.php
Normal file
22
app/Models/Product.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Product extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'description', 'price', 'stock', 'category', 'brand',
|
||||
'sku', 'weight', 'status', 'order'
|
||||
];
|
||||
|
||||
public function subDepartment() : BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SubDepartment::class);
|
||||
}
|
||||
}
|
||||
14
app/Models/SubDepartment.php
Normal file
14
app/Models/SubDepartment.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class SubDepartment extends Model
|
||||
{
|
||||
public function department() : BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
}
|
||||
48
app/Models/User.php
Normal file
48
app/Models/User.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
}
|
||||
24
app/Providers/AppServiceProvider.php
Normal file
24
app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
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