forked from eatvio/eatvio-infra
48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\User;
|
|
|
|
/* use Livewire\Component; */
|
|
|
|
use App\Models\CircumferenceMeasure;
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use LivewireUI\Modal\ModalComponent;
|
|
use Illuminate\Contracts\View\Factory as ViewFactory;
|
|
use Illuminate\Contracts\View\View;
|
|
|
|
class AddCircumference extends ModalComponent
|
|
{
|
|
public User $user;
|
|
|
|
public int $chest_circumference = 0;
|
|
|
|
public int $waist_circumference = 0;
|
|
|
|
public int $hip_circumference = 0;
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->user = Auth::user();
|
|
}
|
|
|
|
public function render(): View|ViewFactory
|
|
{
|
|
return view('livewire.user.add-circumference');
|
|
}
|
|
|
|
public function add(): void
|
|
{
|
|
$newMeasure = CircumferenceMeasure::create([
|
|
'user_id' => $this->user->id,
|
|
'chest_circumference' => $this->chest_circumference,
|
|
'waist_circumference' => $this->waist_circumference,
|
|
'hip_circumference' => $this->hip_circumference,
|
|
]);
|
|
$newMeasure->save();
|
|
$this->reset(['chest_circumference', 'waist_circumference', 'hip_circumference']);
|
|
$this->dispatch('circumference-chart-updated')->to('profile.circumference-chart');
|
|
$this->closeModal();
|
|
}
|
|
}
|