File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class Gallery extends Model
1616
1717 public function images ()
1818 {
19- return $ this ->hasMany ('SystemInc\LaravelAdmin\GalleryImage ' )->orderBy ('order_number ' );
19+ return $ this ->hasMany ('SystemInc\LaravelAdmin\GalleryImage ' )->orderBy ('order_number ' )-> with ( ' elements ' ) ;
2020 }
2121
2222 public function product ()
Original file line number Diff line number Diff line change @@ -36,6 +36,11 @@ public function getAllElements()
3636 return $ this ->hasMany (GalleryElement::class, 'image_id ' );
3737 }
3838
39+ public function elements ()
40+ {
41+ return $ this ->getAllElements ();
42+ }
43+
3944 public function gallery ()
4045 {
4146 return $ this ->belongsTo (Gallery::class);
Original file line number Diff line number Diff line change @@ -35,9 +35,9 @@ public function shop()
3535 public function page ($ page_query = null )
3636 {
3737 if (is_string ($ page_query )) {
38- return Page::where (['slug ' => $ page_query ])->first ();
38+ return Page::where (['slug ' => $ page_query ])->with ( ' elements ' )-> first ();
3939 } elseif (is_int ($ page_query )) {
40- return Page::where (['id ' => $ page_query ])->first ();
40+ return Page::where (['id ' => $ page_query ])->with ( ' elements ' )-> first ();
4141 }
4242
4343 return new Page ();
@@ -63,7 +63,7 @@ public function element($key)
6363 public function gallery ($ key = false )
6464 {
6565 if ($ key ) {
66- return Gallery::where (['key ' => $ key ])->first ();
66+ return Gallery::where (['key ' => $ key ])->with ( ' images ' )-> first ();
6767 }
6868
6969 return new Gallery ();
You can’t perform that action at this time.
0 commit comments