mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
Replaces all Jetstream model trait functions and relations
This commit is contained in:
committed by
Constantin Graf
parent
5eb1a6a006
commit
734aab6353
@@ -173,7 +173,7 @@ class DeletionService
|
||||
$user->authCodes()->delete();
|
||||
|
||||
// Note: Since the deletion of the profile photo is not reversible via a database rollback this needs to be done last
|
||||
$user->deleteProfilePhoto();
|
||||
$this->userService->deleteProfilePhoto($user);
|
||||
|
||||
$user->delete();
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ class MemberService
|
||||
$isPlaceholder = $user->is_placeholder;
|
||||
|
||||
if (! $isPlaceholder && $user->current_team_id === $member->organization_id) {
|
||||
$user->currentTeam()->disassociate();
|
||||
$user->currentOrganization()->disassociate();
|
||||
$user->save();
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ class MemberService
|
||||
{
|
||||
$user = $member->user;
|
||||
if ($user->current_team_id === $member->organization_id) {
|
||||
$user->currentTeam()->disassociate();
|
||||
$user->currentOrganization()->disassociate();
|
||||
$user->save();
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ class PermissionStore
|
||||
public function userHas(Organization $organization, User $user, string $permission): bool
|
||||
{
|
||||
if (! isset($this->permissionCache[$user->getKey().'|'.$organization->getKey()])) {
|
||||
if (! $user->belongsToTeam($organization)) {
|
||||
if (! $user->isMemberOfOrganization($organization)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ class PermissionStore
|
||||
*/
|
||||
private function getPermissionsByUser(Organization $organization, User $user): array
|
||||
{
|
||||
if (! $user->belongsToTeam($organization)) {
|
||||
if (! $user->isMemberOfOrganization($organization)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ use App\Models\TimeEntry;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class UserService
|
||||
{
|
||||
@@ -61,7 +62,6 @@ class UserService
|
||||
$intervalFormat,
|
||||
$timeFormat,
|
||||
);
|
||||
$user->ownedTeams()->save($organization);
|
||||
}
|
||||
|
||||
return $user;
|
||||
@@ -103,13 +103,17 @@ class UserService
|
||||
true
|
||||
);
|
||||
|
||||
// Set the organization as the user's current organization
|
||||
$user->currentOrganization()->associate($organization);
|
||||
$user->save();
|
||||
$this->switchCurrentOrganization($user, $organization);
|
||||
|
||||
AfterCreateOrganization::dispatch($organization);
|
||||
}
|
||||
|
||||
public function switchCurrentOrganization(User $user, Organization $organization): void
|
||||
{
|
||||
$user->currentOrganization()->associate($organization);
|
||||
$user->save();
|
||||
}
|
||||
|
||||
public function getOrganizationNameForUserName(string $username): string
|
||||
{
|
||||
return explode(' ', $username, 2)[0]."'s Organization";
|
||||
@@ -157,4 +161,16 @@ class UserService
|
||||
$oldOwner->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteProfilePhoto(User $user): void
|
||||
{
|
||||
if ($user->profile_photo_path === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Storage::disk(config('filesystems.public'))->delete($user->profile_photo_path);
|
||||
|
||||
$user->profile_photo_path = null;
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user