-
app/Models/Enrollment.php
Open in GitHubuse Illuminate\Database\Eloquent\Model; class Enrollment extends Model { // public function scheduledPayments() { return $this->hasMany(ScheduledPayment::class); } // }
-
app/Http/Controllers/ScheduledPaymentController.php
Open in GitHubuse App\Models\Enrollment; use Illuminate\Http\Request; class ScheduledPaymentController extends Controller { // public function store(Enrollment $enrollment, Request $request) { foreach ($request->payments as $p => $payment) { $enrollment->scheduledPayments()->create([ 'responsable_id' => backpack_user()->id, 'value' => $payment['value'], 'date' => $payment['date'], 'status' => 1, ]); } } // }