File tree Expand file tree Collapse file tree 3 files changed +21
-13
lines changed
app/Http/Livewire/Articles Expand file tree Collapse file tree 3 files changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -13,11 +13,25 @@ class Browse extends Component
13
13
{
14
14
use WithInfiniteScroll, WithTags;
15
15
16
+ public string $ viewMode = 'list ' ;
17
+
16
18
protected $ queryString = [
17
19
'tag ' => ['except ' => '' ],
18
20
'sortBy ' => ['except ' => 'recent ' ],
19
21
];
20
22
23
+ public function mount ()
24
+ {
25
+ $ this ->viewMode = session ('viewMode ' , $ this ->viewMode );
26
+ }
27
+
28
+ public function changeViewMode ($ mode )
29
+ {
30
+ session ()->put ('viewMode ' , $ mode );
31
+
32
+ $ this ->viewMode = $ mode ;
33
+ }
34
+
21
35
public function validSort ($ sort ): bool
22
36
{
23
37
return in_array ($ sort , [
@@ -29,10 +43,11 @@ public function validSort($sort): bool
29
43
30
44
public function render (): View
31
45
{
32
- $ articles = Article::with ('tags ' )->published ()
46
+ $ articles = Article::with ('tags ' )
47
+ ->published ()
33
48
->notPinned ()
34
49
->orderByDesc ('sponsored_at ' )
35
- ->orderByDesc ('submitted_at ' );
50
+ ->orderByDesc ('published_at ' );
36
51
37
52
$ tags = Tag::whereHas ('articles ' , function ($ query ) {
38
53
$ query ->published ();
Original file line number Diff line number Diff line change 9
9
use App \Models \User ;
10
10
use App \Traits \WithArticleAttributes ;
11
11
use App \Traits \WithTagsAssociation ;
12
+ use Illuminate \Contracts \View \View ;
12
13
use Illuminate \Support \Facades \Auth ;
14
+ use Illuminate \Support \Str ;
13
15
use Livewire \Component ;
14
16
use Livewire \WithFileUploads ;
15
17
@@ -24,15 +26,11 @@ public function mount()
24
26
/** @var User $user */
25
27
$ user = Auth::user ();
26
28
29
+ $ this ->published_at = now ()->toDateTimeLocalString ();
27
30
$ this ->submitted_at = $ user ->hasAnyRole (['admin ' , 'moderator ' ]) ? now () : null ;
28
31
$ this ->approved_at = $ user ->hasAnyRole (['admin ' , 'moderator ' ]) ? now () : null ;
29
32
}
30
33
31
- public function onMarkdownUpdate (string $ content )
32
- {
33
- $ this ->body = $ content ;
34
- }
35
-
36
34
public function submit ()
37
35
{
38
36
$ this ->submitted_at = now ();
@@ -83,7 +81,7 @@ public function store()
83
81
$ this ->redirectRoute ('articles.show ' , $ article );
84
82
}
85
83
86
- public function render ()
84
+ public function render (): View
87
85
{
88
86
return view ('livewire.articles.create ' , [
89
87
'tags ' => Tag::whereJsonContains ('concerns ' , ['post ' ])->get (),
Original file line number Diff line number Diff line change @@ -38,11 +38,6 @@ public function mount(Article $article)
38
38
$ this ->associateTags = $ this ->tags_selected = old ('tags ' , $ article ->tags ()->pluck ('id ' )->toArray ());
39
39
}
40
40
41
- public function onMarkdownUpdate (string $ content )
42
- {
43
- $ this ->body = $ content ;
44
- }
45
-
46
41
public function submit ()
47
42
{
48
43
$ this ->alreadySubmitted = $ this ->article ->submitted_at !== null ;
You can’t perform that action at this time.
0 commit comments