Fonz
Fonz
FFilament
Created by Fonz on 3/21/2024 in #❓┊help
Import: Column not found: 1054 Unknown column 'grade' in 'field list'
I solved it by adding an empty ->fillRecordUsing(function (Participant $participant, string $state) { })
4 replies
FFilament
Created by Fonz on 10/30/2023 in #❓┊help
404 on admin/new (Filament\Pages\Tenancy\RegisterTenant)
Adding a canView() function to the page fixes the issue
4 replies
FFilament
Created by Fonz on 10/15/2023 in #❓┊help
Custom column to display a pivot of the current user and tenancy relationship
With a bit of help from chatgpt: User.php
public function getAcceptedForCurrentTenantAttribute()
{
$userTenant = $this->tenants->firstWhere('id', \Filament\Facades\Filament::getTenant()->id);
return $userTenant ? $userTenant->pivot->accepted : 'N/A';
}
public function getAcceptedForCurrentTenantAttribute()
{
$userTenant = $this->tenants->firstWhere('id', \Filament\Facades\Filament::getTenant()->id);
return $userTenant ? $userTenant->pivot->accepted : 'N/A';
}
UserResource.php
TextColumn::make('Accepted for Current Tenant', 'acceptedForCurrentTenant')
TextColumn::make('Accepted for Current Tenant', 'acceptedForCurrentTenant')
This seems to work
5 replies
FFilament
Created by Fonz on 10/15/2023 in #❓┊help
Custom column to display a pivot of the current user and tenancy relationship
I am using stancl/tenancy for a plateform with tenancy. Users create an account and ask permission to access a tenant. When they register, I attach the tenant to a user and save some variables to the pivot table. On of those columns is "accepted" with a default value of 0. In filament, the user resource displays all the users that have the relationship of the current tenant. I now would like to display true or false (if they have been accepted or not) in a column based on the value from the pivot. I would like to do something like this $user->tenants()->where('id', $tenantId)->first(); and display the "accepted" column. Currently if I do "tenants.id" all the ids of the attached tenants are displayed. "tenants.accepted" returns nothing, probably because there is not with() in the query. My question is how to I add a custom query to a column?
5 replies
FFilament
Created by Fonz on 10/4/2023 in #❓┊help
weird month names in date column
Lu is not properly translated
6 replies
FFilament
Created by Fonz on 10/4/2023 in #❓┊help
weird month names in date column
6 replies
FFilament
Created by Fonz on 10/4/2023 in #❓┊help
weird month names in date column
Locale is 'lu' and fallback_locale is 'fr'. Everything in filament but the dates is in french. The dates are definitely not Luxembourgish.
6 replies
FFilament
Created by Fonz on 9/19/2023 in #❓┊help
Custom validation rules
Thanks, this works, just had change it a bit so it works with v2:
->rules([
function (Closure $get) {
return function (string $attribute, $value, Closure $fail) use ($get) {
$filledCount = 0;
foreach(["registrationLink","registrationEmail"] as $field) {
if ($get($field)) {
$filledCount++;
}
}
if ($get("onlineRegistration") == 1) {
$filledCount++;
}
if ($filledCount !== 1) {
$fail('Only one of may be selected');
}
};
}
]),
->rules([
function (Closure $get) {
return function (string $attribute, $value, Closure $fail) use ($get) {
$filledCount = 0;
foreach(["registrationLink","registrationEmail"] as $field) {
if ($get($field)) {
$filledCount++;
}
}
if ($get("onlineRegistration") == 1) {
$filledCount++;
}
if ($filledCount !== 1) {
$fail('Only one of may be selected');
}
};
}
]),
9 replies
FFilament
Created by Fonz on 9/19/2023 in #❓┊help
Custom validation rules
I have three fields and only one of those should be present
9 replies