Skjena
Skjena
FFilament
Created by Skjena on 2/8/2024 in #❓┊help
Can't get the field when disabled
I have made the employee_id selectable for role-based users. However, when the field is disabled, I can't get the employee_id in $data inside the handleRecordCreation().
17 replies
FFilament
Created by Skjena on 11/29/2023 in #❓┊help
Encounter a network issue while uploading a file using SpatieMediaLibraryFileUpload
When I create a record without using file upload, it is successfully created. However, when I attempt to create a record with a file, it encounters a network issue, but the record is still successfully created.
9 replies
FFilament
Created by Skjena on 10/4/2023 in #❓┊help
How can I access the table filter value within the getTableQuery() function of a table widget?
Inside getTableFilters(), I created my filter fields and want to get the filter value within the getTableQuery() function to customize the table query accordingly.
18 replies
FFilament
Created by Skjena on 10/3/2023 in #❓┊help
Typed property Filament\Widgets\TableWidget::$table must not be accessed before initialization.
$this->getTableFilterState("key")["value"] returns the error $table must not be used before initialisation when I try to retrieve the current filter value.
7 replies
FFilament
Created by Skjena on 9/30/2023 in #❓┊help
Value keeps getting deleted automatically inside TextInput field.
Some values are immediately removed while typing in the TextInput field, especially when typing quickly. Here is that TextInput field code
TextInput::make('name')
->afterStateUpdated(function (\Filament\Forms\Set $set, $state, $context) {
if ($context === 'edit') {
return;
}
$set('slug', Str::slug($state));
})
->reactive()
->required()
TextInput::make('name')
->afterStateUpdated(function (\Filament\Forms\Set $set, $state, $context) {
if ($context === 'edit') {
return;
}
$set('slug', Str::slug($state));
})
->reactive()
->required()
i think the issue with reactive() and live() , because when i use lazy() there is no such issue. Could you help me out with this issue ? Thanks.
6 replies
FFilament
Created by Skjena on 9/1/2023 in #❓┊help
The table design breaks after adding url() to the table columns.
The table design breaks after adding url() to the table columns.
7 replies
FFilament
Created by Skjena on 8/25/2023 in #❓┊help
After updating to filament v3, resources are not shown.
My project has been updated to filament version 3, which displays only the getNavigationGroup but not the resources.
14 replies
FFilament
Created by Skjena on 8/21/2023 in #❓┊help
How to display percentages on pie chart pieces?
I have a pie chart where I show the value if you hover over it, but I want to show it as a percentage. Here is my code
protected function getData(): array
{
$data = [
"draft" => 1,
"in_use" => 3,
"available" => 2,
"under_repair" => 0
];
return [
'datasets' => [
[
'label' => 'Assets',
'data' => array_values($data),
'backgroundColor' => [
'#C98249',
'#69B19C',
'#9FCAE1',
'#D67676',
],
'borderColor' => [
'#A6693A',
'#467D6E',
'#6A90B8',
'#B05858',
],
'borderWidth' => 0.5,
],
],
'labels' => array_keys($data),
];
}
protected function getData(): array
{
$data = [
"draft" => 1,
"in_use" => 3,
"available" => 2,
"under_repair" => 0
];
return [
'datasets' => [
[
'label' => 'Assets',
'data' => array_values($data),
'backgroundColor' => [
'#C98249',
'#69B19C',
'#9FCAE1',
'#D67676',
],
'borderColor' => [
'#A6693A',
'#467D6E',
'#6A90B8',
'#B05858',
],
'borderWidth' => 0.5,
],
],
'labels' => array_keys($data),
];
}
6 replies
FFilament
Created by Skjena on 7/5/2023 in #❓┊help
The dynamic toggle button is not working and has the value null saved.
When I select an asset type in AssetResource, the AssetTypeResource's associated schema is made available for filling out, with the exception of the toggle button. I have built an AssetTypeResource where I have established the schema for a certain asset type. When I first created an asset the toggle button field, stored the null value rather than the value true/false; yet, on the edit page, the value true/false is saved.
public static function getAssetFieldsFormSchema($asset_type_id, Form $form)
{
if (empty($asset_type_id)) {
return [];
}
$fieldHandlers = [
'toggle' => function ($field, $fieldResponseKey) {
$text_input = Toggle::make($fieldResponseKey)
->label($field['field_label'])
->onIcon('heroicon-s-check')
->offIcon('heroicon-s-x');
if ($field['field_is_required'])
$text_input->required(true);
return $text_input;
},
];
$asset_type_fields = AssetType::find($asset_type_id)->fields;
$schema = [];
foreach ($asset_type_fields as $field) {
$asset_field_key = "asset_fields.{$field['field_key']}";
$fieldType = $field['field_type'];

if (isset($fieldHandlers[$fieldType])) {
$handler = $fieldHandlers[$fieldType];
$schema[] = $handler($field, $asset_field_key);
}
}
return $schema;
}
public static function getAssetFieldsFormSchema($asset_type_id, Form $form)
{
if (empty($asset_type_id)) {
return [];
}
$fieldHandlers = [
'toggle' => function ($field, $fieldResponseKey) {
$text_input = Toggle::make($fieldResponseKey)
->label($field['field_label'])
->onIcon('heroicon-s-check')
->offIcon('heroicon-s-x');
if ($field['field_is_required'])
$text_input->required(true);
return $text_input;
},
];
$asset_type_fields = AssetType::find($asset_type_id)->fields;
$schema = [];
foreach ($asset_type_fields as $field) {
$asset_field_key = "asset_fields.{$field['field_key']}";
$fieldType = $field['field_type'];

if (isset($fieldHandlers[$fieldType])) {
$handler = $fieldHandlers[$fieldType];
$schema[] = $handler($field, $asset_field_key);
}
}
return $schema;
}
14 replies
FFilament
Created by Skjena on 6/13/2023 in #❓┊help
How do I display the time (hh:mm) on the yaxis of a linechart?
Here is my code protected function getData(): array { $data = Attendance::where('user_id', 1) ->where('attendance_month', '2023-06-01') ->orderBy('check_in') ->get() ->groupBy(function ($attendance) { return Carbon::parse($attendance->check_in)->format('Y-m-d'); // Group by date }) ->map(function ($groupedAttendances) { $firstCheckIn = $groupedAttendances->first()->check_in; $timezone = config('app.user_timezone'); return Carbon::parse($firstCheckIn)->timezone($timezone)->format('Y-m-d H:i:s'); // Get the first check-in time of each day }) ->toArray(); $days = array_map(function ($value) { return date('d', strtotime($value)); }, array_keys($data)); $times = array_map(function ($value) { return date('h:i', strtotime($value)); }, array_values($data)); return [ 'datasets' => [ [ 'label' => 'User checkin time', 'data' => $times, 'borderColor' => 'rgb(61, 178, 106)', 'backgroundColor' => 'rgb(61, 178, 106)', 'borderWidth' => 2, 'tension' => 0.3, 'fill' => false, 'pointRadius' => 2, 'height' => 100 ], ], 'labels' => $days ]; }
14 replies