Skip to content

Commit 49a33ac

Browse files
authored
Merge pull request #216 from systeminc/maki10-patch-1
Maki10 patch 1
2 parents 5c2a7c9 + 8e944d0 commit 49a33ac

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/Gallery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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()

src/GalleryImage.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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);

src/SLA.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
 (0)