mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-19 00:22:15 +00:00
controller refactoring part 21
This commit is contained in:
@@ -1,34 +1,31 @@
|
||||
<?php
|
||||
namespace Domain\Folders\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Support\Demo\Actions\DemoService;
|
||||
use Domain\Folders\Actions\CreateFolderAction;
|
||||
use Domain\Folders\Requests\CreateFolderRequest;
|
||||
use Support\Demo\Actions\FakeCreateFolderAction;
|
||||
|
||||
class CreateFolderController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
public DemoService $demo
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new folder for authenticated master|editor user
|
||||
*/
|
||||
public function __invoke(
|
||||
CreateFolderRequest $request,
|
||||
CreateFolderAction $createFolder,
|
||||
): Response {
|
||||
FakeCreateFolderAction $fakeCreateFolder,
|
||||
): Response|array {
|
||||
|
||||
// If is demo, return fake folder
|
||||
if (is_demo_account('howdy@hi5ve.digital')) {
|
||||
return $this->demo->create_folder($request);
|
||||
if (is_demo_account(Auth::user()->email)) {
|
||||
return ($fakeCreateFolder)($request);
|
||||
}
|
||||
|
||||
$folder = ($createFolder)($request);
|
||||
|
||||
// Create new folder
|
||||
return response($folder, 201);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user