File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -32,11 +32,16 @@ public function syncOriginal()
3232
3333 public static function fromModel (Model $ model )
3434 {
35- return (new static )
35+ $ asset = (new static )
3636 ->container ($ model ->container )
3737 ->path (Str::replace ('// ' , '/ ' , $ model ->folder .'/ ' .$ model ->basename ))
3838 ->hydrateMeta ($ model ->meta )
3939 ->syncOriginal ();
40+
41+ Blink::put ('eloquent-asset- ' .$ asset ->id (), $ model );
42+ Blink::put ($ asset ->metaCacheKey (), $ model ->meta );
43+
44+ return $ asset ;
4045 }
4146
4247 public function meta ($ key = null )
@@ -86,6 +91,10 @@ public function exists()
8691
8792 public function metaExists ()
8893 {
94+ if (Blink::has ($ this ->metaCacheKey ())) {
95+ return true ;
96+ }
97+
8998 return Blink::once ('eloquent-asset-meta-exists- ' .$ this ->id (), function () {
9099 return app ('statamic.eloquent.assets.model ' )::query ()
91100 ->where ([
@@ -131,6 +140,7 @@ public function writeMeta($meta)
131140
132141 self ::makeModelFromContract ($ this , $ meta )?->save();
133142
143+ Blink::put ($ this ->metaCacheKey (), $ meta );
134144 Blink::put ('eloquent-asset-meta-exists- ' .$ this ->id (), true );
135145 }
136146
You can’t perform that action at this time.
0 commit comments