|
@@ -7,7 +7,7 @@ use Livewire\Component;
|
|
|
class Course extends Component
|
|
class Course extends Component
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
- protected $listeners = ['setCausal' => 'setCausal'];
|
|
|
|
|
|
|
+ protected $listeners = ['setCausal' => 'setCausal', 'setSubscriptionCausal' => 'setSubscriptionCausal'];
|
|
|
|
|
|
|
|
public $records, $parent_id, $name, $enabled, $dataId, $update = false, $add = false;
|
|
public $records, $parent_id, $name, $enabled, $dataId, $update = false, $add = false;
|
|
|
public $course_type_id,
|
|
public $course_type_id,
|
|
@@ -15,10 +15,12 @@ class Course extends Component
|
|
|
$course_frequency_id,
|
|
$course_frequency_id,
|
|
|
$course_level_id,
|
|
$course_level_id,
|
|
|
$causal_id,
|
|
$causal_id,
|
|
|
|
|
+ $sub_causal_id,
|
|
|
$max_members,
|
|
$max_members,
|
|
|
$instructor,
|
|
$instructor,
|
|
|
$year,
|
|
$year,
|
|
|
$price,
|
|
$price,
|
|
|
|
|
+ $subscription_price,
|
|
|
$months,
|
|
$months,
|
|
|
$date_from, $date_to;
|
|
$date_from, $date_to;
|
|
|
|
|
|
|
@@ -31,6 +33,7 @@ class Course extends Component
|
|
|
public $monthList = [];
|
|
public $monthList = [];
|
|
|
|
|
|
|
|
public $typeIN = 'IN';
|
|
public $typeIN = 'IN';
|
|
|
|
|
+ public $setSubscriptionCausal = 'setSubscriptionCausal';
|
|
|
|
|
|
|
|
// public $selectedMonthList = [];
|
|
// public $selectedMonthList = [];
|
|
|
|
|
|
|
@@ -40,11 +43,14 @@ class Course extends Component
|
|
|
'course_duration_id' => 'required',
|
|
'course_duration_id' => 'required',
|
|
|
'course_frequency_id' => 'required',
|
|
'course_frequency_id' => 'required',
|
|
|
'course_level_id' => 'required',
|
|
'course_level_id' => 'required',
|
|
|
- 'causal_id' => 'required'
|
|
|
|
|
|
|
+ 'causal_id' => 'required',
|
|
|
|
|
+ 'sub_causal_id' => 'required',
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
protected $messages = [
|
|
protected $messages = [
|
|
|
- 'name.required' => 'Il nome è obbligatorio'
|
|
|
|
|
|
|
+ 'name.required' => 'Il nome è obbligatorio',
|
|
|
|
|
+ 'causal_id' => 'Campo obbligatorio',
|
|
|
|
|
+ 'sub_causal_id' => 'Campo obbligatorio',
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
public function resetFields(){
|
|
public function resetFields(){
|
|
@@ -55,10 +61,12 @@ class Course extends Component
|
|
|
$this->course_frequency_id = null;
|
|
$this->course_frequency_id = null;
|
|
|
$this->course_level_id = null;
|
|
$this->course_level_id = null;
|
|
|
$this->causal_id = null;
|
|
$this->causal_id = null;
|
|
|
|
|
+ $this->sub_causal_id = null;
|
|
|
$this->max_members = 0;
|
|
$this->max_members = 0;
|
|
|
$this->instructor = '';
|
|
$this->instructor = '';
|
|
|
$this->year = date("Y");
|
|
$this->year = date("Y");
|
|
|
$this->price = 0;
|
|
$this->price = 0;
|
|
|
|
|
+ $this->subscription_price = 0;
|
|
|
$this->date_from = null;
|
|
$this->date_from = null;
|
|
|
$this->date_to = null;
|
|
$this->date_to = null;
|
|
|
$this->months = array();
|
|
$this->months = array();
|
|
@@ -100,6 +108,7 @@ class Course extends Component
|
|
|
$this->resetFields();
|
|
$this->resetFields();
|
|
|
$this->add = true;
|
|
$this->add = true;
|
|
|
$this->update = false;
|
|
$this->update = false;
|
|
|
|
|
+ $this->emit('setEdit', true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -125,16 +134,19 @@ class Course extends Component
|
|
|
'date_from' => $this->date_from,
|
|
'date_from' => $this->date_from,
|
|
|
'date_to' => $this->date_to,
|
|
'date_to' => $this->date_to,
|
|
|
'causal_id' => $this->causal_id,
|
|
'causal_id' => $this->causal_id,
|
|
|
|
|
+ 'sub_causal_id' => $this->sub_causal_id,
|
|
|
'max_members' => $this->max_members,
|
|
'max_members' => $this->max_members,
|
|
|
'instructor' => $this->instructor,
|
|
'instructor' => $this->instructor,
|
|
|
'year' => $this->year,
|
|
'year' => $this->year,
|
|
|
'price' => currencyToDouble($this->price),
|
|
'price' => currencyToDouble($this->price),
|
|
|
|
|
+ 'subscription_price' => currencyToDouble($this->subscription_price),
|
|
|
'months' => json_encode($this->months),
|
|
'months' => json_encode($this->months),
|
|
|
'enabled' => $this->enabled
|
|
'enabled' => $this->enabled
|
|
|
]);
|
|
]);
|
|
|
session()->flash('success','Corso creato');
|
|
session()->flash('success','Corso creato');
|
|
|
$this->resetFields();
|
|
$this->resetFields();
|
|
|
$this->add = false;
|
|
$this->add = false;
|
|
|
|
|
+ $this->emit('setEdit', false);
|
|
|
} catch (\Exception $ex) {
|
|
} catch (\Exception $ex) {
|
|
|
session()->flash('error','Errore (' . $ex->getMessage() . ')');
|
|
session()->flash('error','Errore (' . $ex->getMessage() . ')');
|
|
|
}
|
|
}
|
|
@@ -156,15 +168,18 @@ class Course extends Component
|
|
|
$this->date_from = $course->date_from;
|
|
$this->date_from = $course->date_from;
|
|
|
$this->date_to = $course->date_to;
|
|
$this->date_to = $course->date_to;
|
|
|
$this->causal_id = $course->causal_id;
|
|
$this->causal_id = $course->causal_id;
|
|
|
|
|
+ $this->sub_causal_id = $course->sub_causal_id;
|
|
|
$this->max_members = $course->max_members;
|
|
$this->max_members = $course->max_members;
|
|
|
$this->instructor = $course->instructor;
|
|
$this->instructor = $course->instructor;
|
|
|
$this->year = $course->year;
|
|
$this->year = $course->year;
|
|
|
$this->price = formatPrice($course->price);
|
|
$this->price = formatPrice($course->price);
|
|
|
|
|
+ $this->subscription_price = formatPrice($course->subscription_price);
|
|
|
$this->months = json_decode($course->months);
|
|
$this->months = json_decode($course->months);
|
|
|
$this->dataId = $course->id;
|
|
$this->dataId = $course->id;
|
|
|
$this->update = true;
|
|
$this->update = true;
|
|
|
$this->add = false;
|
|
$this->add = false;
|
|
|
}
|
|
}
|
|
|
|
|
+ $this->emit('setEdit', true);
|
|
|
} catch (\Exception $ex) {
|
|
} catch (\Exception $ex) {
|
|
|
session()->flash('error','Errore (' . $ex->getMessage() . ')');
|
|
session()->flash('error','Errore (' . $ex->getMessage() . ')');
|
|
|
}
|
|
}
|
|
@@ -184,16 +199,19 @@ class Course extends Component
|
|
|
'date_from' => $this->date_from,
|
|
'date_from' => $this->date_from,
|
|
|
'date_to' => $this->date_to,
|
|
'date_to' => $this->date_to,
|
|
|
'causal_id' => $this->causal_id,
|
|
'causal_id' => $this->causal_id,
|
|
|
|
|
+ 'sub_causal_id' => $this->sub_causal_id,
|
|
|
'max_members' => $this->max_members,
|
|
'max_members' => $this->max_members,
|
|
|
'instructor' => $this->instructor,
|
|
'instructor' => $this->instructor,
|
|
|
'year' => $this->year,
|
|
'year' => $this->year,
|
|
|
'price' => currencyToDouble($this->price),
|
|
'price' => currencyToDouble($this->price),
|
|
|
|
|
+ 'subscription_price' => currencyToDouble($this->subscription_price),
|
|
|
'months' => json_encode($this->months),
|
|
'months' => json_encode($this->months),
|
|
|
'enabled' => $this->enabled
|
|
'enabled' => $this->enabled
|
|
|
]);
|
|
]);
|
|
|
session()->flash('success','Corso aggiornato');
|
|
session()->flash('success','Corso aggiornato');
|
|
|
$this->resetFields();
|
|
$this->resetFields();
|
|
|
$this->update = false;
|
|
$this->update = false;
|
|
|
|
|
+ $this->emit('setEdit', false);
|
|
|
} catch (\Exception $ex) {
|
|
} catch (\Exception $ex) {
|
|
|
session()->flash('error','Errore (' . $ex->getMessage() . ')');
|
|
session()->flash('error','Errore (' . $ex->getMessage() . ')');
|
|
|
}
|
|
}
|
|
@@ -204,6 +222,7 @@ class Course extends Component
|
|
|
$this->add = false;
|
|
$this->add = false;
|
|
|
$this->update = false;
|
|
$this->update = false;
|
|
|
$this->resetFields();
|
|
$this->resetFields();
|
|
|
|
|
+ $this->emit('setEdit', false);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function delete($id)
|
|
public function delete($id)
|
|
@@ -221,4 +240,9 @@ class Course extends Component
|
|
|
$this->causal_id = $id;
|
|
$this->causal_id = $id;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function setSubscriptionCausal($id, $idx)
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->sub_causal_id = $id;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|