����JFIF��x�x����'
| Server IP : 78.140.185.180  /  Your IP : 216.73.216.38 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/builderbox/././././././www/common/Workspaces/Actions/  | 
Upload File :  | 
<?php
namespace Common\Workspaces\Actions;
use Common\Workspaces\Workspace;
use Common\Workspaces\WorkspaceMember;
use const App\Providers\WORKSPACED_RESOURCES;
class RemoveMemberFromWorkspace
{
    public function execute(Workspace $workspace, int $userToBeRemoved)
    {
        // transfer workspace resources to owner
        if ($workspace->owner_id !== $userToBeRemoved) {
            foreach (WORKSPACED_RESOURCES as $model) {
                $baseName = class_basename($model);
                $namespace = "App\Workspaces\Transfer{$baseName}";
                if (class_exists($namespace)) {
                    app($namespace)->execute($workspace->id, $workspace->owner_id, $userToBeRemoved);
                } else {
                    app($model)
                        ->where('workspace_id', $workspace->id)
                        ->where('user_id', $userToBeRemoved)
                        ->update(['user_id' => $workspace->owner_id]);
                }
            }
        }
        app(WorkspaceMember::class)
            ->where('workspace_id', $workspace->id)
            ->where('user_id', $userToBeRemoved)
            ->delete();
    }
}