forked from eatvio/eatvio-infra
62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Profile;
|
|
|
|
use App\Models\User;
|
|
use App\Models\UserDetailz;
|
|
use Illuminate\Contracts\View\Factory as ViewFactory;
|
|
use Illuminate\Contracts\View\View;
|
|
use Livewire\Component;
|
|
use Masmerise\Toaster\Toaster;
|
|
|
|
class ShowDetailz extends Component
|
|
{
|
|
public User $user;
|
|
|
|
public array $userDetailzAttributes;
|
|
|
|
public array $regFormKeys;
|
|
|
|
public UserDetailz $userDetailz;
|
|
|
|
public bool|int $publicity;
|
|
|
|
public bool|int $is_bedtime_fillable;
|
|
|
|
public bool|int $is_mood_fillable;
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->is_mood_fillable = $this->user->detailz->is_mood_fillable;
|
|
$this->is_bedtime_fillable = $this->user->detailz->is_bedtime_fillable;
|
|
$this->publicity = $this->user->is_public_profile;
|
|
}
|
|
|
|
public function render(): View|ViewFactory
|
|
{
|
|
return view('livewire.profile.show-detailz');
|
|
}
|
|
|
|
public function editAction(): void
|
|
{
|
|
//return redirect()->route('user_detailz.edit', $this->userDetailz->id);
|
|
$this->redirectRoute('user_detailz.edit', $this->userDetailz->id);
|
|
}
|
|
|
|
public function updated(string $name, mixed $value): void
|
|
{
|
|
if ($name === 'is_bedtime_fillable') {
|
|
$this->user->detailz->update(['is_bedtime_fillable' => $value]);
|
|
Toaster::info('Bedtime updated!');
|
|
}
|
|
if ($name === 'is_mood_fillable') {
|
|
$this->user->detailz->update(['is_mood_fillable' => $value]);
|
|
Toaster::info('Mood updated!');
|
|
}
|
|
if ($name === 'publicity') {
|
|
$this->user->update(['is_public_profile' => $value]);
|
|
Toaster::info('Publicity updated!');
|
|
}
|
|
}
|
|
}
|