F
Filamentβ€’9mo ago
afdhal

how to store repeater data in 1 table, I get an error:Array to string conversion

😩
3 Replies
!Andy
!Andyβ€’9mo ago
// Assuming $repeaterData is your array from the repeater
$repeaterData = array(/* ... */);

// Convert the array to a JSON string
$repeaterJson = json_encode($repeaterData);

// Now, you can store $repeaterJson in your database
// Perform your database insert/update operation here
// Assuming $repeaterData is your array from the repeater
$repeaterData = array(/* ... */);

// Convert the array to a JSON string
$repeaterJson = json_encode($repeaterData);

// Now, you can store $repeaterJson in your database
// Perform your database insert/update operation here
afdhal
afdhalOPβ€’9mo ago
in this case I have succeeded, but how to retrieve the school_id on selected tabs 1, then on tabs 2 selected teacher_id will filter from the school_id value
// Tabs 1
School Selected

Select::make('school_id')
->pluck('name', 'id'))
->live()
->required(),
// Tabs 2
Teacher Repeater

Select::make('teacher_id')
->pluck('name', 'id');
})
->required()
->searchable()
// Tabs 1
School Selected

Select::make('school_id')
->pluck('name', 'id'))
->live()
->required(),
// Tabs 2
Teacher Repeater

Select::make('teacher_id')
->pluck('name', 'id');
})
->required()
->searchable()
afdhal
afdhalOPβ€’9mo ago
You are trying to retrieve the value of client_id from inside the repeater item.

$get() is relative to the current repeater item, so $get('client_id') is looking for $get('repeater.item1.client_id').

You can use ../ to go up a level in the data structure, so $get('../client_id') is $get('repeater.client_id') and $get('../../client_id') is $get('client_id')
You are trying to retrieve the value of client_id from inside the repeater item.

$get() is relative to the current repeater item, so $get('client_id') is looking for $get('repeater.item1.client_id').

You can use ../ to go up a level in the data structure, so $get('../client_id') is $get('repeater.client_id') and $get('../../client_id') is $get('client_id')
https://filamentphp.com/docs/3.x/forms/fields/repeater
Want results from more Discord servers?
Add your server