• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

RonasIT / laravel-helpers / 15463936058

05 Jun 2025 09:48AM UTC coverage: 77.839% (+0.2%) from 77.591%
15463936058

Pull #202

github

web-flow
Merge db31ecfb3 into 829e475f7
Pull Request #202: feat: mysql driver for work with enums in migrations

13 of 13 new or added lines in 1 file covered. (100.0%)

25 existing lines in 2 files now uncovered.

1124 of 1444 relevant lines covered (77.84%)

12.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Traits/FilesUploadTrait.php
1
<?php
2

3
namespace RonasIT\Support\Traits;
4

5
use Illuminate\Http\UploadedFile;
6
use Illuminate\Support\Facades\Storage;
7

8
trait FilesUploadTrait
9
{
10
    protected function saveFile($fileName, $content): string
11
    {
12
        $preparedName = $this->generateName($fileName);
×
13

14
        Storage::put($preparedName, $content);
×
15

16
        return $preparedName;
×
17
    }
18

19
    protected function checkUploadedFile($path): bool
20
    {
21
        return Storage::exists($path);
×
22
    }
23

24
    protected function getFileForUploading($path)
25
    {
26
        return new UploadedFile($path, $this->generateName($path));
×
27
    }
28

29
    protected function clearUploadedFilesFolder()
30
    {
31
        $files = Storage::allFiles();
×
32

33
        foreach ($files as $file) {
×
34
            Storage::delete($file);
×
35
        }
36
    }
37

38
    protected function generateName($path): string
39
    {
40
        $name = basename($path);
×
41
        $explodedName = explode('.', $name);
×
42
        $extension = array_pop($explodedName);
×
43
        $hash = md5(uniqid());
×
44
        $timestamp = str_replace(['.', ' '], '_', microtime());
×
45

46
        return "{$timestamp}_{$hash}.{$extension}";
×
47
    }
48

49
    public function getFilePathFromUrl($url)
50
    {
51
        $explodedUrl = explode('/', $url);
×
52

53
        return last($explodedUrl);
×
54
    }
55
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc