undercode
undercode
FFilament
Created by Moe Tarhini on 11/4/2024 in #❓┊help
Save Table column order
3 replies
FFilament
Created by Jefry on 8/7/2024 in #❓┊help
How to validate two fields combined are unique
7 replies
FFilament
Created by _𝕰𝖋x on 8/7/2024 in #❓┊help
Customizing update process globally
5 replies
FFilament
Created by Matthew on 8/7/2024 in #❓┊help
How can I get started with a JS field?
22 replies
FFilament
Created by SuperUserDo on 8/5/2024 in #❓┊help
Missing Bulk Actions
Have you installed Shield plugin? If so, check your permissions and execute: php artisan shield:generate --all
4 replies
FFilament
Created by Soundmit on 6/24/2024 in #❓┊help
getHEaderWidgetColumns not works in resource view
You can use protected function getColumns(): int, but it only allows you 4 columns max. If you need more columns you can create your own view based on stats-overview-widget.blade.php and modify it to add more column options. Mine is:
@php
$columns = $this->getColumns();
@endphp

<x-filament-widgets::widget class="fi-wi-stats-overview">
<div
@if ($pollingInterval = $this->getPollingInterval())
wire:poll.{{ $pollingInterval }}
@endif
@class([
'fi-wi-stats-overview-stats-ctn grid gap-6',
'md:grid-cols-1' => $columns === 1,
'md:grid-cols-2' => $columns === 2,
'md:grid-cols-3' => $columns === 3,
'md:grid-cols-2 xl:grid-cols-4' => $columns === 4,
'md:grid-cols-3 xl:grid-cols-5' => $columns === 5,
'md:grid-cols-3 xl:grid-cols-6' => $columns === 6,
])
>
@foreach ($this->getCachedStats() as $stat)
{{ $stat }}
@endforeach
</div>
</x-filament-widgets::widget>
@php
$columns = $this->getColumns();
@endphp

<x-filament-widgets::widget class="fi-wi-stats-overview">
<div
@if ($pollingInterval = $this->getPollingInterval())
wire:poll.{{ $pollingInterval }}
@endif
@class([
'fi-wi-stats-overview-stats-ctn grid gap-6',
'md:grid-cols-1' => $columns === 1,
'md:grid-cols-2' => $columns === 2,
'md:grid-cols-3' => $columns === 3,
'md:grid-cols-2 xl:grid-cols-4' => $columns === 4,
'md:grid-cols-3 xl:grid-cols-5' => $columns === 5,
'md:grid-cols-3 xl:grid-cols-6' => $columns === 6,
])
>
@foreach ($this->getCachedStats() as $stat)
{{ $stat }}
@endforeach
</div>
</x-filament-widgets::widget>
4 replies
FFilament
Created by Jordy on 6/12/2024 in #❓┊help
Issue with Summary Range formatting
No description
25 replies
FFilament
Created by Jordy on 6/12/2024 in #❓┊help
Issue with Summary Range formatting
Sorry, I made a mistake
25 replies
FFilament
Created by Jordy on 6/12/2024 in #❓┊help
Issue with Summary Range formatting
return sprintf("%.2f", $state[0] / 100) . ' - ' . sprintf("%.2f", $state[1] / 100);
return sprintf("%.2f", $state[0] / 100) . ' - ' . sprintf("%.2f", $state[1] / 100);
25 replies
FFilament
Created by ahinkle on 4/22/2024 in #❓┊help
Debugging Import: Multiple types of exceptions occurred
Hi! In my case, I had to modify handleException function in \Filament\Actions\Imports\Jobs\ImportCsv.php with this:
protected function handleExceptions(array $exceptions): void
{
if (empty($exceptions)) {
return;
}

if (count($exceptions) > 1) {
$exception_description = '';
foreach ($exceptions as $exception) {
$exception_description = '[' . $exception::class . ": \n\t" . $exception->getMessage() . "]\n\n";
}
throw new Exception('Multiple types of exceptions occurred: ' . $exception_description);
//throw new Exception('Multiple types of exceptions occurred: [' . implode('], [', array_keys($exceptions)) . ']');
}

throw Arr::first($exceptions);
}
protected function handleExceptions(array $exceptions): void
{
if (empty($exceptions)) {
return;
}

if (count($exceptions) > 1) {
$exception_description = '';
foreach ($exceptions as $exception) {
$exception_description = '[' . $exception::class . ": \n\t" . $exception->getMessage() . "]\n\n";
}
throw new Exception('Multiple types of exceptions occurred: ' . $exception_description);
//throw new Exception('Multiple types of exceptions occurred: [' . implode('], [', array_keys($exceptions)) . ']');
}

throw Arr::first($exceptions);
}
2 replies
FFilament
Created by bernhard on 9/21/2023 in #❓┊help
Two panels with two auth guards, logges me out from both
Thank you, @Sourabh Unfortunately your approach didn't work for me. Instead, I had to remove your composer.json modifications and add an alias to the default LoginController in my AppServiceProvider, as follows:
use Filament\Http\Controllers\Auth\LogoutController;
use App\Overrides\LogoutController as NewLogoutController;

public function register(): void
{
$loader = AliasLoader::getInstance();
$loader->alias(LogoutController::class, NewLogoutController::class);
}
use Filament\Http\Controllers\Auth\LogoutController;
use App\Overrides\LogoutController as NewLogoutController;

public function register(): void
{
$loader = AliasLoader::getInstance();
$loader->alias(LogoutController::class, NewLogoutController::class);
}
And I made some modifications to your LogoutController to keep it simpler and without the need to know the name of the panels and their guards:
<?php

namespace App\Overrides;

use Filament\Facades\Filament;
use Filament\Http\Responses\Auth\Contracts\LogoutResponse;
use Illuminate\Http\Request;

class LogoutController
{
public function __invoke(Request $request): LogoutResponse
{
$panel = Filament::getCurrentPanel();
Filament::auth()->logout();
$request->session()->forget($panel->getAuthGuard());
$request->session()->regenerateToken();

return app(LogoutResponse::class);
}
}
<?php

namespace App\Overrides;

use Filament\Facades\Filament;
use Filament\Http\Responses\Auth\Contracts\LogoutResponse;
use Illuminate\Http\Request;

class LogoutController
{
public function __invoke(Request $request): LogoutResponse
{
$panel = Filament::getCurrentPanel();
Filament::auth()->logout();
$request->session()->forget($panel->getAuthGuard());
$request->session()->regenerateToken();

return app(LogoutResponse::class);
}
}
12 replies
FFilament
Created by Quin. on 11/21/2023 in #❓┊help
Upgraded to v3 icon-button error
Thank you!
6 replies
FFilament
Created by Quin. on 11/21/2023 in #❓┊help
Upgraded to v3 icon-button error
Can I ask you how you fixed it? I have a similar issue.
6 replies
FFilament
Created by Matthew on 11/20/2023 in #❓┊help
CSS errors on upgrade V2 -> V3
In your 'filament.css' change @import '../../vendor/filament/filament/resources/css/app.css'; with @import '../../vendor/filament/filament/resources/css/theme.css';
4 replies
FFilament
Created by undercode on 9/19/2023 in #❓┊help
Prevent image saving with FileUpload (v2)
I've solved using saveUploadedFilesUsing() . Example:
->saveUploadedFileUsing(function (TemporaryUploadedFile $file, $component) {
$originalName = Str::upper(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME));
$applicant = Applicant::whereRaw('UPPER(dni) = ?', [$originalName])->first();

if (empty($applicant)) {
try {
$file->delete();
} catch (Exception $e) {
return null;
}

return null;
} else {
if ($component->shouldMoveFile() && $component->getDiskName() == $file->disk) {
$newPath = trim($component->getDirectory() . '/' . $component->getUploadedFileNameForStorage($file), '/');
$component->getDisk()->move($file->path(), $newPath);

return $newPath;
}

$storeMethod = $component->getVisibility() === 'public' ? 'storePubliclyAs' : 'storeAs';
return $file->{$storeMethod}(
$component->getDirectory(),
$component->getUploadedFileNameForStorage($file),
$component->getDiskName(),
);
}
})
->saveUploadedFileUsing(function (TemporaryUploadedFile $file, $component) {
$originalName = Str::upper(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME));
$applicant = Applicant::whereRaw('UPPER(dni) = ?', [$originalName])->first();

if (empty($applicant)) {
try {
$file->delete();
} catch (Exception $e) {
return null;
}

return null;
} else {
if ($component->shouldMoveFile() && $component->getDiskName() == $file->disk) {
$newPath = trim($component->getDirectory() . '/' . $component->getUploadedFileNameForStorage($file), '/');
$component->getDisk()->move($file->path(), $newPath);

return $newPath;
}

$storeMethod = $component->getVisibility() === 'public' ? 'storePubliclyAs' : 'storeAs';
return $file->{$storeMethod}(
$component->getDirectory(),
$component->getUploadedFileNameForStorage($file),
$component->getDiskName(),
);
}
})
The code inside else block has been taken from BaseFileUpload class.
4 replies
FFilament
Created by DS on 7/28/2023 in #❓┊help
problems in v3 custom panel auth
public function panel(Panel $panel): Panel
{
return $panel
...
->login()
...
}
public function panel(Panel $panel): Panel
{
return $panel
...
->login()
...
}
15 replies
FFilament
Created by H.Bilbao on 5/21/2023 in #❓┊help
Mark as read once notification is opened
I solved it by updating 'read_at' field when the user enters in my ViewPage or EditPage.
public function mount($record): void
{
parent::mount($record);

$user = auth()->user();
$notification = DB::table('notifications')
->where('notifiable_type', get_class($user))
->where('notifiable_id', $user->id)
->where('data->actions[0]->url', 'like', '%issues/' . $this->record->id)
->whereNull('read_at');
$notification->update(['read_at' => now()]);
}
public function mount($record): void
{
parent::mount($record);

$user = auth()->user();
$notification = DB::table('notifications')
->where('notifiable_type', get_class($user))
->where('notifiable_id', $user->id)
->where('data->actions[0]->url', 'like', '%issues/' . $this->record->id)
->whereNull('read_at');
$notification->update(['read_at' => now()]);
}
You have to change '%issues/' with '%tickets/' or whatever your resource path is.
5 replies
FFilament
Created by undercode on 4/11/2023 in #❓┊help
DatePicker "hintAction" error: Xdebug has detected a possible infinite loop
Problem solved adding the next line to my php.ini
[xdebug]
xdebug.max_nesting_level=512
[xdebug]
xdebug.max_nesting_level=512
2 replies
FFilament
Created by Falk Maria Zeitsprung on 3/9/2023 in #❓┊help
how to make uploaded image only visible inside the filament admin panel
I think you have to use a temporary url to access files from not public disk.
Forms\Components\FileUpload::make('path')
->disk('private')
->directory('attachments')
->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file): string {
return (string) str($file->hashName());
})
->enableOpen()
])
Forms\Components\FileUpload::make('path')
->disk('private')
->directory('attachments')
->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file): string {
return (string) str($file->hashName());
})
->enableOpen()
])
15 replies