mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-22 01:38:49 -05:00
update: UNIT3D linting
- github action updated with new ruleset in pint.json - codebase linted with new ruleset - contributors can now run `./vendor/bin/pint` - action workflow will auto correct any lint issues upon commit/opened pull request
This commit is contained in:
@@ -60,9 +60,9 @@ class TopicController extends Controller
|
||||
|
||||
// Get all posts
|
||||
$posts = $topic->posts()->with(['user', 'user.group', 'user.topics', 'user.posts', 'topic', 'tips'])
|
||||
->withCount(['likes' => function (Builder $query) {
|
||||
->withCount(['likes' => function (Builder $query): void {
|
||||
$query->where('like', '=', 1);
|
||||
}, 'likes as dislikes_count' => function (Builder $query) {
|
||||
}, 'likes as dislikes_count' => function (Builder $query): void {
|
||||
$query->where('dislike', '=', 1);
|
||||
}])->paginate(25);
|
||||
|
||||
@@ -70,9 +70,9 @@ class TopicController extends Controller
|
||||
$firstPost = Post::with('tips')->where('topic_id', '=', $topic->id)->first();
|
||||
|
||||
// The user can post a topic here ?
|
||||
if (! $category->getPermission()->read_topic) {
|
||||
if ( ! $category->getPermission()->read_topic) {
|
||||
// Redirect him to the forum index
|
||||
return \to_route('forums.index')
|
||||
return to_route('forums.index')
|
||||
->withErrors('You Do Not Have Access To Read This Topic!');
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class TopicController extends Controller
|
||||
$topic->views++;
|
||||
$topic->save();
|
||||
|
||||
return \view('forum.topic', [
|
||||
return view('forum.topic', [
|
||||
'topic' => $topic,
|
||||
'forum' => $forum,
|
||||
'category' => $category,
|
||||
@@ -98,12 +98,12 @@ class TopicController extends Controller
|
||||
$category = Forum::findOrFail($id);
|
||||
|
||||
// The user has the right to create a topic here?
|
||||
if (! $category->getPermission()->start_topic) {
|
||||
return \to_route('forums.index')
|
||||
if ( ! $category->getPermission()->start_topic) {
|
||||
return to_route('forums.index')
|
||||
->withErrors('You Cannot Start A New Topic Here!');
|
||||
}
|
||||
|
||||
return \view('forum.new_topic', [
|
||||
return view('forum.new_topic', [
|
||||
'forum' => $forum,
|
||||
'category' => $category,
|
||||
'title' => $request->input('title'),
|
||||
@@ -120,8 +120,8 @@ class TopicController extends Controller
|
||||
$category = Forum::findOrFail($id);
|
||||
|
||||
// The user has the right to create a topic here?
|
||||
if (! $category->getPermission()->start_topic) {
|
||||
return \to_route('forums.index')
|
||||
if ( ! $category->getPermission()->start_topic) {
|
||||
return to_route('forums.index')
|
||||
->withErrors('You Cannot Start A New Topic Here!');
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ class TopicController extends Controller
|
||||
$topic->pinned = false;
|
||||
$topic->forum_id = $forum->id;
|
||||
|
||||
$v = \validator($topic->toArray(), [
|
||||
$v = validator($topic->toArray(), [
|
||||
'name' => 'required',
|
||||
'state' => 'required',
|
||||
'num_post' => '',
|
||||
@@ -151,7 +151,7 @@ class TopicController extends Controller
|
||||
]);
|
||||
|
||||
if ($v->fails()) {
|
||||
return \to_route('forums.index')
|
||||
return to_route('forums.index')
|
||||
->withErrors($v->errors());
|
||||
}
|
||||
|
||||
@@ -160,13 +160,13 @@ class TopicController extends Controller
|
||||
$post->content = $request->input('content');
|
||||
$post->user_id = $user->id;
|
||||
$post->topic_id = $topic->id;
|
||||
$v = \validator($post->toArray(), [
|
||||
$v = validator($post->toArray(), [
|
||||
'content' => 'required',
|
||||
'user_id' => 'required',
|
||||
'topic_id' => 'required',
|
||||
]);
|
||||
if ($v->fails()) {
|
||||
return \to_route('forums.index')
|
||||
return to_route('forums.index')
|
||||
->withErrors($v->errors());
|
||||
}
|
||||
|
||||
@@ -183,14 +183,14 @@ class TopicController extends Controller
|
||||
$forum->save();
|
||||
|
||||
// Post To ShoutBox
|
||||
$appurl = \config('app.url');
|
||||
$topicUrl = \sprintf('%s/forums/topics/%s', $appurl, $topic->id);
|
||||
$profileUrl = \sprintf('%s/users/%s', $appurl, $user->username);
|
||||
$appurl = config('app.url');
|
||||
$topicUrl = sprintf('%s/forums/topics/%s', $appurl, $topic->id);
|
||||
$profileUrl = sprintf('%s/users/%s', $appurl, $user->username);
|
||||
|
||||
if (\config('other.staff-forum-notify') && ($forum->id == \config('other.staff-forum-id') || $forum->parent_id == \config('other.staff-forum-id'))) {
|
||||
if (config('other.staff-forum-notify') && ($forum->id == config('other.staff-forum-id') || $forum->parent_id == config('other.staff-forum-id'))) {
|
||||
$forum->notifyStaffers($user, $topic);
|
||||
} else {
|
||||
$this->chatRepository->systemMessage(\sprintf('[url=%s]%s[/url] has created a new topic [url=%s]%s[/url]', $profileUrl, $user->username, $topicUrl, $topic->name));
|
||||
$this->chatRepository->systemMessage(sprintf('[url=%s]%s[/url] has created a new topic [url=%s]%s[/url]', $profileUrl, $user->username, $topicUrl, $topic->name));
|
||||
$forum->notifySubscribers($user, $topic);
|
||||
}
|
||||
|
||||
@@ -208,8 +208,8 @@ class TopicController extends Controller
|
||||
$user->addProgress(new UserMade800Posts(), 1);
|
||||
$user->addProgress(new UserMade900Posts(), 1);
|
||||
|
||||
return \to_route('forum_topic', ['id' => $topic->id])
|
||||
->withSuccess('Topic Created Successfully!');
|
||||
return to_route('forum_topic', ['id' => $topic->id])
|
||||
->withSuccess('Topic Created Successfully!');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,7 +220,7 @@ class TopicController extends Controller
|
||||
$topic = Topic::findOrFail($id);
|
||||
$categories = Forum::where('parent_id', '!=', 0)->get();
|
||||
|
||||
return \view('forum.edit_topic', ['topic' => $topic, 'categories' => $categories]);
|
||||
return view('forum.edit_topic', ['topic' => $topic, 'categories' => $categories]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,14 +231,14 @@ class TopicController extends Controller
|
||||
$user = $request->user();
|
||||
$topic = Topic::findOrFail($id);
|
||||
|
||||
\abort_unless($user->group->is_modo || $user->id === $topic->first_post_user_id, 403);
|
||||
abort_unless($user->group->is_modo || $user->id === $topic->first_post_user_id, 403);
|
||||
$name = $request->input('name');
|
||||
$forumId = $request->input('forum_id');
|
||||
$topic->name = $name;
|
||||
$topic->forum_id = $forumId;
|
||||
$topic->save();
|
||||
|
||||
return \to_route('forum_topic', ['id' => $topic->id])
|
||||
return to_route('forum_topic', ['id' => $topic->id])
|
||||
->withSuccess('Topic Successfully Edited');
|
||||
}
|
||||
|
||||
@@ -250,11 +250,11 @@ class TopicController extends Controller
|
||||
$user = $request->user();
|
||||
$topic = Topic::findOrFail($id);
|
||||
|
||||
\abort_unless($user->group->is_modo || $user->id === $topic->first_post_user_id, 403);
|
||||
abort_unless($user->group->is_modo || $user->id === $topic->first_post_user_id, 403);
|
||||
$topic->state = 'close';
|
||||
$topic->save();
|
||||
|
||||
return \to_route('forum_topic', ['id' => $topic->id])
|
||||
return to_route('forum_topic', ['id' => $topic->id])
|
||||
->withSuccess('This Topic Is Now Closed!');
|
||||
}
|
||||
|
||||
@@ -266,11 +266,11 @@ class TopicController extends Controller
|
||||
$user = $request->user();
|
||||
$topic = Topic::findOrFail($id);
|
||||
|
||||
\abort_unless($user->group->is_modo || $user->id === $topic->first_post_user_id, 403);
|
||||
abort_unless($user->group->is_modo || $user->id === $topic->first_post_user_id, 403);
|
||||
$topic->state = 'open';
|
||||
$topic->save();
|
||||
|
||||
return \to_route('forum_topic', ['id' => $topic->id])
|
||||
return to_route('forum_topic', ['id' => $topic->id])
|
||||
->withSuccess('This Topic Is Now Open!');
|
||||
}
|
||||
|
||||
@@ -284,12 +284,12 @@ class TopicController extends Controller
|
||||
$user = $request->user();
|
||||
$topic = Topic::findOrFail($id);
|
||||
|
||||
\abort_unless($user->group->is_modo || ($user->id === $topic->first_post_user_id && $topic->num_post <= 1 && $topic->created_at->greaterThan(now()->subDay())), 403);
|
||||
abort_unless($user->group->is_modo || ($user->id === $topic->first_post_user_id && $topic->num_post <= 1 && $topic->created_at->greaterThan(now()->subDay())), 403);
|
||||
$posts = $topic->posts();
|
||||
$posts->delete();
|
||||
$topic->delete();
|
||||
|
||||
return \to_route('forums.show', ['id' => $topic->forum->id])
|
||||
return to_route('forums.show', ['id' => $topic->forum->id])
|
||||
->withSuccess('This Topic Is Now Deleted!');
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ class TopicController extends Controller
|
||||
$topic->pinned = 1;
|
||||
$topic->save();
|
||||
|
||||
return \to_route('forum_topic', ['id' => $topic->id])
|
||||
return to_route('forum_topic', ['id' => $topic->id])
|
||||
->withSuccess('This Topic Is Now Pinned!');
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ class TopicController extends Controller
|
||||
$topic->pinned = 0;
|
||||
$topic->save();
|
||||
|
||||
return \to_route('forum_topic', ['id' => $topic->id])
|
||||
return to_route('forum_topic', ['id' => $topic->id])
|
||||
->withSuccess('This Topic Is Now Unpinned!');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user