|
|
@@ -1668,21 +1668,31 @@ class Member extends Component
|
|
|
$mc->save();
|
|
|
|
|
|
// Se il corso ha associato una categoria iscrivo anche al gruppo
|
|
|
- $c = \App\Models\Course::findOrFail($this->course_course_id);
|
|
|
- if ($c) {
|
|
|
- if ($c->category_id > 0) {
|
|
|
- if (!\App\Models\MemberCategory::where('member_id', $this->dataId)->where('category_id', $c->category_id)->first()) {
|
|
|
- \App\Models\MemberCategory::create([
|
|
|
- 'member_id' => $this->dataId,
|
|
|
- 'category_id' => $c->category_id,
|
|
|
- 'date' => \Carbon\Carbon::now()
|
|
|
- ]);
|
|
|
+ if ($this->course_course_id) {
|
|
|
+ try {
|
|
|
+ $c = \App\Models\Course::findOrFail($this->course_course_id);
|
|
|
+ if ($c) {
|
|
|
+ if ($c->category_id > 0) {
|
|
|
+ if (!\App\Models\MemberCategory::where('member_id', $this->dataId)->where('category_id', $c->category_id)->first()) {
|
|
|
+ \App\Models\MemberCategory::create([
|
|
|
+ 'member_id' => $this->dataId,
|
|
|
+ 'category_id' => $c->category_id,
|
|
|
+ 'date' => \Carbon\Carbon::now()
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ } catch (\Throwable $e) {}
|
|
|
}
|
|
|
|
|
|
// Creo i pagamenti in base alla tipologia
|
|
|
- $r = \App\Models\CourseSubscription::findOrFail($this->course_course_subscription_id);
|
|
|
+ if ($this->course_course_subscription_id) {
|
|
|
+ try {
|
|
|
+ $r = \App\Models\CourseSubscription::findOrFail($this->course_course_subscription_id);
|
|
|
+ } catch (\Throwable $e) {
|
|
|
+ $r = new \App\Models\CourseSubscription();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
$start = $this->course_date_from;
|
|
|
|