update: normalize forums a little more

We already make most of these queries anyways, and we'll need these foriegn keys when implementing future forum features like 'catch up'.
This commit is contained in:
Roardom
2024-02-08 18:08:49 +00:00
parent b823ade1b3
commit 834d438281
24 changed files with 243 additions and 191 deletions
+3 -3
View File
@@ -23,7 +23,7 @@ class TopicSearch extends Component
use WithPagination;
public string $search = '';
public string $sortField = 'last_reply_at';
public string $sortField = 'last_post_created_at';
public string $sortDirection = 'desc';
public string $label = '';
public string $state = '';
@@ -35,7 +35,7 @@ class TopicSearch extends Component
*/
protected $queryString = [
'search' => ['except' => ''],
'sortField' => ['except' => 'last_reply_at'],
'sortField' => ['except' => 'last_post_created_at'],
'sortDirection' => ['except' => 'desc'],
'label' => ['except' => ''],
'state' => ['except' => ''],
@@ -75,7 +75,7 @@ class TopicSearch extends Component
{
return Topic::query()
->select('topics.*')
->with('user', 'user.group', 'latestPoster')
->with('user', 'user.group', 'latestPoster', 'forum')
->whereRelation('forumPermissions', [['show_forum', '=', 1], ['group_id', '=', auth()->user()->group_id]])
->when($this->search !== '', fn ($query) => $query->where('name', 'LIKE', '%'.$this->search.'%'))
->when($this->label !== '', fn ($query) => $query->where($this->label, '=', 1))