Fonz
Fonz
FFilament
Created by Fonz on 3/21/2024 in #❓┊help
Import: Column not found: 1054 Unknown column 'grade' in 'field list'
Hi, I have an import action in a relationship manager, with the following fields:
ImportColumn::make('name')
->requiredMapping()
->rules(['required', 'max:255']),
ImportColumn::make('grade')
->rules(['max:255']),
ImportColumn::make('birthday')
->rules(['date']),
ImportColumn::make('name')
->requiredMapping()
->rules(['required', 'max:255']),
ImportColumn::make('grade')
->rules(['max:255']),
ImportColumn::make('birthday')
->rules(['date']),
Then in resolveRecord(), I check if the record exists (firstOrCreate) and attach to its parent. The value from grade should be saved in the pivot table.
$particpant = Participant::firstOrCreate([
'name' => $this->data['name'],
]);
$grade = $this->data['grade'] ?? null;
$particpant->certificats()->syncWithoutDetaching($this->options['certificatID'], ['grade' => $grade]);

return $particpant;
$particpant = Participant::firstOrCreate([
'name' => $this->data['name'],
]);
$grade = $this->data['grade'] ?? null;
$particpant->certificats()->syncWithoutDetaching($this->options['certificatID'], ['grade' => $grade]);

return $particpant;
If I import name and birthday only, everything works as expected. But as soon as I add grade, I get the following error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'grade' in 'field list' (Connection: mysql, SQL: update `participants` set `grade` = 10, `participants`.`updated_at` = 2024-03-21 21:02:46 where `id` = 10963)
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'grade' in 'field list' (Connection: mysql, SQL: update `participants` set `grade` = 10, `participants`.`updated_at` = 2024-03-21 21:02:46 where `id` = 10963)
The script tries to add the grade to the participant table when creating a new participant, which does not exist. How to tell it to ignore "grade" when creating a new participant? I tried setting 'birthday' a second parameter, in hope it would then only consider name and birthday. But it does not. Is this even the right way to handle this import action? Thanks
4 replies
FFilament
Created by Fonz on 10/30/2023 in #❓┊help
404 on admin/new (Filament\Pages\Tenancy\RegisterTenant)
Hi, I am using multi-tenancy and have created a tenant registration page as described in the docs. CreatePlateform.php
<?php
namespace App\Filament\Pages;
...
use Filament\Pages\Tenancy\RegisterTenant;
use Illuminate\Database\Eloquent\Model;
use App\Models\Tenant;

class CreatePlateform extends RegisterTenant
{
public static function getLabel(): string
{
return 'Create new plateform';
}

public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
...
]);
}
}
<?php
namespace App\Filament\Pages;
...
use Filament\Pages\Tenancy\RegisterTenant;
use Illuminate\Database\Eloquent\Model;
use App\Models\Tenant;

class CreatePlateform extends RegisterTenant
{
public static function getLabel(): string
{
return 'Create new plateform';
}

public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
...
]);
}
}
AdminPanelProvider.php
...
use App\Filament\Pages\CreatePlateform;
...
->tenantRegistration(CreatePlateform::class)
...
...
use App\Filament\Pages\CreatePlateform;
...
->tenantRegistration(CreatePlateform::class)
...
route:list
GET|HEAD admin/new .......... filament.admin.tenant.registration › App\Filament\Pages\CreatePlateform
GET|HEAD admin/new .......... filament.admin.tenant.registration › App\Filament\Pages\CreatePlateform
If I click on "Create new plateform" in the menu, I get a "404 | Not found" error. Could it be a permission problem? I am using althinect/filament-spatie-roles-permissions. But wouldn't this throw a 403 error? I have a "Super Admin" role, but they are attachted to the exiting tenants (one role per tenant). Thank you
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
I would like to display a boolean column of the users and the currenty tenant relation in a table and I am a bit lost. Can someone point me to the right direction? Thanks
5 replies
FFilament
Created by Fonz on 10/4/2023 in #❓┊help
weird month names in date column
No description
6 replies
FFilament
Created by Fonz on 9/19/2023 in #❓┊help
Custom validation rules
I am currently using a custom validation rule on a form. I would like to use the same rule in filament, but I do not know how. This is the rule: $request->validate([ "onlineRegistration" => [new OneOf($request, ["onlineRegistration","registrationLink","registrationEmail"])], "registrationLink" => [new OneOf($request, ["onlineRegistration","registrationLink","registrationEmail"])], "registrationEmail" => [new OneOf($request, ["onlineRegistration","registrationLink","registrationEmail"])], ]); In filament, I tried this: Toggle::make('onlineRegistration')->rules([new OneOf(request(), ["onlineRegistration","registrationLink","registrationEmail"])]), But it always shows a validation error
9 replies