Files
eatvio-infra/app/Livewire/Profile/ShowDetailz.php

62 lines
1.6 KiB
PHP

<?php
namespace App\Livewire\Profile;
use App\Models\User;
use App\Models\UserDetailz;
use Illuminate\Http\RedirectResponse;
use Illuminate\View\View;
use Livewire\Component;
use Livewire\Features\SupportRedirects\Redirector;
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
{
return view('livewire.profile.show-detailz');
}
public function editAction(): Redirector|RedirectResponse
{
return redirect()->route('user_detailz.edit', $this->userDetailz->id);
}
public function updated(string $name, bool $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!');
}
}
}