Skip to content

Commit 5868100

Browse files
committed
First Commit
1 parent 2ef833d commit 5868100

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

src/Builders/ArticleBuilder.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace magutti\MaguttiBuilders\Builders;
4+
5+
class ArticleBuilder extends LaraCmsBuilder
6+
{
7+
/**
8+
* @return mixed
9+
*/
10+
public function menuItems(){
11+
return $this->published()->menu()
12+
->with(['parentPage' => function($query) {
13+
$query->published()->menu();
14+
}])
15+
->orderBy('sort','Asc');
16+
}
17+
18+
/**
19+
* @param $id
20+
* @return ArticleBuilder
21+
*/
22+
public function childrenMenu($id) {
23+
return $this->where('parent_id', $id)->where('top_menu', 1)->orderBy('sort', 'asc');
24+
}
25+
26+
/**
27+
* @param string $id
28+
* @return ArticleBuilder
29+
*/
30+
public function pageChildren($id = '') {
31+
return $this->where('parent_id', $id)->orderBy('sort', 'asc');
32+
}
33+
34+
public function top() {
35+
return $this->where('parent_id', 0);
36+
}
37+
38+
/**
39+
* @return ArticleBuilder
40+
*/
41+
public function menu() {
42+
return $this->where('top_menu', 1);
43+
}
44+
}

src/Builders/LaraCmsBuilder.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
namespace magutti\MaguttiBuilders\Builders;
3+
4+
5+
use Illuminate\Database\Eloquent\Builder;
6+
7+
/**
8+
* Class LaraCmsBuilder
9+
* @package App\maguttiCms\Builders
10+
*/
11+
class LaraCmsBuilder extends Builder
12+
{
13+
public function status($status){
14+
return $this->where('is_active',$status);
15+
}
16+
public function active(){
17+
return $this->status(1);
18+
}
19+
public function inactive(){
20+
return $this->where('is_active','!=',1)->orWhereNull('is_active');
21+
}
22+
public function published() {
23+
return $this->where('pub', 1);
24+
}
25+
}

src/Builders/UserBuilder.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace magutti\MaguttiBuilders\Builders;
4+
use Carbon\Carbon;
5+
6+
/**
7+
* Class UserBuilder
8+
* @package App\maguttiCms\Builders
9+
*/
10+
class UserBuilder extends LaraCmsBuilder
11+
{
12+
/**
13+
* @return mixed
14+
*/
15+
public function todayUser(){
16+
return $this->whereDate('created_at',Carbon::today()->toDateString());
17+
}
18+
19+
/**
20+
* @return mixed
21+
*/
22+
public function yesterdayUser(){
23+
return $this->whereDate('created_at',Carbon::yesterday()->toDateString());
24+
}
25+
}

0 commit comments

Comments
 (0)