|
@@ -9,6 +9,7 @@ class Member extends Component
|
|
|
public $records, $first_name, $last_name, $status, $birth_city_id, $birth_province_id, $birth_nation_id, $birth_date, $gender, $fiscal_code, $address, $zip_code, $nation_id, $province_id, $city_id, $phone, $email, $enabled, $dataId, $update = false, $add = false;
|
|
public $records, $first_name, $last_name, $status, $birth_city_id, $birth_province_id, $birth_nation_id, $birth_date, $gender, $fiscal_code, $address, $zip_code, $nation_id, $province_id, $city_id, $phone, $email, $enabled, $dataId, $update = false, $add = false;
|
|
|
|
|
|
|
|
public $cards = array();
|
|
public $cards = array();
|
|
|
|
|
+ public $categories = array();
|
|
|
public $nations = array();
|
|
public $nations = array();
|
|
|
public $provinces = array();
|
|
public $provinces = array();
|
|
|
public $cities = array();
|
|
public $cities = array();
|
|
@@ -68,10 +69,28 @@ class Member extends Component
|
|
|
$this->certificate_status = 0;
|
|
$this->certificate_status = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function resetCategoryFields(){
|
|
|
|
|
+ $this->category_category_id = null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getCategories($records, $indentation)
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach($records as $record)
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->categories[] = array('id' => $record->id, 'name' => str_repeat(" -> ", $indentation) . $record->name);
|
|
|
|
|
+ if(count($record->childs))
|
|
|
|
|
+ $this->getCategories($record->childs, $indentation + 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function mount()
|
|
public function mount()
|
|
|
{
|
|
{
|
|
|
$this->cards = \App\Models\Card::select('id', 'name')->get();
|
|
$this->cards = \App\Models\Card::select('id', 'name')->get();
|
|
|
|
|
|
|
|
|
|
+ $this->categories = array();
|
|
|
|
|
+
|
|
|
|
|
+ $this->getCategories(\App\Models\Category::select('id', 'name')->where('parent_id', null)->get(), 0);
|
|
|
|
|
+
|
|
|
$this->nations = \App\Models\Nation::select('id', 'name')->get();
|
|
$this->nations = \App\Models\Nation::select('id', 'name')->get();
|
|
|
$this->provinces = array();
|
|
$this->provinces = array();
|
|
|
$this->cities = array();
|
|
$this->cities = array();
|
|
@@ -107,25 +126,26 @@ class Member extends Component
|
|
|
{
|
|
{
|
|
|
$this->records = \App\Models\Member::select('id', 'first_name', 'last_name', 'status', 'enabled')->get();
|
|
$this->records = \App\Models\Member::select('id', 'first_name', 'last_name', 'status', 'enabled')->get();
|
|
|
$this->loadMemberCards();
|
|
$this->loadMemberCards();
|
|
|
|
|
+ $this->loadMemberCategories();
|
|
|
return view('livewire.member');
|
|
return view('livewire.member');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function loadMemberCards()
|
|
public function loadMemberCards()
|
|
|
{
|
|
{
|
|
|
$this->member_cards = \App\Models\MemberCard::where('member_id', $this->dataId)->get();
|
|
$this->member_cards = \App\Models\MemberCard::where('member_id', $this->dataId)->get();
|
|
|
- return view('livewire.member');
|
|
|
|
|
|
|
+ // return view('livewire.member');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function loadMemberCategories()
|
|
public function loadMemberCategories()
|
|
|
{
|
|
{
|
|
|
$this->member_categories = \App\Models\MemberCategory::where('member_id', $this->dataId)->get();
|
|
$this->member_categories = \App\Models\MemberCategory::where('member_id', $this->dataId)->get();
|
|
|
- return view('livewire.member');
|
|
|
|
|
|
|
+ // return view('livewire.member');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function loadMemberCertificates()
|
|
public function loadMemberCertificates()
|
|
|
{
|
|
{
|
|
|
$this->member_certificates = \App\Models\MemberCertificate::where('member_id', $this->dataId)->get();
|
|
$this->member_certificates = \App\Models\MemberCertificate::where('member_id', $this->dataId)->get();
|
|
|
- return view('livewire.member');
|
|
|
|
|
|
|
+ // return view('livewire.member');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function add()
|
|
public function add()
|
|
@@ -431,5 +451,34 @@ class Member extends Component
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Gruppi di appartenenza
|
|
|
|
|
+
|
|
|
|
|
+ public function storeCategory()
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ $this->validate(['category_category_id' => 'required']);
|
|
|
|
|
+ try {
|
|
|
|
|
+ \App\Models\MemberCategory::create([
|
|
|
|
|
+ 'member_id' => $this->dataId,
|
|
|
|
|
+ 'category_id' => $this->category_category_id,
|
|
|
|
|
+ 'date' => \Carbon\Carbon::now()
|
|
|
|
|
+ ]);
|
|
|
|
|
+ session()->flash('success, Associazione creato');
|
|
|
|
|
+ $this->resetCategoryFields();
|
|
|
|
|
+ $this->addCard = false;
|
|
|
|
|
+ } catch (\Exception $ex) {
|
|
|
|
|
+ session()->flash('error','Errore in fase di salvataggio');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function deleteCategory($id)
|
|
|
|
|
+ {
|
|
|
|
|
+ try{
|
|
|
|
|
+ \App\Models\MemberCategory::find($id)->delete();
|
|
|
|
|
+ session()->flash('success',"Associazione eliminata");
|
|
|
|
|
+ }catch(\Exception $e){
|
|
|
|
|
+ session()->flash('error',"Errore");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|