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
1313{
1414 use WithInfiniteScroll, WithTags;
1515
16+ public string $ viewMode = 'list ' ;
17+
1618 protected $ queryString = [
1719 'tag ' => ['except ' => '' ],
1820 'sortBy ' => ['except ' => 'recent ' ],
1921 ];
2022
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+
2135 public function validSort ($ sort ): bool
2236 {
2337 return in_array ($ sort , [
@@ -29,10 +43,11 @@ public function validSort($sort): bool
2943
3044 public function render (): View
3145 {
32- $ articles = Article::with ('tags ' )->published ()
46+ $ articles = Article::with ('tags ' )
47+ ->published ()
3348 ->notPinned ()
3449 ->orderByDesc ('sponsored_at ' )
35- ->orderByDesc ('submitted_at ' );
50+ ->orderByDesc ('published_at ' );
3651
3752 $ tags = Tag::whereHas ('articles ' , function ($ query ) {
3853 $ query ->published ();
Original file line number Diff line number Diff line change 99use App \Models \User ;
1010use App \Traits \WithArticleAttributes ;
1111use App \Traits \WithTagsAssociation ;
12+ use Illuminate \Contracts \View \View ;
1213use Illuminate \Support \Facades \Auth ;
14+ use Illuminate \Support \Str ;
1315use Livewire \Component ;
1416use Livewire \WithFileUploads ;
1517
@@ -24,15 +26,11 @@ public function mount()
2426 /** @var User $user */
2527 $ user = Auth::user ();
2628
29+ $ this ->published_at = now ()->toDateTimeLocalString ();
2730 $ this ->submitted_at = $ user ->hasAnyRole (['admin ' , 'moderator ' ]) ? now () : null ;
2831 $ this ->approved_at = $ user ->hasAnyRole (['admin ' , 'moderator ' ]) ? now () : null ;
2932 }
3033
31- public function onMarkdownUpdate (string $ content )
32- {
33- $ this ->body = $ content ;
34- }
35-
3634 public function submit ()
3735 {
3836 $ this ->submitted_at = now ();
@@ -83,7 +81,7 @@ public function store()
8381 $ this ->redirectRoute ('articles.show ' , $ article );
8482 }
8583
86- public function render ()
84+ public function render (): View
8785 {
8886 return view ('livewire.articles.create ' , [
8987 '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)
3838 $ this ->associateTags = $ this ->tags_selected = old ('tags ' , $ article ->tags ()->pluck ('id ' )->toArray ());
3939 }
4040
41- public function onMarkdownUpdate (string $ content )
42- {
43- $ this ->body = $ content ;
44- }
45-
4641 public function submit ()
4742 {
4843 $ this ->alreadySubmitted = $ this ->article ->submitted_at !== null ;
You can’t perform that action at this time.
0 commit comments