Nuekrato
Nuekrato
FFilament
Created by Nuekrato on 9/19/2024 in #❓┊help
Filament Panel assets not respecting X-Forwarded-Host Header
This is my app/Http/Middleware/TrustProxies.php
<?php

namespace App\Http\Middleware;

use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;

class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var string|array
*/
protected $proxies = '*';

/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO;
}
<?php

namespace App\Http\Middleware;

use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;

class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var string|array
*/
protected $proxies = '*';

/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO;
}
4 replies
FFilament
Created by Nuekrato on 9/19/2024 in #❓┊help
Filament Panel assets not respecting X-Forwarded-Host Header
OK. I further analysed the issue and it seems like a Filament bug: If I set this in the panel provider:
public function panel(Panel $panel): Panel
{
if (request()->hasHeader('X-Forwarded-Host') {
request()->headers->set('Host', request()->header('X-Forwarded-Host'));
}
}
public function panel(Panel $panel): Panel
{
if (request()->hasHeader('X-Forwarded-Host') {
request()->headers->set('Host', request()->header('X-Forwarded-Host'));
}
}
This seems to be very odd. Laravel respects the X-Forwarded-Host-Header per default when running behind a loadbalancer. I didn't ever experience issues with assets but only using Filament in this case... Any ideas?
4 replies
FFilament
Created by Nuekrato on 8/14/2024 in #❓┊help
How to use a custom policy for a custom resource page or disable authorization entirely?
Alright thank you very much for your help!
14 replies
FFilament
Created by Nuekrato on 8/14/2024 in #❓┊help
How to use a custom policy for a custom resource page or disable authorization entirely?
OK. So I can use a custom (non resource page) like described here: https://filamentphp.com/docs/3.x/panels/pages But still use Eloquent Models and Relationships within Form or Table?
14 replies
FFilament
Created by Nuekrato on 8/14/2024 in #❓┊help
How to use a custom policy for a custom resource page or disable authorization entirely?
But it seems like resource pages do not fit my use case
14 replies
FFilament
Created by Nuekrato on 8/14/2024 in #❓┊help
How to use a custom policy for a custom resource page or disable authorization entirely?
I created a custom page now. I was thinking about a resource page because I resolve a resource (eloquent model) from the magic link in the end and want to show a table with related data to that model. So I thought using a resource page for this would make sense.
14 replies
FFilament
Created by Nuekrato on 8/14/2024 in #❓┊help
How to use a custom policy for a custom resource page or disable authorization entirely?
I use the same resource in my "main" app panel that uses the default model policies. I setup an additional "guest" panel for unauthenticated users that can download files from a resource using some kind of magic link. For this I want to check if the URL contains a valid token instead of checking for any model policies (or use a custom policy for that check). For my custom page I don't need any navigation, breadcrumbs or whatsoever. From my Resource class:
public static function getPages(): array
{
return [
'download' => Pages\DownloadProject::route('/download/{token}'),
];
}
public static function getPages(): array
{
return [
'download' => Pages\DownloadProject::route('/download/{token}'),
];
}
I encrounter a second issue with the getPages()-method if I omit the index page for the resource. Somehow the index page seems to be required?
[2024-08-14 12:27:14] local.ERROR: Route [filament.guest.resources.projects.index] not defined. {"view":{"view":"/var/www/html/vendor/filament/filament/resources/views/components/page/index.blade.php","data":[]},"exception":"[object] (Spatie\\LaravelIgnition\\Exceptions\\ViewException(code: 0): Route [filament.guest.resources.projects.index] not defined. at /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:477)
[stacktrace]
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(811): Illuminate\\Routing\\UrlGenerator->route()
#1 /var/www/html/vendor/filament/filament/src/Resources/Resource.php(701): route()
#2 /var/www/html/vendor/filament/filament/src/Resources/Pages/Page.php(123): Filament\\Resources\\Resource::getUrl()
#3 /var/www/html/vendor/filament/filament/resources/views/components/page/index.blade.php(36): Filament\\Resources\\Pages\\Page->getBreadcrumbs()
[2024-08-14 12:27:14] local.ERROR: Route [filament.guest.resources.projects.index] not defined. {"view":{"view":"/var/www/html/vendor/filament/filament/resources/views/components/page/index.blade.php","data":[]},"exception":"[object] (Spatie\\LaravelIgnition\\Exceptions\\ViewException(code: 0): Route [filament.guest.resources.projects.index] not defined. at /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:477)
[stacktrace]
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(811): Illuminate\\Routing\\UrlGenerator->route()
#1 /var/www/html/vendor/filament/filament/src/Resources/Resource.php(701): route()
#2 /var/www/html/vendor/filament/filament/src/Resources/Pages/Page.php(123): Filament\\Resources\\Resource::getUrl()
#3 /var/www/html/vendor/filament/filament/resources/views/components/page/index.blade.php(36): Filament\\Resources\\Pages\\Page->getBreadcrumbs()
14 replies
FFilament
Created by Alvika Aji Prahasta on 8/14/2024 in #❓┊help
Table TextInputColumn Update Other Model
That's because Filament thinks that each form input relates to a model property. You are using a custom identifier (TextInputColumn::make("score_{$property->id}")) that does not belong to any model property. This use case is described in the docs: https://filamentphp.com/docs/3.x/forms/advanced#field-dehydration Try to use the TextInputColumn with the ->dehydrated(false) option.
7 replies
FFilament
Created by Nuekrato on 8/8/2024 in #❓┊help
Table: How to position bulk action checkbox?
OK thanks. That could be a solution. Could be a useful feature though
4 replies
FFilament
Created by Nuekrato on 5/28/2024 in #❓┊help
CheckboxList: modifyOptionsQueryUsing does not exist
So I need to use either one and in my use case I think I need options and I should handle the relationship attach/detach myself in the action handle method?
5 replies
FFilament
Created by Nuekrato on 5/28/2024 in #❓┊help
CheckboxList: modifyOptionsQueryUsing does not exist
Does anyone has an idea? This seems like a bug, because it behaves differently than other components - also the missing method from the docs seems odd.
5 replies
FFilament
Created by Nuekrato on 5/15/2024 in #❓┊help
Form: Adding user-defined pivot data to belongsToMany relationship
I also have a pivot model that casts the JSON column to an array:
protected $casts = [
'allowed_file_extensions' => 'array',
];
protected $casts = [
'allowed_file_extensions' => 'array',
];
5 replies
FFilament
Created by Nuekrato on 5/15/2024 in #❓┊help
Form: Adding user-defined pivot data to belongsToMany relationship
Anyone has an idea?
5 replies
FFilament
Created by Nuekrato on 5/15/2024 in #❓┊help
Form: Adding user-defined pivot data to belongsToMany relationship
For now I would like to go with a RelationManager on the Edit page so I can edit the pivot data later. But I have problems using a repeater:
[2024-05-15 10:18:48] production.ERROR: foreach() argument must be of type array|object, string given {"userId":"9bb5ab66-79fe-4a37-a059-07bc95238656","exception":"[object] (ErrorException(code: 0): foreach() argument must be of type array|object, string given at /var/www/html/vendor/filament/forms/src/Components/Repeater.php:755)
[stacktrace]
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(255): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 /var/www/html/vendor/filament/forms/src/Components/Repeater.php(755): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->Illuminate\\Foundation\\Bootstrap\\{closure}()
[2024-05-15 10:18:48] production.ERROR: foreach() argument must be of type array|object, string given {"userId":"9bb5ab66-79fe-4a37-a059-07bc95238656","exception":"[object] (ErrorException(code: 0): foreach() argument must be of type array|object, string given at /var/www/html/vendor/filament/forms/src/Components/Repeater.php:755)
[stacktrace]
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(255): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 /var/www/html/vendor/filament/forms/src/Components/Repeater.php(755): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->Illuminate\\Foundation\\Bootstrap\\{closure}()
This is the form in my AllowedTargetsRelationManager:
public function form(Form $form): Form
{
return $form
->schema([
Repeater::make('allowed_file_extensions')
->simple(
TextInput::make('extension')
->regex('/\s/u')
->required(),
)
]);
}
public function form(Form $form): Form
{
return $form
->schema([
Repeater::make('allowed_file_extensions')
->simple(
TextInput::make('extension')
->regex('/\s/u')
->required(),
)
]);
}
These are typical data in the database of the allowed_file_extensions column: ["json"]`` default: []`
5 replies
FFilament
Created by Nuekrato on 5/14/2024 in #❓┊help
Form: Nested JSON values are stored as string instead of integers
Thanks @Leandro Ferreira this works. Is it possible to build something like this directly into Filament? Ideally by respecting the model $casts-property?
4 replies
FFilament
Created by Boustrophedon on 5/8/2024 in #❓┊help
Show columns from relation on different connection?
That's the reason why you don't see an error or anything in the frontend
8 replies
FFilament
Created by Boustrophedon on 5/8/2024 in #❓┊help
Show columns from relation on different connection?
Also in my experience Filament "silently fails" if a Form or Table field does not directly match with a Model's attribute
8 replies
FFilament
Created by Boustrophedon on 5/8/2024 in #❓┊help
Show columns from relation on different connection?
I am not sure if Filament is case-sensitive here
8 replies
FFilament
Created by Boustrophedon on 5/8/2024 in #❓┊help
Show columns from relation on different connection?
Try Tables\Columns\TextColumn::make('user.name') with a lower case u
8 replies
FFilament
Created by Nuekrato on 5/8/2024 in #❓┊help
How to get $data from table form action?
Nevermind. I found another way by just using the $record in the action directly and get the relationship after saving. So I can use that data to dispatch an Event:
->action(function ($record, $livewire) {
logger()->debug('Permissions', $record->projectPermissions($livewire->ownerRecord)->get()->toArray());
})
->action(function ($record, $livewire) {
logger()->debug('Permissions', $record->projectPermissions($livewire->ownerRecord)->get()->toArray());
})
9 replies