Код: Выделить всё
// In Student model
public function studentFeePayment()
{
return $this->hasOne(StudentFeePayment::class);
}
//In StudentFeePayment model
public function student() {
return $this->belongsTo(Student::class);
}
Код: Выделить всё
Fieldset::make('Payment')
->relationship('studentFeePayment')
->schema([ ...... ])
Код: Выделить всё
class ListStudents extends ListRecords
{
protected static string $resource = StudentResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make()->label('Register New Student')
->using(function (array $data, string $model): Model {
// Here $data does not contain relationship items
})
];
}
}
Код: Выделить всё
Fieldset::make('Payment')
->relationship('studentFeePayment')
->schema([ .... ])
->saveRelationshipsUsing(function (Model $student, $state){
// Custom code to save relationship data
StudentService::createStudentFeePayment($student, $state);
})
Код: Выделить всё
Fieldset::make('Payment')
->relationship('studentFeePayment', false)
->schema([ .... ])
->saveRelationshipsUsing(function (Model $student, $state){
// Custom code to save relationship data
StudentService::createStudentFeePayment($student, $state);
})
Так что, похоже, мне нужно установить false и true для действий «Создать» и «Обновить» соответственно.
Поэтому я хочу знать последовательный способ реализации пользовательского сохранения данных отношений в Laravel Filament.
Примечание. Я использую модальные окна действий для создания и редактирования действий.
Подробнее здесь: https://stackoverflow.com/questions/784 ... ilament-v3
Мобильная версия