lasthourcloud/app/Http/Livewire/Team/Member.php

35 lines
861 B
PHP
Raw Normal View History

2023-06-02 10:34:45 +00:00
<?php
namespace App\Http\Livewire\Team;
use App\Models\User;
2023-09-15 09:19:36 +00:00
use Illuminate\Support\Facades\Cache;
2023-06-02 10:34:45 +00:00
use Livewire\Component;
class Member extends Component
{
public User $member;
2023-06-09 13:55:21 +00:00
public function makeAdmin()
{
2023-08-22 15:44:49 +00:00
$this->member->teams()->updateExistingPivot(currentTeam()->id, ['role' => 'admin']);
2023-06-09 13:55:21 +00:00
$this->emit('reloadWindow');
}
2023-06-09 13:55:21 +00:00
public function makeReadonly()
{
2023-08-22 15:44:49 +00:00
$this->member->teams()->updateExistingPivot(currentTeam()->id, ['role' => 'member']);
2023-06-09 13:55:21 +00:00
$this->emit('reloadWindow');
}
2023-06-08 09:43:14 +00:00
public function remove()
2023-06-02 10:34:45 +00:00
{
2023-08-22 15:44:49 +00:00
$this->member->teams()->detach(currentTeam());
2023-09-15 09:19:36 +00:00
Cache::forget("team:{$this->member->id}");
Cache::remember('team:' . $this->member->id, 3600, function() {
return $this->member->teams()->first();
});
2023-06-08 09:43:14 +00:00
$this->emit('reloadWindow');
2023-06-02 10:34:45 +00:00
}
}