Zakhaev
Zakhaev
FFilament
Created by Zakhaev on 5/7/2024 in #❓┊help
FillForms not working on a custom page with multiple forms.
I got a custom page where i use multiple forms. in the mount function i add a fillforms method.
public function mount(): void
{
if (!isAssetManager() && !isManager()) {
abort(404);
}

//Get the user
$this->user = Filament::auth()->user();

$this->profileData = [
// 'id' => $user->id,
'Naam' => $this->user->name,
'Email' => $this->user->email,
'Telefoonnummer' => $this->user->phone_number,

// Add other properties as needed
];

$this->fillForms();
public function mount(): void
{
if (!isAssetManager() && !isManager()) {
abort(404);
}

//Get the user
$this->user = Filament::auth()->user();

$this->profileData = [
// 'id' => $user->id,
'Naam' => $this->user->name,
'Email' => $this->user->email,
'Telefoonnummer' => $this->user->phone_number,

// Add other properties as needed
];

$this->fillForms();
Then i try to fill it but the toggle always stays false i dont know what im missing
protected function fillForms(): void
{
$this->getAccountFormSchema->fill();
$this->getDashboardFormSchema->fill();
$this->getConnectivityFormSchema->fill(['mileage_request_service' => true]);
}

protected function getForms(): array
{
return [
'getAccountFormSchema',
'getDashboardFormSchema',
'getConnectivityFormSchema',
];
}
protected function getConnectivityFormSchema(Form $form): Form
{
return $form
->schema([
Toggle::make('mileage_request_service')
->label('Kilometerstand ophalen doormiddel van online service')
->reactive(),
]);
}
protected function fillForms(): void
{
$this->getAccountFormSchema->fill();
$this->getDashboardFormSchema->fill();
$this->getConnectivityFormSchema->fill(['mileage_request_service' => true]);
}

protected function getForms(): array
{
return [
'getAccountFormSchema',
'getDashboardFormSchema',
'getConnectivityFormSchema',
];
}
protected function getConnectivityFormSchema(Form $form): Form
{
return $form
->schema([
Toggle::make('mileage_request_service')
->label('Kilometerstand ophalen doormiddel van online service')
->reactive(),
]);
}
3 replies
FFilament
Created by Zakhaev on 3/8/2024 in #❓┊help
Accessing accessor trough a relationship
Hi, i got a problem and i couldnt find the answer on the net. in my Invoice resource i have a table column like this
TextColumn::make('lineItems.total_vat')
TextColumn::make('lineItems.total_vat')
in the invoice model i have a relationship like this
class Order2CashInvoice extends Model
{
public function lineItems()
{
return $this->hasMany(Order2CashLineItem::class, 'invoice_id');
}
class Order2CashInvoice extends Model
{
public function lineItems()
{
return $this->hasMany(Order2CashLineItem::class, 'invoice_id');
}
And then in my LineItem model i have this
public function getTotalVatAttribute($key = 'BedragBtw')
{
return $this->additionalItemProperties()
->where('name', $key)
->first()
->value ?? null; // Return the value or null if not found
}
public function getTotalVatAttribute($key = 'BedragBtw')
{
return $this->additionalItemProperties()
->where('name', $key)
->first()
->value ?? null; // Return the value or null if not found
}
the additionalitemproperties is a relationship to a model that has many records beloning to one lineitem
class Order2CashAdditionalItemProperty extends Model
{
public function lineItem()
{
return $this->belongsTo(Order2CashLineItem::class, 'line_item_id');
}
class Order2CashAdditionalItemProperty extends Model
{
public function lineItem()
{
return $this->belongsTo(Order2CashLineItem::class, 'line_item_id');
}
i cant figure it out thanks for the help
12 replies
FFilament
Created by Zakhaev on 1/29/2024 in #❓┊help
problem when editing or viewing deleted records
I have just a resource with records. But when i delete one and try to edit or view it i get a 404. What can i do to solve this problem. Im using softdeletes to delete a record The code is just a normal resource nothing special or extra
12 replies
FFilament
Created by Zakhaev on 8/15/2023 in #❓┊help
Problem with decimal format (EUR) (,)
28 replies
FFilament
Created by Zakhaev on 8/15/2023 in #❓┊help
Relation with where id check doesnt work like i want it
I have this piece of code that allows searching all the assets
Select::make('asset_id')
->label('Selecteer aan middel')
->searchable([
'name','identifier'
])
->relationship('asset','full_name')
Select::make('asset_id')
->label('Selecteer aan middel')
->searchable([
'name','identifier'
])
->relationship('asset','full_name')
but now i want them filtered on a organisation_id this is what i did in the model.
public function asset()
{
return $this->belongsTo(Asset::class)->where('organisation_id', Filament::auth()->user()->organisation_id);
}
public function asset()
{
return $this->belongsTo(Asset::class)->where('organisation_id', Filament::auth()->user()->organisation_id);
}
but when i check it with Telescope i see that the organisation_id check is never performed. Anyone tips for me ?
4 replies
FFilament
Created by Zakhaev on 8/11/2023 in #❓┊help
change html or make it a button of createoptions icon/button
6 replies
FFilament
Created by Zakhaev on 8/2/2023 in #❓┊help
Can i use a key/value logic on a textinput field?
Hi folks, i have a field where i display the username. But i want to save the ID to the database. Is this possible?
TextInput::make('user_id')
->label('Gebruiker')
->disabled()
->id($user->id)
->default($user->full_name),
TextInput::make('user_id')
->label('Gebruiker')
->disabled()
->id($user->id)
->default($user->full_name),
i tried using id field in default i display the username
5 replies
FFilament
Created by Zakhaev on 8/1/2023 in #❓┊help
AfterStateUpdate looks like it isnt working
Grid::make(2)->schema([
Select::make('chosen_asset')
->label('Selecteer aan middel')
->searchable()
->options(
Asset::all()->map(function ($asset) {
return [
'id' => $asset->id,
'value' => $asset->name . ' - ' . $asset->brand,
];
})->pluck('value', 'id')->toArray()
)
->afterStateUpdated(
fn (Closure $set, $value) => $set('asset_id', $value)
)
]),

Grid::make(2)->schema([
TextInput::make('asset_id')
->label('Type'),
Grid::make(2)->schema([
Select::make('chosen_asset')
->label('Selecteer aan middel')
->searchable()
->options(
Asset::all()->map(function ($asset) {
return [
'id' => $asset->id,
'value' => $asset->name . ' - ' . $asset->brand,
];
})->pluck('value', 'id')->toArray()
)
->afterStateUpdated(
fn (Closure $set, $value) => $set('asset_id', $value)
)
]),

Grid::make(2)->schema([
TextInput::make('asset_id')
->label('Type'),
As you can see in the example above. I have a chosen asset select component. With values of assets. That is working fine. But when some value is selected i want to change other fields according to that. I try to change the asset_id field below but nothing seems to be working. Can anyone help me with this?
7 replies
FFilament
Created by Zakhaev on 7/27/2023 in #❓┊help
Custom form component. But i want it to show a model.
30 replies
FFilament
Created by Zakhaev on 7/26/2023 in #❓┊help
Forms / Can i use a form checkbox to show or hide other form components?
Hi people, i have a quick question. I am using filament forms to build a form. Now i have a checkbox. But i want to show other forms components if the checkbox is checked. Is there a way to do this?
11 replies