forked from eatvio/eatvio-infra
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Livewire\User;
|
|
|
|
/* use Livewire\Component; */
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use LivewireUI\Modal\ModalComponent;
|
|
use App\Models\CircumferenceMeasure;
|
|
|
|
class AddCircumference extends ModalComponent
|
|
{
|
|
public User $user;
|
|
public $chest_circumference = 0;
|
|
public $waist_circumference = 0;
|
|
public $hip_circumference = 0;
|
|
|
|
public function mount()
|
|
{
|
|
$this->user = Auth::user();
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.user.add-circumference');
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
$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->emitTo('profile.circumference-chart', 'circumference-chart-updated');
|
|
$this->closeModal();
|
|
}
|
|
}
|