first commit
Some checks failed
Build / run (push) Has been cancelled

This commit is contained in:
maher
2025-10-29 11:42:25 +01:00
commit 703f50a09d
4595 changed files with 385164 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
<?php
namespace Common\Workspaces\Actions;
use Auth;
use Common\Workspaces\Workspace;
class CrupdateWorkspace
{
public function __construct(protected Workspace $workspace)
{
}
public function execute(
array $data,
Workspace|null $initialWorkspace = null
): Workspace {
if ($initialWorkspace) {
$workspace = $initialWorkspace;
} else {
$workspace = $this->workspace->newInstance([
'owner_id' => Auth::id(),
]);
}
$attributes = [
'name' => $data['name'],
];
$workspace->fill($attributes)->save();
if (!$initialWorkspace) {
$workspace
->members()
->create(['user_id' => Auth::id(), 'is_owner' => true]);
}
return $workspace;
}
}