AlexAnder
AlexAnder
FFilament
Created by AlexAnder on 11/11/2024 in #❓┊help
console error ':popover-open' is not a valid selector
Is it filaments error or livewire? In console shows error: "uncaught (in promise) DOMException: Element.querySelectorAll: ':popover-open' is not a valid selector" and nothings shows on screen. If I hit refresh, then loads panel, or open in new tab, alsou shows, but clicking on links get error. Can it be, because my Firefox version is 115.4.0esr?
4 replies
FFilament
Created by AlexAnder on 10/10/2024 in #❓┊help
Import CSV multiple columns in one relationship
Is it possible to import CSV with multiple columns in one relationship column (determine if there is such a person - by two columns: name and birth_date). CSV has seperate columns - name and birth_date
1 replies
FFilament
Created by AlexAnder on 9/26/2024 in #❓┊help
Filament Exporter dinamicly add columns to excel from relationship?
Hi! Maybe someone can help? How to pass
Model $record
Model $record
to
public static function getColumns(): array
{
//
public static function getColumns(): array
{
//
for dinamicly add columns to excel from relationship?
2 replies
FFilament
Created by AlexAnder on 7/31/2024 in #❓┊help
ListRecords page display records from three diferent tables (based on firlter values)
Hi. I have a question. Is it possible in one resource/ListRecords page display records from three diferent tables, like merged in one collection (based on firlter values)? Maybe someone have a example?
4 replies
FFilament
Created by AlexAnder on 6/14/2024 in #❓┊help
How to "disable globalScope" in "Listing records" when "Using tabs to filter the records"
use Filament\Resources\Components\Tab;
use Illuminate\Database\Eloquent\Builder;

public function getTabs(): array
{
return [
'all' => Tab::make(),
'childrens' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query->whereHas('childrens'))
->withoutGlobalScopes(), // the global scope is belongsTo(auth()->user())
];
}
use Filament\Resources\Components\Tab;
use Illuminate\Database\Eloquent\Builder;

public function getTabs(): array
{
return [
'all' => Tab::make(),
'childrens' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query->whereHas('childrens'))
->withoutGlobalScopes(), // the global scope is belongsTo(auth()->user())
];
}
"->withoutGlobalScopes()" doesn't work.
4 replies
FFilament
Created by AlexAnder on 5/27/2024 in #❓┊help
Why View Page needs viewAny policy role to be true for viewing?
Why View Page needs viewAny policy role to be true for viewing? Is it possible to override?
6 replies
FFilament
Created by AlexAnder on 4/18/2024 in #❓┊help
Custom page layout divide in 3 columns
I created custom page and want to split page content into 3 columns? I try all of tailwinds flex/grids, etc.., nothing works. Is there is some way to implement this?
17 replies
FFilament
Created by AlexAnder on 3/18/2024 in #❓┊help
Select or Create in attach modal freezes (no scroll)
When in RealitionManager choose attach and in select there is no wanted record, choose create witch opens new modal for create. Then It's creates, closes create modal, selects active record in select and you can attach. After modal closes, screen lost it's scroll. All actions works, but scroll returns after refresh the page.
4 replies
FFilament
Created by AlexAnder on 3/18/2024 in #❓┊help
Table Filters DatePicker native(false) error
When using DatePicker in Table Filters with native(false), in console returns error:
Alpine Expression Error: displayText is not defined
Expression: "displayText"
<input id="tableFilters.date.date_from" class="w-full border-none bg-tr…sm:text-sm sm:leading-6" readonly="" placeholder="" wire:key="uzFSJtiB92fiifV63GQ0.tab…DatePicker.display-text" x-model="displayText">
Alpine Expression Error: displayText is not defined
Expression: "displayText"
<input id="tableFilters.date.date_from" class="w-full border-none bg-tr…sm:text-sm sm:leading-6" readonly="" placeholder="" wire:key="uzFSJtiB92fiifV63GQ0.tab…DatePicker.display-text" x-model="displayText">
The code:
Filter::make('date')
->form([
DatePicker::make('date_from')
->label('Datums no')
->native(false)
->displayFormat('d.m.Y')
->closeOnDateSelection(true),
DatePicker::make('date_to')
->label('Datums līdz')
->native(false)
->displayFormat('d.m.Y')
->closeOnDateSelection(true),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['date_from'],
fn (Builder $query, $date): Builder => $query->whereDate('date', '>=', $date),
)
->when(
$data['date_to'],
fn (Builder $query, $date): Builder => $query->whereDate('date', '<=', $date),
);
})
->indicateUsing(function (array $data): array {
$indicators = [];
if ($data['date_from'] ?? null) {
$indicators['date_from'] = 'Datums no: '.Carbon::parse($data['date_from'])->format('d.m.Y');
}
if ($data['date_to'] ?? null) {
$indicators['date_to'] = 'Datums līdz: '.Carbon::parse($data['date_to'])->format('d.m.Y');
}

return $indicators;
}),
Filter::make('date')
->form([
DatePicker::make('date_from')
->label('Datums no')
->native(false)
->displayFormat('d.m.Y')
->closeOnDateSelection(true),
DatePicker::make('date_to')
->label('Datums līdz')
->native(false)
->displayFormat('d.m.Y')
->closeOnDateSelection(true),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['date_from'],
fn (Builder $query, $date): Builder => $query->whereDate('date', '>=', $date),
)
->when(
$data['date_to'],
fn (Builder $query, $date): Builder => $query->whereDate('date', '<=', $date),
);
})
->indicateUsing(function (array $data): array {
$indicators = [];
if ($data['date_from'] ?? null) {
$indicators['date_from'] = 'Datums no: '.Carbon::parse($data['date_from'])->format('d.m.Y');
}
if ($data['date_to'] ?? null) {
$indicators['date_to'] = 'Datums līdz: '.Carbon::parse($data['date_to'])->format('d.m.Y');
}

return $indicators;
}),
4 replies
FFilament
Created by AlexAnder on 2/1/2024 in #❓┊help
Long $recordTitleAttribute in breadcrumbs
I need to globaly search by $recordTitleAttribute, but on edit page in breadcrumbs this value is very long. How to make it shorter..
2 replies
FFilament
Created by AlexAnder on 1/19/2024 in #❓┊help
RelationManager table custom query by role Policy
It's possible to rewrite RelationManager table query to show only records, witch has allowed by role?
2 replies
FFilament
Created by AlexAnder on 12/7/2023 in #❓┊help
Forms\Components\Select with relationship loads all records from DB
My code
...
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('author_id')
->relationship('author', 'name')
...
...
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('author_id')
->relationship('author', 'name')
...
Post.php - Model
...

public function author(): BelongsTo
{
return $this
->belongsTo(User::class, 'author_id');
}

...
...

public function author(): BelongsTo
{
return $this
->belongsTo(User::class, 'author_id');
}

...
From DB selects all users. Its all table records.. (not enogth RAM) Also from people table is the same.. DB
SELECT "users"."name", "users"."id" FROM "users" ORDER BY "users"."name" ASC
SELECT "users"."name", "users"."id" FROM "users" ORDER BY "users"."name" ASC
And PHP crashed because off memory exhausted..
2 replies
FFilament
Created by AlexAnder on 11/10/2023 in #❓┊help
Keybindings works only once
If I edit resource directly, then "ctrl+s" works one time(first time) if in resource I have repeater with relationship and I choose the record, then "ctrl+s" doesn't works anymore.
2 replies
FFilament
Created by AlexAnder on 10/5/2023 in #❓┊help
Custom AttachAction
Can someone can help? I have peoples connected thru polymorphic relation MorphToMany. When I attach person to person, in db I get
[
'person_id' => 1,
'personable_id' => 2,
'personable_type' => 'App\Models\Person',
];
[
'person_id' => 1,
'personable_id' => 2,
'personable_type' => 'App\Models\Person',
];
The questions is: Ho to customize AttachAction to get records in db in both directions, so on both persons I get relation with each other?
7 replies
FFilament
Created by AlexAnder on 9/19/2023 in #❓┊help
Auto scrolling for navigation selected menu
On v2, there was renderHook for Auto scrolling for navigation selected menu. If there is the same for v3
12 replies
FFilament
Created by AlexAnder on 9/10/2023 in #❓┊help
FileUpload with ImageEditor on save prevent redirect
How to prevent redirect on save, if on resource there is FileUpload with ImageEditor and also
protected function getRedirectUrl(): string
{
return $this->previousUrl ?? $this->getResource()::getUrl('index');
}
protected function getRedirectUrl(): string
{
return $this->previousUrl ?? $this->getResource()::getUrl('index');
}
2 replies
FFilament
Created by AlexAnder on 8/31/2023 in #❓┊help
old web page tricks..
Hi, where is the old filament page tricks page? There was post about edit related model (from relationmanager) in edit page, instead of modal
6 replies
FFilament
Created by AlexAnder on 8/17/2023 in #❓┊help
Is it possible to realize something like this.
I have models with relationships and want to edit actual values, but input fields are not linked to model values. In SurveyResource edit:
Forms\Components\Section::make()
->schema(function ($record) {
$data = [];
foreach ($record->categories as $category) {
foreach ($category->answers as $answer) {
$data[] = Forms\Components\Group::make()
->schema([
Forms\Components\TextInput::make('answer'),
]);
}
}
return $data;
})
Forms\Components\Section::make()
->schema(function ($record) {
$data = [];
foreach ($record->categories as $category) {
foreach ($category->answers as $answer) {
$data[] = Forms\Components\Group::make()
->schema([
Forms\Components\TextInput::make('answer'),
]);
}
}
return $data;
})
I would appreciate the advice.
2 replies
FFilament
Created by AlexAnder on 8/2/2023 in #❓┊help
Rewrite Global search
Maybe someone will need a solution for rewrite global search. It's searches by different column (in my case PostgreSql full text search column - tsvector data type) I did it like this. Enable global search
protected static ?string $recordTitleAttribute = 'topic';
protected static ?string $recordTitleAttribute = 'topic';
Rewrite global search results (getGlobalSearchResults)
public static function getGlobalSearchResults(string $searchQuery): Collection
{
$customSearchQuery = Str::replace(' ', ':* & ', trim($searchQuery));

return RfiIncome::query()
->whereRaw("rfi_incomes_fts @@ to_tsquery('english', ?)", [$customSearchQuery.':*'])
->limit(static::getGlobalSearchResultsLimit())
->get()
->map(function (Model $record): ?GlobalSearchResult {
$url = static::getGlobalSearchResultUrl($record);

if (blank($url)) {
return null;
}

return new GlobalSearchResult(
title: static::getGlobalSearchResultTitle($record),
url: $url,
details: static::getGlobalSearchResultDetails($record),
actions: static::getGlobalSearchResultActions($record),
);
})
->filter();

}
public static function getGlobalSearchResults(string $searchQuery): Collection
{
$customSearchQuery = Str::replace(' ', ':* & ', trim($searchQuery));

return RfiIncome::query()
->whereRaw("rfi_incomes_fts @@ to_tsquery('english', ?)", [$customSearchQuery.':*'])
->limit(static::getGlobalSearchResultsLimit())
->get()
->map(function (Model $record): ?GlobalSearchResult {
$url = static::getGlobalSearchResultUrl($record);

if (blank($url)) {
return null;
}

return new GlobalSearchResult(
title: static::getGlobalSearchResultTitle($record),
url: $url,
details: static::getGlobalSearchResultDetails($record),
actions: static::getGlobalSearchResultActions($record),
);
})
->filter();

}
Maybe someone can give better solution..
1 replies
FFilament
Created by AlexAnder on 7/31/2023 in #❓┊help
max_content_width
Where to add max_content_width in v3
4 replies