File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 11<?php
22
3+ declare (strict_types=1 );
4+
35namespace NotFound \Framework \Models ;
46
57use Illuminate \Database \Eloquent \Factories \HasFactory ;
@@ -33,10 +35,22 @@ class BaseModel extends Model
3335 */
3436 protected $ visible = ['' ];
3537
36- public function v ()
38+ /**
39+ * Fetch the cached values for this model
40+ * based on the CMS settings.
41+ *
42+ * As this is causes heavy use of resources we'll cache
43+ * the result for a week.
44+ */
45+ public function v (): AssetValues
3746 {
38- $ cacheKey = 'table_ ' .$ this ->table .'_ ' .$ this ->id .'_ ' .Lang::current ()->url .($ this ->updated_at ?? '' );
39- $ secondsToRemember = 7 * 24 * 60 * 60 ;
47+ $ updated = '' ;
48+ $ secondsToRemember = 3600 ;
49+ if (isset ($ this ->updated_at ) && $ this ->updated_at !== null ) {
50+ $ secondsToRemember = 7 * 24 * 60 * 60 ;
51+ $ updated = (string ) $ this ->updated_at ->getTimeStamp ();
52+ }
53+ $ cacheKey = 'table_ ' .$ this ->table .'_ ' .$ this ->id .'_ ' .Lang::current ()->url .$ updated ;
4054
4155 return Cache::remember ($ cacheKey , $ secondsToRemember , function () {
4256 $ tableService = new TableService (Table::whereTable ($ this ->table )->first (), Lang::current (), $ this ->id );
You can’t perform that action at this time.
0 commit comments