PHP code example of mokhosh / filament-kanban
1. Go to this page and download the library: Download mokhosh/filament-kanban library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mokhosh / filament-kanban example snippets
use Mokhosh\FilamentKanban\Concerns\IsKanbanStatus;
enum UserStatus: string
{
use IsKanbanStatus;
case User = 'User';
case Admin = 'Admin';
}
php artisan make:kanban UsersKanbanBoard
protected static string $model = User::class;
protected static string $statusEnum = UserStatus::class;
protected function records(): Collection
{
return User::where('role', 'admin')->get();
}
protected function statuses(): Collection
{
return [
['id' => 'user', 'title' => 'User'],
['id' => 'admin', 'title' => 'Admin'],
];
}
public function onStatusChanged(int $recordId, string $status, array $fromOrderedIds, array $toOrderedIds): void
{
User::find($recordId)->update(['status' => $status]);
User::setNewOrder($toOrderedIds);
}
public function onSortChanged(int $recordId, string $status, array $orderedIds): void
{
User::setNewOrder($orderedIds);
}
public static function kanbanCases(): array
{
return [
static::CaseOne,
static::CaseThree,
];
}
public function getTitle(): string
{
return __($this->label());
}
public bool $disableEditModal = false;
protected function getEditModalFormSchema(null|int $recordId): array
{
return [
TextInput::make('title'),
];
}
protected function editRecord($recordId, array $data, array $state): void
{
Model::find($recordId)->update([
'phone' => $data['phone']
]);
}
protected string $editModalTitle = 'Edit Record';
protected string $editModalWidth = '2xl';
protected string $editModalSaveButtonLabel = 'Save';
protected string $editModalCancelButtonLabel = 'Cancel';
protected bool $editModalSlideOver = true;
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $recordTitleAttribute = 'title';
protected static string $recordStatusAttribute = 'status';
protected static string $view = 'filament-kanban::kanban-board';
protected static string $headerView = 'filament-kanban::kanban-header';
protected static string $recordView = 'filament-kanban::kanban-record';
protected static string $statusView = 'filament-kanban::kanban-status';
protected static string $scriptsView = 'filament-kanban::kanban-scripts';
bash
php artisan filament-kanban:install
bash
php artisan vendor:publish --tag="filament-kanban-views"