undercode
undercode
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);
}
}
10 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