Files
eatvio-infra/app/Livewire/Profile/ShowDetailz.php
2023-10-04 17:57:09 +03:00

52 lines
1.3 KiB
PHP

<?php
namespace App\Livewire\Profile;
use Livewire\Component;
use Masmerise\Toaster\Toaster;
class ShowDetailz extends Component
{
public $user;
public $userDetailzAttributes;
public $regFormKeys;
public $userDetailz;
public $publicity;
public $is_bedtime_fillable;
public $is_mood_fillable;
public function mount()
{
$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()
{
return view('livewire.profile.show-detailz');
}
public function editAction()
{
return redirect()->route('user_detailz.edit', $this->userDetailz->id);
}
public function updated($name, $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!');
}
}
}