mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-19 00:22:15 +00:00
- Restriction UI warning
- create folder restriction - fixed UI bugs
This commit is contained in:
@@ -5,24 +5,35 @@ use Domain\Sharing\Models\Share;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Domain\Folders\Requests\CreateFolderRequest;
|
||||
use App\Users\Exceptions\InvalidUserActionException;
|
||||
|
||||
class CreateFolderAction
|
||||
{
|
||||
/**
|
||||
* Create new folder
|
||||
*
|
||||
* @throws InvalidUserActionException
|
||||
*/
|
||||
public function __invoke(
|
||||
CreateFolderRequest $request,
|
||||
?Share $shared = null,
|
||||
): Folder|array {
|
||||
// Get user model
|
||||
$user = $shared
|
||||
? $shared->user
|
||||
: Auth::user();
|
||||
|
||||
// Check if user can create folder
|
||||
if (! $user->canCreateFolder()) {
|
||||
throw new InvalidUserActionException();
|
||||
}
|
||||
|
||||
/*
|
||||
* check if exist parent team folder, if yes,
|
||||
* then get folder to detect whether it is team_folder
|
||||
* Check if exist parent team folder, if yes,
|
||||
* then get the latest parent folder to detect whether it is team_folder
|
||||
*/
|
||||
if ($request->has('parent_id')) {
|
||||
$isTeamFolder = Folder::find(
|
||||
$request->input('parent_id')
|
||||
)
|
||||
$isTeamFolder = Folder::find($request->input('parent_id'))
|
||||
->getLatestParent()
|
||||
->team_folder;
|
||||
}
|
||||
@@ -34,7 +45,7 @@ class CreateFolderAction
|
||||
'color' => $request->input('color') ?? null,
|
||||
'emoji' => $request->input('emoji') ?? null,
|
||||
'author' => $shared ? 'visitor' : 'user',
|
||||
'user_id' => $shared ? $shared->user_id : Auth::id(),
|
||||
'user_id' => $user->id,
|
||||
'team_folder' => $isTeamFolder ?? false,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user