Ander
Ander
FFilament
Created by Ander on 2/1/2024 in #❓┊help
Does not install filament package
When I update the filament package, it shows me this error: Your requirements could not be resolved to an installable set of packages. Problem 1 - Root composer.json requires filament/upgrade ^3.1, it is satisfiable by filament/upgrade[v3.1.0-alpha1, ..., 3.x-dev] from composer repo (https://repo.packagist.org) but filament/upgrade[dev-main] from path repo (filament/packages/*) has higher repository priority. The packages from the higher priority repository do not match your constraint and are therefore not installable. That repository is canonical so the lower priority repo's packages are not installable. See https://getcomposer.org/repoprio for details and assistance. Follow these steps: https://github.com/filamentphp/filament/tree/3.x?tab=readme-ov-file#contributing
3 replies
FFilament
Created by Ander on 1/31/2024 in #❓┊help
Wizard still showing "Next" when steps hidden dynamically
I'm trying to hide a step depending on the variable 'applies_to_all_employees,' the step hides, but the 'next' button doesn't change to 'create.' In version 2 of filament, this did work.
protected function getSteps()
{
return [
Step::make(__('bonuses.create.bonus_name'))
->schema(
BonusesResource::getFormSchema('0')
),
Step::make(__('bonuses.create.add_employees'))
->hidden(fn (Get $get) => empty($get('applies_to_all_employees')) ? false : true)
->schema([
Grid::make(['default' => 1, 'sm' => 1, 'xl' => 2])
->schema([
...
])
]),
];
}
protected function getSteps()
{
return [
Step::make(__('bonuses.create.bonus_name'))
->schema(
BonusesResource::getFormSchema('0')
),
Step::make(__('bonuses.create.add_employees'))
->hidden(fn (Get $get) => empty($get('applies_to_all_employees')) ? false : true)
->schema([
Grid::make(['default' => 1, 'sm' => 1, 'xl' => 2])
->schema([
...
])
]),
];
}
2 replies
FFilament
Created by Ander on 7/31/2023 in #❓┊help
hasone relations and belong to
I am trying to use 2 relations in a resource, the model is "employee", through this I am making the first relation to get to the "EmployeeAddress" table, the relationship is hasOne, data: 'employee_id','address_id', 'start_date', 'end_date', the second is to get to the "Address" table, the relationship is belongs to, data: 'street_1', 'street_2', 'city', 'state', 'postal code'. but when saving all the data it returns this error: SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause'
update `employee_addresses` set `address_id` = 22783556 where `` = 22783541 and `` = 22783541
update `employee_addresses` set `address_id` = 22783556 where `` = 22783541 and `` = 22783541
but it is supposed that when the relation is there it returns the id, isn't it?
relationships:
model: Employee
public function employeeAddress()
{
return $this->hasOne('App\Models\Tenant\EmployeeAddress','employee_id');
}

model: EmployeeAddress
public function address()
{
return $this->belongsTo('App\Models\Tenant\Address', 'address_id');
}


Group::make()
->relationship('employeeAddress')
->schema([
Hidden::make('start_date')->default(now()->toDateString()),
Hidden::make('end_date')->default(now()->toDateString()),
Group::make()
->relationship('address')
->schema([
TextInput::make('street_1'),
TextInput::make('street_2'),
TextInput::make('city'),
TextInput::make('state'),
TextInput::make('zip'),
]),
]),
relationships:
model: Employee
public function employeeAddress()
{
return $this->hasOne('App\Models\Tenant\EmployeeAddress','employee_id');
}

model: EmployeeAddress
public function address()
{
return $this->belongsTo('App\Models\Tenant\Address', 'address_id');
}


Group::make()
->relationship('employeeAddress')
->schema([
Hidden::make('start_date')->default(now()->toDateString()),
Hidden::make('end_date')->default(now()->toDateString()),
Group::make()
->relationship('address')
->schema([
TextInput::make('street_1'),
TextInput::make('street_2'),
TextInput::make('city'),
TextInput::make('state'),
TextInput::make('zip'),
]),
]),
3 replies
FFilament
Created by Ander on 7/25/2023 in #❓┊help
get element of array, not index
How can I get the element of the index of the array of a select. The $state only returns the index of the array but I also need the element . For example, the values ​​are: [ 'A' => 'Example 1', 'B' => 'Example 2' ]. I want to get "Example 1", but I don't want to modify 'A', otherwise I would put something like 'Example 1' => 'Example 1'.
Select::make('job_id')->label(__('employees.job_id'))
->options(Job::get()->pluck('name', 'id'))->searchable() ->afterStateUpdated(
function($state)
{
**\Log::alert($state); //return INDEX
//I want to get element
//$set('test', I want to get element);**
}),
Select::make('job_id')->label(__('employees.job_id'))
->options(Job::get()->pluck('name', 'id'))->searchable() ->afterStateUpdated(
function($state)
{
**\Log::alert($state); //return INDEX
//I want to get element
//$set('test', I want to get element);**
}),
4 replies
FFilament
Created by Ander on 7/25/2023 in #❓┊help
relationship on a resource
10 replies
FFilament
Created by Ander on 7/18/2023 in #❓┊help
select will not open createOptionForm modal
Inside a custom page of a resource, I call a Livewire view, where I have a form, but the select modal doesn't open, but if I use a form on the page, it opens. <x-filament::page> {{$this->form}} @livewire('form-pay-schedule') </x-filament::page> Does anyone know why this happens?
5 replies
FFilament
Created by Ander on 7/17/2023 in #❓┊help
Default selection for radio element - not working!
6 replies
FFilament
Created by Ander on 7/10/2023 in #❓┊help
Form Select - how can I interact with the newly created record after creation?
When creating an option from a Select field, how can I interact with the newly created record after creation? or some way that I can create it my way instead of saving automatically Forms\Components\Select::make('user_id') ->relationship('user', 'name') ->searchable() ->createOptionForm([ Forms\Components\TextInput::make('name') ->label(('Nombre')) ->required(), Forms\Components\TextInput::make('email') ->label(('Email')) ->required() ->email() ]) ->createOptionAction(function (Forms\Components\Actions\Action $action) { return $action ->modalHeading('new user') ->modalButton('create') ->modalWidth('lg'); })->after(function () use ($record) { $table = TableTest::([ "id_user" => $record->id; ]) }); })
3 replies
FFilament
Created by Ander on 7/4/2023 in #❓┊help
position of repeater
6 replies
FFilament
Created by Ander on 6/20/2023 in #❓┊help
FileUpload - it shows me this error: No such file or directory
11 replies
FFilament
Created by Ander on 6/14/2023 in #❓┊help
Not recognized more than one rule
This is my code:
Select::make('frequency')
->options([
'weekly' => 'Semanalmente',
'fortnightly' => 'Quincenal',
'monthly_twice' => 'Dos veces al mes',
'monthly' => 'Mensual',
'quarterly' => 'Trimestral',
'annually' => 'Anualmente',
])->required(),
TextInput::make('frequency_day_1')->numeric()->rules([function (Closure $get) {
$frequency = $get('frequency');
\Log::alert($frequency);
switch ($frequency)
{
case 'weekly':
return 'max:7|min:1';
break;
case 'fortnightly':
return 'max:7';
break;
default:
return;
break;
}
}]),
Select::make('frequency')
->options([
'weekly' => 'Semanalmente',
'fortnightly' => 'Quincenal',
'monthly_twice' => 'Dos veces al mes',
'monthly' => 'Mensual',
'quarterly' => 'Trimestral',
'annually' => 'Anualmente',
])->required(),
TextInput::make('frequency_day_1')->numeric()->rules([function (Closure $get) {
$frequency = $get('frequency');
\Log::alert($frequency);
switch ($frequency)
{
case 'weekly':
return 'max:7|min:1';
break;
case 'fortnightly':
return 'max:7';
break;
default:
return;
break;
}
}]),
what I'm trying to do is create different rules depending on what the user chooses in the select. It only works for me if I use one rule, when I use more than one it returns this error: "The given value "7|min:1" does not represent a valid number."
6 replies
FFilament
Created by Ander on 3/30/2023 in #❓┊help
Customizing notifications doesn't work
16 replies