Multiple Repeater
In the models Customer, Service, Transaction, ServiceTransaction, Payment, and PaymentTransaction, I display ServiceTransaction using a repeater in TransactionResource. I also want to use PaymentTransaction with a repeater, but it doesn't catch the payment_id. Is there a way to use a repeater that isn't related to the resource? Thank you!
Solution:Jump to solution
The problem is I can’t see the array sent by “payment” .Yes, because you declared it a
->relationship()
it is saving directly to that relationship and removing the data afterwards....5 Replies
Repeaters aren't related to the resource. Somebody might help if you'd share some code. You are probably using the
->relationship()
feature?->schema([
Section::make('Payment') ->schema([ Repeater::make('payments') ->relationship('paymentTransactions') ->schema([
TextInput::make('amount') ->numeric() ->label('Amount') ->required()->default(1), Select::make('currency') ->label('Currency') ->options([ 'USD' => 'USD', 'EUR' => 'EUR', 'GBP' => 'GBP', 'TRY' => 'TRY', 'JPY' => 'JPY', 'AUD' => 'AUD', ])
->required(),
]) ->addActionLabel('Add Payment') ->columns(3) ->defaultItems(1),
]), Select::make('status') ->options([ 'pending' => 'Pending', 'completed' => 'Completed', 'failed' => 'Failed', ]) ->default('pending') ->required(), ]); Actually when i use it in PaymentResource page it works, but in TransactionResource page it only works when i provide the payment-id manually. The problem is I can’t see the array sent by “payment” .
Section::make('Payment') ->schema([ Repeater::make('payments') ->relationship('paymentTransactions') ->schema([
TextInput::make('amount') ->numeric() ->label('Amount') ->required()->default(1), Select::make('currency') ->label('Currency') ->options([ 'USD' => 'USD', 'EUR' => 'EUR', 'GBP' => 'GBP', 'TRY' => 'TRY', 'JPY' => 'JPY', 'AUD' => 'AUD', ])
->required(),
]) ->addActionLabel('Add Payment') ->columns(3) ->defaultItems(1),
]), Select::make('status') ->options([ 'pending' => 'Pending', 'completed' => 'Completed', 'failed' => 'Failed', ]) ->default('pending') ->required(), ]); Actually when i use it in PaymentResource page it works, but in TransactionResource page it only works when i provide the payment-id manually. The problem is I can’t see the array sent by “payment” .
Please read #✅┊rules on code formatting
Solution
The problem is I can’t see the array sent by “payment” .Yes, because you declared it a
->relationship()
it is saving directly to that relationship and removing the data afterwards.Thank you so much, it worked after deleting the relationship.