mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-19 00:22:15 +00:00
controller refactoring part 5
This commit is contained in:
26
src/Domain/Folders/Actions/CreateFolderAction.php
Normal file
26
src/Domain/Folders/Actions/CreateFolderAction.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace Domain\Folders\Actions;
|
||||
|
||||
use Domain\Sharing\Models\Share;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CreateFolderAction
|
||||
{
|
||||
/**
|
||||
* Create new directory
|
||||
*/
|
||||
public function __invoke(
|
||||
$request,
|
||||
?Share $shared = null,
|
||||
): Folder | array {
|
||||
return Folder::create([
|
||||
'parent_id' => $request->parent_id,
|
||||
'name' => $request->name,
|
||||
'color' => $request->color ?? null,
|
||||
'emoji' => $request->emoji ?? null,
|
||||
'author' => $shared ? 'visitor' : 'user',
|
||||
'user_id' => $shared ? $shared->user_id : Auth::id(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user