-
-
Notifications
You must be signed in to change notification settings - Fork 339
Expand file tree
/
Copy pathBoard.php
More file actions
81 lines (68 loc) · 2.52 KB
/
Board.php
File metadata and controls
81 lines (68 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
namespace App\Filament\Pages;
use BackedEnum;
use App\Models\Project;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Grid;
use Filament\Forms\Components\Select;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Pages\Page;
use Illuminate\Contracts\Support\Htmlable;
class Board extends Page implements HasForms
{
use InteractsWithForms;
protected static string | BackedEnum | null $navigationIcon = 'heroicon-o-view-columns';
protected string $view = 'filament.pages.board';
protected static ?string $slug = 'board';
protected static ?int $navigationSort = 4;
public function getSubheading(): string|Htmlable|null
{
return __("In this section you can choose one of your projects to show it's Scrum or Kanban board");
}
public function mount(): void
{
$this->form->fill();
}
public static function getNavigationLabel(): string
{
return __('Board');
}
public static function getNavigationGroup(): ?string
{
return __('Management');
}
public function getFormSchema(): array
{
return [
Section::make()
->schema([
Grid::make()
->columns(1)
->schema([
Select::make('project')
->label(__('Project'))
->required()
->searchable()
->live()
->afterStateUpdated(fn () => $this->search())
->helperText(__("Choose a project to show it's board"))
->options(fn() => Project::where('owner_id', auth()->user()->id)
->orWhereHas('users', function ($query) {
return $query->where('users.id', auth()->user()->id);
})->pluck('name', 'id')->toArray()),
]),
]),
];
}
public function search(): void
{
$data = $this->form->getState();
$project = Project::find($data['project']);
if ($project->type === "scrum") {
$this->redirect(route('filament.admin.pages.scrum.{project}', ['project' => $project]));
} else {
$this->redirect(route('filament.admin.pages.kanban.{project}', ['project' => $project]));
}
}
}