buzkall
buzkall
FFilament
Created by buzkall on 10/22/2023 in #❓┊help
Wrong indicator in SelectFilter with multiple and translatable
The snippet you gave me is for the option labels I'm talking here to the indicators in the table, which can be solved using something like this in each filter (which doesn't need to be done if the filter is not multiple)
->indicateUsing(fn(array $data): ?string => $data ?
__('Gender') . ': ' . Gender::whereIn('id', $data['values'])->pluck('name')->join(', ') :
null),
->indicateUsing(fn(array $data): ?string => $data ?
__('Gender') . ': ' . Gender::whereIn('id', $data['values'])->pluck('name')->join(', ') :
null),
6 replies
FFilament
Created by buzkall on 10/22/2023 in #❓┊help
Wrong indicator in SelectFilter with multiple and translatable
no, I've opened and issue in github
6 replies
FFilament
Created by buzkall on 8/23/2023 in #❓┊help
How to trigger loading in Field Macro when one of the fields is reactive
This is the modal
Field::macro('withImageCaption', fn($collection) => $this->hintAction(
fn(Closure $set, $record) => Action::make('Custom_properties')
->icon('heroicon-o-camera')
->tooltip(__('Add a caption to the images'))
->label(__('Image captions'))
->form([
Select::make('media_id')
->label(__('Image name'))
->options($this->getRecord()->getMedia($collection)->pluck('file_name', 'id')->toArray())
->required()
->reactive()
->afterStateUpdated(function($state, $record, Closure $set) {
$description_es = $record->media->find($state)?->getCustomProperty('description')['es'] ?? '';
$description_en = $record->media->find($state)?->getCustomProperty('description')['en'] ?? '';

$set('description_es', $description_es);
$set('description_en', $description_en);
}),

Section::make('description')
->heading(__('Image caption'))
->compact()
->schema(
[
TextInput::make('description_es')
->label(__('Spanish')),
TextInput::make('description_en')
->label(__('English')),
]
)->hidden(fn(callable $get) => ! $get('media_id')),

])
->modalButton(__('Save'))
->action(function($data) use ($record) {
$record->media->find($data['media_id'])->setCustomProperty('description', [
'es' => $data['description_es'],
'en' => $data['description_en'],
]);
$record->push();
})
));
Field::macro('withImageCaption', fn($collection) => $this->hintAction(
fn(Closure $set, $record) => Action::make('Custom_properties')
->icon('heroicon-o-camera')
->tooltip(__('Add a caption to the images'))
->label(__('Image captions'))
->form([
Select::make('media_id')
->label(__('Image name'))
->options($this->getRecord()->getMedia($collection)->pluck('file_name', 'id')->toArray())
->required()
->reactive()
->afterStateUpdated(function($state, $record, Closure $set) {
$description_es = $record->media->find($state)?->getCustomProperty('description')['es'] ?? '';
$description_en = $record->media->find($state)?->getCustomProperty('description')['en'] ?? '';

$set('description_es', $description_es);
$set('description_en', $description_en);
}),

Section::make('description')
->heading(__('Image caption'))
->compact()
->schema(
[
TextInput::make('description_es')
->label(__('Spanish')),
TextInput::make('description_en')
->label(__('English')),
]
)->hidden(fn(callable $get) => ! $get('media_id')),

])
->modalButton(__('Save'))
->action(function($data) use ($record) {
$record->media->find($data['media_id'])->setCustomProperty('description', [
'es' => $data['description_es'],
'en' => $data['description_en'],
]);
$record->push();
})
));
3 replies
FFilament
Created by buzkall on 8/17/2023 in #❓┊help
activeLocale error in ListResource using Filament Spatie Translatable
Me neither, it was driving me crazy!
40 replies
FFilament
Created by buzkall on 8/17/2023 in #❓┊help
activeLocale error in ListResource using Filament Spatie Translatable
yes, I can use $this->activeLocale there and the filter totally works now!
40 replies
FFilament
Created by buzkall on 8/17/2023 in #❓┊help
activeLocale error in ListResource using Filament Spatie Translatable
OMG, you're a genius
40 replies
FFilament
Created by buzkall on 8/17/2023 in #❓┊help
activeLocale error in ListResource using Filament Spatie Translatable
ok, but I'll have the same problem there, isn't it?
40 replies
FFilament
Created by buzkall on 8/17/2023 in #❓┊help
activeLocale error in ListResource using Filament Spatie Translatable
Yes, but I don't see the point in overriding the table query for a filter
40 replies
FFilament
Created by buzkall on 8/17/2023 in #❓┊help
activeLocale error in ListResource using Filament Spatie Translatable
I'm trying to add a filter to the list
40 replies
FFilament
Created by buzkall on 8/17/2023 in #❓┊help
activeLocale error in ListResource using Filament Spatie Translatable
yes
40 replies
FFilament
Created by buzkall on 8/17/2023 in #❓┊help
activeLocale error in ListResource using Filament Spatie Translatable
and apparently I can't resolve $livewire in the true and false parameters
40 replies
FFilament
Created by buzkall on 8/17/2023 in #❓┊help
activeLocale error in ListResource using Filament Spatie Translatable
that doesn't work
40 replies
FFilament
Created by buzkall on 8/17/2023 in #❓┊help
activeLocale error in ListResource using Filament Spatie Translatable
Tables\Filters\TernaryFilter::make('published')
->queries(
true: fn($query) => $query->where('published->' . $this->activeLocale, '1'),
false: fn($query) => $query->where('published->'.$this->activeLocale, '0')
)
Tables\Filters\TernaryFilter::make('published')
->queries(
true: fn($query) => $query->where('published->' . $this->activeLocale, '1'),
false: fn($query) => $query->where('published->'.$this->activeLocale, '0')
)
40 replies
FFilament
Created by buzkall on 8/17/2023 in #❓┊help
activeLocale error in ListResource using Filament Spatie Translatable
yes, but if I'm inside the filter query can't use $this
40 replies
FFilament
Created by buzkall on 8/17/2023 in #❓┊help
activeLocale error in ListResource using Filament Spatie Translatable
Do you know how I can get the active locale, to use it for example in a filter? i'm trying to filter by a json translatable field and want to modify tthe TernaryFilter queries, but I'm not getting the active locale 😦
40 replies
FFilament
Created by buzkall on 8/17/2023 in #❓┊help
activeLocale error in ListResource using Filament Spatie Translatable
I was going crazy and I had just forget about the trait...
40 replies
FFilament
Created by buzkall on 8/17/2023 in #❓┊help
activeLocale error in ListResource using Filament Spatie Translatable
maybe I'm stupid 😱
40 replies
FFilament
Created by uicabpatweyler on 5/27/2023 in #❓┊help
SQLSTATE[HY000]: General error: 1364 Field 'locked' doesn't have a default value
In case someone else has this problem, here is the Spatie's upgrade guide to settings v3. -> https://github.com/spatie/laravel-settings/blob/main/UPGRADING.md The main part to avoid the duplication of settings is the unique key in the migration!
7 replies
FFilament
Created by Hurruwa on 5/17/2023 in #❓┊help
Browser notification using FilamentNotifications?
I'm using Pusher and Laravel echo and if I add this code to a new route (outside Filament) this works and I see a browser notification
window.Echo.private('App.Models.FilamentUser.1')
.listen('.database-notifications.sent', (event) => {
console.log(event);

if (! ('Notification' in window)) {
alert('Web Notification is not supported');
return;
}

Notification.requestPermission( permission => {
let notification = new Notification('New message from ' + event.user.email);
});
});
window.Echo.private('App.Models.FilamentUser.1')
.listen('.database-notifications.sent', (event) => {
console.log(event);

if (! ('Notification' in window)) {
alert('Web Notification is not supported');
return;
}

Notification.requestPermission( permission => {
let notification = new Notification('New message from ' + event.user.email);
});
});
But if I I register a new script with Filament::registerScripts in my AppServiceProvider and try run the same code, the console.log works, but I get an error in the Notification.requestPermission line saying that requestPermission is not a function I don't understand why 😦
10 replies
FFilament
Created by Hurruwa on 5/17/2023 in #❓┊help
Browser notification using FilamentNotifications?
were you able to figure out this?
10 replies