mamamia
mamamia
FFilament
Created by mamamia on 1/25/2024 in #❓┊help
How to add permission check in pages?
so usually i use resource and policies, but now im working on pages, how do i add permission check? i tried this but it still openable through the url
protected static function shouldRegisterNavigation(): bool {
return auth()->user()->can("View report");
}
protected static function shouldRegisterNavigation(): bool {
return auth()->user()->can("View report");
}
2 replies
FFilament
Created by mamamia on 1/24/2024 in #❓┊help
How to use array in getTableQuery instead of Builder?
So i have an array somewhere, i want the table data is using the array instead of querying, how do i do that?
protected function getTableQuery(): Builder
{
// return Post::query();
return [["name"=>"t1"]["name"=>"t2"]] // something like this?
}
protected function getTableQuery(): Builder
{
// return Post::query();
return [["name"=>"t1"]["name"=>"t2"]] // something like this?
}
4 replies
FFilament
Created by mamamia on 1/22/2024 in #❓┊help
How to mimic create action?
So i have 2 button, the default create form action and save as draft, i want save as draft is 99% same with the normal one, the only difference is the status how do i do that? i've tried this but i have to manually give validation how do i mimic the original one?
protected function getFormActions(): array
{
return array_merge(
[
Action::make('Save as draft')
->action('saveAsDraft')
],
parent::getFormActions()
);
}

public function saveAsDraft($data) {
$data = $this->form->getRawState();
$data["status_project"] = ProjectStatus::DRAFT;
static::getModel()::create($data);
}
protected function getFormActions(): array
{
return array_merge(
[
Action::make('Save as draft')
->action('saveAsDraft')
],
parent::getFormActions()
);
}

public function saveAsDraft($data) {
$data = $this->form->getRawState();
$data["status_project"] = ProjectStatus::DRAFT;
static::getModel()::create($data);
}
13 replies
FFilament
Created by mamamia on 1/22/2024 in #❓┊help
Visible On Edit
how do i make input visible only on edit with the $record->status = true?
Forms\Components\Select::make('project_manager_id')
->label(__('Project Manager'))
->visibleOn('edit')
->searchable()
->options(fn() => User::all()->pluck('name', 'id')->toArray())
->default(fn() => auth()->user()->id)
->required(),
Forms\Components\Select::make('project_manager_id')
->label(__('Project Manager'))
->visibleOn('edit')
->searchable()
->options(fn() => User::all()->pluck('name', 'id')->toArray())
->default(fn() => auth()->user()->id)
->required(),
8 replies
FFilament
Created by mamamia on 1/18/2024 in #❓┊help
How to get form value?
No description
3 replies