forked from eatvio/eatvio-infra
53 lines
1.2 KiB
PHP
53 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Profile;
|
|
|
|
use App\Models\UserDetailz;
|
|
use Livewire\Component;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Str;
|
|
|
|
class DescriptionForm extends Component
|
|
{
|
|
public $description = "";
|
|
public $user;
|
|
|
|
public function mount()
|
|
{
|
|
$this->initDetailzIfNeeded();
|
|
$this->description = $this->user->detailz->additional_info ?? "";
|
|
}
|
|
|
|
public function updatedDescription($value)
|
|
{
|
|
$userDetailz = $this->user->detailz;
|
|
|
|
$userDetailz->additional_info = $value;
|
|
$userDetailz->save();
|
|
}
|
|
|
|
private function initDetailzIfNeeded()
|
|
{
|
|
$curUserDetailez = UserDetailz::firstOrNew(
|
|
['user_id'=> $this->user->id],
|
|
[
|
|
'about_alergy' => '',
|
|
'about_taking_pils' => '',
|
|
'about_sport_hobbies' => '',
|
|
'favorite_foods' => '',
|
|
'unfavorite_foods' => '',
|
|
'additional_info' => ''
|
|
]
|
|
);
|
|
|
|
if (is_null($curUserDetailez->id)) {
|
|
$curUserDetailez->save();
|
|
}
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.profile.description-form');
|
|
}
|
|
}
|