Update source into github
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Livewire\Component;
|
||||
|
||||
class UserSettings extends Component
|
||||
{
|
||||
public bool $email_marketing;
|
||||
public bool $receive_deposit;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$user = auth('users')->user();
|
||||
|
||||
// Gán giá trị bool từ database tinyInteger
|
||||
$this->email_marketing = (bool) $user->email_marketing;
|
||||
$this->receive_deposit = (bool) $user->receive_deposit;
|
||||
}
|
||||
|
||||
public function updated($propertyName)
|
||||
{
|
||||
$user = auth('users')->user();
|
||||
|
||||
// Cập nhật database với giá trị int 0 hoặc 1
|
||||
$user->update([
|
||||
$propertyName => $this->$propertyName ? 1 : 0,
|
||||
]);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.user-settings', [
|
||||
'user' => auth('users')->user(), // Truyền user để hiển thị thông tin
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user