Issues (176)

src/Middlewares/CreateDefaultFolder.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace UniSharp\LaravelFilemanager\Middlewares;
4
5
use Closure;
6
use UniSharp\LaravelFilemanager\Lfm;
7
use UniSharp\LaravelFilemanager\LfmPath;
8
9
class CreateDefaultFolder
10
{
11
    private $lfm;
12
    private $helper;
13
14
    public function __construct()
15
    {
16
        $this->lfm = app(LfmPath::class);
0 ignored issues
show
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

16
        $this->lfm = /** @scrutinizer ignore-call */ app(LfmPath::class);
Loading history...
17
        $this->helper = app(Lfm::class);
18
    }
19
20
    public function handle($request, Closure $next)
21
    {
22
        $this->checkDefaultFolderExists('user');
23
        $this->checkDefaultFolderExists('share');
24
25
        return $next($request);
26
    }
27
28
    private function checkDefaultFolderExists($type = 'share')
29
    {
30
        if (! $this->helper->allowFolderType($type)) {
31
            return;
32
        }
33
34
        $this->lfm->dir($this->helper->getRootFolder($type))->createFolder();
35
    }
36
}
37