Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Http;
4
 
5
use Illuminate\Support\Str;
6
 
7
trait FileHelpers
8
{
9
    /**
10
     * The cache copy of the file's hash name.
11
     *
12
     * @var string
13
     */
14
    protected $hashName = null;
15
 
16
    /**
17
     * Get the fully qualified path to the file.
18
     *
19
     * @return string
20
     */
21
    public function path()
22
    {
23
        return $this->getRealPath();
24
    }
25
 
26
    /**
27
     * Get the file's extension.
28
     *
29
     * @return string
30
     */
31
    public function extension()
32
    {
33
        return $this->guessExtension();
34
    }
35
 
36
    /**
37
     * Get a filename for the file.
38
     *
39
     * @param  string|null  $path
40
     * @return string
41
     */
42
    public function hashName($path = null)
43
    {
44
        if ($path) {
45
            $path = rtrim($path, '/').'/';
46
        }
47
 
48
        $hash = $this->hashName ?: $this->hashName = Str::random(40);
49
 
50
        if ($extension = $this->guessExtension()) {
51
            $extension = '.'.$extension;
52
        }
53
 
54
        return $path.$hash.$extension;
55
    }
56
}