Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 1478 | Revision 1480 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 1478 Revision 1479
Zeile 40... Zeile 40...
40
        public function manufacturer(): BelongsTo
40
        public function manufacturer(): BelongsTo
41
        {
41
        {
42
            return $this->belongsTo( Manufacturer::class );
42
            return $this->belongsTo( Manufacturer::class );
43
        }
43
        }
Zeile -... Zeile 44...
-
 
44
 
-
 
45
// On the Model class add the following method.
-
 
46
 
-
 
47
        public function resolveRouteBinding( $value, $field = null ): ?Model
-
 
48
        {
-
 
49
            $cacheName = "item_{$value}";
-
 
50
 
-
 
51
            if ( Cache::has( $cacheName ) )
-
 
52
            {
-
 
53
                return Cache::get( $cacheName );
-
 
54
            }
-
 
55
 
-
 
56
            $result = $this->where( 'slug', $value )->firstOrFail();
-
 
57
            Cache::put( $cacheName, $result, 3600 );
-
 
58
 
-
 
59
            return $result;
44
 
60
        }