mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-28 14:31:10 -05:00
Merge branch 'Forums-Addons' of https://github.com/HDInnovations/UNIT3D into Forums-Addons
Need This Done.
This commit is contained in:
@@ -48,10 +48,9 @@ class BonTransactions extends Model
|
||||
|
||||
public function senderObj()
|
||||
{
|
||||
return $this->belongsTo(User::class,'sender','id')->withDefault([
|
||||
return $this->belongsTo(User::class, 'sender', 'id')->withDefault([
|
||||
'username' => 'System',
|
||||
'id' => '1',
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ class Comment extends Model
|
||||
*/
|
||||
public function request()
|
||||
{
|
||||
return $this->belongsTo(TorrentRequest::class,'requests_id','id');
|
||||
return $this->belongsTo(TorrentRequest::class, 'requests_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+8
-5
@@ -38,6 +38,7 @@ class Forum extends Model
|
||||
if (is_array($children)) {
|
||||
return $this->hasMany(Topic::class)->orWhereIn('topics.forum_id', $children);
|
||||
}
|
||||
|
||||
return $this->hasMany(Topic::class);
|
||||
}
|
||||
|
||||
@@ -48,7 +49,7 @@ class Forum extends Model
|
||||
*/
|
||||
public function forums()
|
||||
{
|
||||
return $this->hasMany(Forum::class,'parent_id','id');
|
||||
return $this->hasMany(self::class, 'parent_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,11 +59,13 @@ class Forum extends Model
|
||||
*/
|
||||
public function subscription_topics()
|
||||
{
|
||||
if(auth()->user()){
|
||||
if (auth()->user()) {
|
||||
$subscriptions = auth()->user()->subscriptions->where('topic_id', '>', '0')->pluck('topic_id')->toArray();
|
||||
return $this->hasMany(Topic::class,'id','topic_id')->whereIn('topics.id',$subscriptions);
|
||||
|
||||
return $this->hasMany(Topic::class, 'id', 'topic_id')->whereIn('topics.id', $subscriptions);
|
||||
}
|
||||
return $this->hasMany(Topic::class,'id','topic_id');
|
||||
|
||||
return $this->hasMany(Topic::class, 'id', 'topic_id');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +75,7 @@ class Forum extends Model
|
||||
*/
|
||||
public function subscriptions()
|
||||
{
|
||||
return $this->hasMany(Subscription::class,'forum_id','id');
|
||||
return $this->hasMany(Subscription::class, 'forum_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ use App\Follow;
|
||||
use App\Torrent;
|
||||
use App\PrivateMessage;
|
||||
use App\Bots\IRCAnnounceBot;
|
||||
use App\Notifications\NewUpload;
|
||||
use App\Achievements\UserMadeUpload;
|
||||
use App\Achievements\UserMade25Uploads;
|
||||
use App\Achievements\UserMade50Uploads;
|
||||
@@ -31,7 +32,6 @@ use App\Achievements\UserMade600Uploads;
|
||||
use App\Achievements\UserMade700Uploads;
|
||||
use App\Achievements\UserMade800Uploads;
|
||||
use App\Achievements\UserMade900Uploads;
|
||||
use App\Notifications\NewUpload;
|
||||
|
||||
class TorrentHelper
|
||||
{
|
||||
@@ -64,7 +64,7 @@ class TorrentHelper
|
||||
$followers = Follow::where('target_id', '=', $torrent->user_id)->get();
|
||||
if ($followers) {
|
||||
foreach ($followers as $follower) {
|
||||
User::find($follower->user_id)->notify(new NewUpload('follower',$torrent));
|
||||
User::find($follower->user_id)->notify(new NewUpload('follower', $torrent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,20 +13,20 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\User;
|
||||
use App\Post;
|
||||
use App\User;
|
||||
use App\Torrent;
|
||||
use Carbon\Carbon;
|
||||
use App\BonExchange;
|
||||
use App\PrivateMessage;
|
||||
use App\BonTransactions;
|
||||
use App\PersonalFreeleech;
|
||||
use App\Notifications\NewPostTip;
|
||||
use App\Notifications\NewUploadTip;
|
||||
use App\Notifications\NewBon;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Notifications\NewBon;
|
||||
use App\Notifications\NewPostTip;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Notifications\NewUploadTip;
|
||||
use App\Repositories\ChatRepository;
|
||||
|
||||
class BonusController extends Controller
|
||||
@@ -264,7 +264,7 @@ class BonusController extends Controller
|
||||
$transaction->torrent_id = null;
|
||||
$transaction->save();
|
||||
|
||||
if($user->id != $recipient->id) {
|
||||
if ($user->id != $recipient->id) {
|
||||
$recipient->notify(new NewBon('gift', $user->username, $transaction));
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ class BonusController extends Controller
|
||||
$transaction->torrent_id = $torrent->id;
|
||||
$transaction->save();
|
||||
|
||||
$uploader->notify(new NewUploadTip('torrent',$user->username,$torrent));
|
||||
$uploader->notify(new NewUploadTip('torrent', $user->username, $torrent));
|
||||
|
||||
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])
|
||||
->with($this->toastr->success('Your Tip Was Successfully Applied!', 'Yay!', ['options']));
|
||||
@@ -346,7 +346,7 @@ class BonusController extends Controller
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if($request->has('post') && $request->input('post') > 0) {
|
||||
if ($request->has('post') && $request->input('post') > 0) {
|
||||
$p = (int) $request->input('post');
|
||||
$post = Post::with('topic')->findOrFail($p);
|
||||
$poster = User::where('id', '=', $post->user_id)->firstOrFail();
|
||||
@@ -383,7 +383,7 @@ class BonusController extends Controller
|
||||
$transaction->post_id = $post->id;
|
||||
$transaction->save();
|
||||
|
||||
$poster->notify(new NewPostTip($user->username,$post));
|
||||
$poster->notify(new NewPostTip($user->username, $post));
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $post->topic->slug, 'id' => $post->topic->id])
|
||||
->with($this->toastr->success('Your Tip Was Successfully Applied!', 'Yay!', ['options']));
|
||||
|
||||
@@ -17,11 +17,10 @@ use App\User;
|
||||
use App\Article;
|
||||
use App\Comment;
|
||||
use App\Torrent;
|
||||
use App\PrivateMessage;
|
||||
use App\TorrentRequest;
|
||||
use App\Notifications\NewComment;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Notifications\NewComment;
|
||||
use App\Repositories\ChatRepository;
|
||||
use App\Achievements\UserMadeComment;
|
||||
use App\Achievements\UserMade50Comments;
|
||||
@@ -127,8 +126,11 @@ class CommentController extends Controller
|
||||
$comment
|
||||
);
|
||||
} else {
|
||||
if($comment->anon) { $sender="Anonymous"; }
|
||||
else { $sender=$user->username; }
|
||||
if ($comment->anon) {
|
||||
$sender = 'Anonymous';
|
||||
} else {
|
||||
$sender = $user->username;
|
||||
}
|
||||
$this->tag->messageTaggedCommentUsers(
|
||||
'article',
|
||||
$request->input('content'),
|
||||
@@ -197,7 +199,7 @@ class CommentController extends Controller
|
||||
|
||||
//Notification
|
||||
if ($user->id != $torrent->user_id) {
|
||||
$torrent->notifyUploader('comment',$comment);
|
||||
$torrent->notifyUploader('comment', $comment);
|
||||
}
|
||||
|
||||
$torrent_url = hrefTorrent($torrent);
|
||||
@@ -215,7 +217,6 @@ class CommentController extends Controller
|
||||
}
|
||||
|
||||
if ($this->tag->hasTags($request->input('content'))) {
|
||||
|
||||
if ($this->tag->contains($request->input('content'), '@here') && $user->group->is_modo) {
|
||||
$users = collect([]);
|
||||
|
||||
@@ -229,8 +230,11 @@ class CommentController extends Controller
|
||||
$comment
|
||||
);
|
||||
} else {
|
||||
if($comment->anon) { $sender="Anonymous"; }
|
||||
else { $sender=$user->username; }
|
||||
if ($comment->anon) {
|
||||
$sender = 'Anonymous';
|
||||
} else {
|
||||
$sender = $user->username;
|
||||
}
|
||||
$this->tag->messageTaggedCommentUsers(
|
||||
'torrent',
|
||||
$request->input('content'),
|
||||
@@ -313,7 +317,7 @@ class CommentController extends Controller
|
||||
|
||||
//Notification
|
||||
if ($user->id != $tr->user_id) {
|
||||
$tr->notifyRequester('comment',$comment);
|
||||
$tr->notifyRequester('comment', $comment);
|
||||
}
|
||||
|
||||
if ($this->tag->hasTags($request->input('content'))) {
|
||||
@@ -332,8 +336,11 @@ class CommentController extends Controller
|
||||
$comment
|
||||
);
|
||||
} else {
|
||||
if($comment->anon) { $sender="Anonymous"; }
|
||||
else { $sender=$user->username; }
|
||||
if ($comment->anon) {
|
||||
$sender = 'Anonymous';
|
||||
} else {
|
||||
$sender = $user->username;
|
||||
}
|
||||
$this->tag->messageTaggedCommentUsers(
|
||||
'req',
|
||||
$request->input('content'),
|
||||
@@ -417,7 +424,7 @@ class CommentController extends Controller
|
||||
|
||||
//Notification
|
||||
if ($user->id != $torrent->user_id) {
|
||||
User::find($torrent->user_id)->notify(new NewComment('torrent',$comment));
|
||||
User::find($torrent->user_id)->notify(new NewComment('torrent', $comment));
|
||||
}
|
||||
|
||||
// Auto Shout
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\User;
|
||||
use App\Follow;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use App\Notifications\NewFollow;
|
||||
use App\Notifications\NewUnfollow;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
|
||||
class FollowController extends Controller
|
||||
{
|
||||
@@ -54,7 +54,7 @@ class FollowController extends Controller
|
||||
$follow->target_id = $user->id;
|
||||
$follow->save();
|
||||
|
||||
$user->notify(new NewFollow('user', auth()->user()->username,$follow));
|
||||
$user->notify(new NewFollow('user', auth()->user()->username, $follow));
|
||||
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->with($this->toastr->success('You are now following '.$user->username, 'Yay!', ['options']));
|
||||
|
||||
@@ -74,103 +74,107 @@ class ForumController extends Controller
|
||||
*/
|
||||
public function search(Request $request)
|
||||
{
|
||||
|
||||
$categories = Forum::oldest('position')->get();
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
$pests = $user->group->permissions->where('show_forum','=',0)->pluck('forum_id')->toArray();
|
||||
if(!is_array($pests)) { $pests=[]; }
|
||||
|
||||
$topic_neos = $user->subscriptions->pluck('topic_id')->toArray();
|
||||
if(!is_array($topic_neos)) { $topic_neos=[]; }
|
||||
|
||||
$forum_neos = $user->subscriptions->pluck('forum_id')->toArray();
|
||||
if(!is_array($forum_neos)) { $forum_neos=[]; }
|
||||
|
||||
if($request->has('body') && $request->input('body') != '') {
|
||||
$logger = "forum.results_posts";
|
||||
$result = Post::selectRaw('posts.id as id,posts.*')->with(['topic','user'])->leftJoin('topics','posts.topic_id','=','topics.id')->whereNotIn('topics.forum_id',$pests);
|
||||
$pests = $user->group->permissions->where('show_forum', '=', 0)->pluck('forum_id')->toArray();
|
||||
if (! is_array($pests)) {
|
||||
$pests = [];
|
||||
}
|
||||
|
||||
if(!isset($logger)) {
|
||||
$logger = "forum.results_topics";
|
||||
$topic_neos = $user->subscriptions->pluck('topic_id')->toArray();
|
||||
if (! is_array($topic_neos)) {
|
||||
$topic_neos = [];
|
||||
}
|
||||
|
||||
$forum_neos = $user->subscriptions->pluck('forum_id')->toArray();
|
||||
if (! is_array($forum_neos)) {
|
||||
$forum_neos = [];
|
||||
}
|
||||
|
||||
if ($request->has('body') && $request->input('body') != '') {
|
||||
$logger = 'forum.results_posts';
|
||||
$result = Post::selectRaw('posts.id as id,posts.*')->with(['topic', 'user'])->leftJoin('topics', 'posts.topic_id', '=', 'topics.id')->whereNotIn('topics.forum_id', $pests);
|
||||
}
|
||||
|
||||
if (! isset($logger)) {
|
||||
$logger = 'forum.results_topics';
|
||||
$result = Topic::whereNotIn('topics.forum_id', $pests);
|
||||
}
|
||||
|
||||
if($request->has('body') && $request->input('body') != '') {
|
||||
$result->where([['posts.content', 'like', '%' . $request->input('body') . '%']]);
|
||||
if ($request->has('body') && $request->input('body') != '') {
|
||||
$result->where([['posts.content', 'like', '%'.$request->input('body').'%']]);
|
||||
}
|
||||
if($request->has('name')) {
|
||||
$result->where([['topics.name', 'like', '%' . $request->input('name') . '%']]);
|
||||
if ($request->has('name')) {
|
||||
$result->where([['topics.name', 'like', '%'.$request->input('name').'%']]);
|
||||
}
|
||||
if($request->has('subscribed') && $request->input('subscribed') == 1) {
|
||||
if ($request->has('subscribed') && $request->input('subscribed') == 1) {
|
||||
$result->where(function ($query) use ($topic_neos,$forum_neos) {
|
||||
$query->whereIn('topics.id',$topic_neos)->orWhereIn('topics.forum_id',$forum_neos);
|
||||
$query->whereIn('topics.id', $topic_neos)->orWhereIn('topics.forum_id', $forum_neos);
|
||||
});
|
||||
} else if ($request->has('notsubscribed') && $request->input('notsubscribed') == 1) {
|
||||
$result->whereNotIn('topics.id',$neos);
|
||||
} elseif ($request->has('notsubscribed') && $request->input('notsubscribed') == 1) {
|
||||
$result->whereNotIn('topics.id', $neos);
|
||||
}
|
||||
|
||||
if($request->has('implemented') && $request->input('implemented') == 1) {
|
||||
$result->where('topics.implemented','=',1);
|
||||
if ($request->has('implemented') && $request->input('implemented') == 1) {
|
||||
$result->where('topics.implemented', '=', 1);
|
||||
}
|
||||
if($request->has('approved') && $request->input('approved') == 1) {
|
||||
$result->where('topics.approved','=',1);
|
||||
if ($request->has('approved') && $request->input('approved') == 1) {
|
||||
$result->where('topics.approved', '=', 1);
|
||||
}
|
||||
if($request->has('denied') && $request->input('denied') == 1) {
|
||||
$result->where('topics.denied','=',1);
|
||||
if ($request->has('denied') && $request->input('denied') == 1) {
|
||||
$result->where('topics.denied', '=', 1);
|
||||
}
|
||||
if($request->has('solved') && $request->input('solved') == 1) {
|
||||
$result->where('topics.solved','=',1);
|
||||
if ($request->has('solved') && $request->input('solved') == 1) {
|
||||
$result->where('topics.solved', '=', 1);
|
||||
}
|
||||
if($request->has('invalid') && $request->input('invalid') == 1) {
|
||||
$result->where('topics.invalid','=',1);
|
||||
if ($request->has('invalid') && $request->input('invalid') == 1) {
|
||||
$result->where('topics.invalid', '=', 1);
|
||||
}
|
||||
if($request->has('bug') && $request->input('bug') == 1) {
|
||||
$result->where('topics.bug','=',1);
|
||||
if ($request->has('bug') && $request->input('bug') == 1) {
|
||||
$result->where('topics.bug', '=', 1);
|
||||
}
|
||||
if($request->has('suggestion') && $request->input('suggestion') == 1) {
|
||||
$result->where('topics.suggestion','=',1);
|
||||
if ($request->has('suggestion') && $request->input('suggestion') == 1) {
|
||||
$result->where('topics.suggestion', '=', 1);
|
||||
}
|
||||
|
||||
if($request->has('closed') && $request->input('closed') == 1) {
|
||||
$result->where('topics.state','=','close');
|
||||
if ($request->has('closed') && $request->input('closed') == 1) {
|
||||
$result->where('topics.state', '=', 'close');
|
||||
}
|
||||
if($request->has('open') && $request->input('open') == 1) {
|
||||
$result->where('topics.state','=','open');
|
||||
if ($request->has('open') && $request->input('open') == 1) {
|
||||
$result->where('topics.state', '=', 'open');
|
||||
}
|
||||
|
||||
if($request->has('category')) {
|
||||
if ($request->has('category')) {
|
||||
$category = (int) $request->input('category');
|
||||
if($category > 0 && $category < 99999999999) {
|
||||
$children = Forum::where('parent_id','=',$category)->get()->toArray();
|
||||
if(is_array($children)) {
|
||||
if ($category > 0 && $category < 99999999999) {
|
||||
$children = Forum::where('parent_id', '=', $category)->get()->toArray();
|
||||
if (is_array($children)) {
|
||||
$result->where(function ($query) use ($category,$children) {
|
||||
$query->where('topics.forum_id','=',$category)->orWhereIn('topics.forum_id',$children);
|
||||
$query->where('topics.forum_id', '=', $category)->orWhereIn('topics.forum_id', $children);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
$direction = 2;
|
||||
$order = "desc";
|
||||
if($request->has('direction') && $request->input('direction') == 1) {
|
||||
$order = 'desc';
|
||||
if ($request->has('direction') && $request->input('direction') == 1) {
|
||||
$direction = 1;
|
||||
$order = "asc";
|
||||
$order = 'asc';
|
||||
}
|
||||
if($request->has('body') && $request->input('body') != '') {
|
||||
$sorting = "posts.created_at";
|
||||
if($request->has('sorting') && $request->input('sorting') == 'updated_at') {
|
||||
$sorting = "posts.updated_at";
|
||||
if ($request->has('body') && $request->input('body') != '') {
|
||||
$sorting = 'posts.created_at';
|
||||
if ($request->has('sorting') && $request->input('sorting') == 'updated_at') {
|
||||
$sorting = 'posts.updated_at';
|
||||
}
|
||||
$results = $result->orderBy($sorting,$direction)->paginate(25);
|
||||
}
|
||||
else {
|
||||
$sorting = "topics.created_at";
|
||||
if($request->has('sorting') && $request->input('sorting') == 'updated_at') {
|
||||
$sorting = "topics.updated_at";
|
||||
$results = $result->orderBy($sorting, $direction)->paginate(25);
|
||||
} else {
|
||||
$sorting = 'topics.created_at';
|
||||
if ($request->has('sorting') && $request->input('sorting') == 'updated_at') {
|
||||
$sorting = 'topics.updated_at';
|
||||
}
|
||||
$results = $result->orderBy($sorting,$order)->paginate(25);
|
||||
$results = $result->orderBy($sorting, $order)->paginate(25);
|
||||
}
|
||||
|
||||
$results->setPath('?name='.$request->input('name'));
|
||||
@@ -209,18 +213,24 @@ class ForumController extends Controller
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$pests = $user->group->permissions->where('show_forum','=',0)->pluck('forum_id')->toArray();
|
||||
if(!is_array($pests)) { $pests=[]; }
|
||||
$pests = $user->group->permissions->where('show_forum', '=', 0)->pluck('forum_id')->toArray();
|
||||
if (! is_array($pests)) {
|
||||
$pests = [];
|
||||
}
|
||||
|
||||
$topic_neos = $user->subscriptions->pluck('topic_id')->toArray();
|
||||
if(!is_array($topic_neos)) { $topic_neos=[]; }
|
||||
if (! is_array($topic_neos)) {
|
||||
$topic_neos = [];
|
||||
}
|
||||
|
||||
$forum_neos = $user->subscriptions->pluck('forum_id')->toArray();
|
||||
if(!is_array($forum_neos)) { $forum_neos=[]; }
|
||||
if (! is_array($forum_neos)) {
|
||||
$forum_neos = [];
|
||||
}
|
||||
|
||||
$logger = "forum.subscriptions";
|
||||
$result = Forum::distinct()->with('subscription_topics')->selectRaw('forums.*,max(topics.id) as topic_id,max(topics.created_at) as topic_created_at')->leftJoin('topics','forums.id','=','topics.forum_id')->whereNotIn('topics.forum_id', $pests)->where(function ($query) use ($topic_neos,$forum_neos) {
|
||||
$query->whereIn('topics.id',$topic_neos)->orWhereIn('forums.id',$forum_neos);
|
||||
$logger = 'forum.subscriptions';
|
||||
$result = Forum::distinct()->with('subscription_topics')->selectRaw('forums.*,max(topics.id) as topic_id,max(topics.created_at) as topic_created_at')->leftJoin('topics', 'forums.id', '=', 'topics.forum_id')->whereNotIn('topics.forum_id', $pests)->where(function ($query) use ($topic_neos,$forum_neos) {
|
||||
$query->whereIn('topics.id', $topic_neos)->orWhereIn('forums.id', $forum_neos);
|
||||
})->groupBy('forums.id');
|
||||
|
||||
$results = $result->orderBy('topic_created_at', 'desc')->paginate(25);
|
||||
@@ -261,10 +271,12 @@ class ForumController extends Controller
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$pests = $user->group->permissions->where('show_forum','=',0)->pluck('forum_id')->toArray();
|
||||
if(!is_array($pests)) { $pests=[]; }
|
||||
$pests = $user->group->permissions->where('show_forum', '=', 0)->pluck('forum_id')->toArray();
|
||||
if (! is_array($pests)) {
|
||||
$pests = [];
|
||||
}
|
||||
|
||||
$results = Topic::whereNotIn('topics.forum_id',$pests)->latest()->paginate(25);
|
||||
$results = Topic::whereNotIn('topics.forum_id', $pests)->latest()->paginate(25);
|
||||
|
||||
// Total Forums Count
|
||||
$num_forums = Forum::count();
|
||||
@@ -294,10 +306,12 @@ class ForumController extends Controller
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$pests = $user->group->permissions->where('show_forum','=',0)->pluck('forum_id')->toArray();
|
||||
if(!is_array($pests)) { $pests=[]; }
|
||||
$pests = $user->group->permissions->where('show_forum', '=', 0)->pluck('forum_id')->toArray();
|
||||
if (! is_array($pests)) {
|
||||
$pests = [];
|
||||
}
|
||||
|
||||
$results = Post::selectRaw('posts.id as id,posts.*')->with(['topic','user'])->leftJoin('topics','posts.topic_id','=','topics.id')->whereNotIn('topics.forum_id',$pests)->orderBy('posts.created_at','desc')->paginate(25);
|
||||
$results = Post::selectRaw('posts.id as id,posts.*')->with(['topic', 'user'])->leftJoin('topics', 'posts.topic_id', '=', 'topics.id')->whereNotIn('topics.forum_id', $pests)->orderBy('posts.created_at', 'desc')->paginate(25);
|
||||
|
||||
// Total Forums Count
|
||||
$num_forums = Forum::count();
|
||||
@@ -325,9 +339,9 @@ class ForumController extends Controller
|
||||
*/
|
||||
public function userTopics(Request $request, $slug, int $id)
|
||||
{
|
||||
$user = User::where('id','=',$id)->firstOrFail();
|
||||
$user = User::where('id', '=', $id)->firstOrFail();
|
||||
|
||||
$results = Topic::where('topics.first_post_user_id','=',$user->id)->latest()->paginate(25);
|
||||
$results = Topic::where('topics.first_post_user_id', '=', $user->id)->latest()->paginate(25);
|
||||
|
||||
// Total Forums Count
|
||||
$num_forums = Forum::count();
|
||||
@@ -355,9 +369,9 @@ class ForumController extends Controller
|
||||
*/
|
||||
public function userPosts(Request $request, $slug, int $id)
|
||||
{
|
||||
$user = User::where('id','=',$id)->firstOrFail();
|
||||
$user = User::where('id', '=', $id)->firstOrFail();
|
||||
|
||||
$results = Post::selectRaw('posts.id as id,posts.*')->with(['topic','user'])->leftJoin('topics','posts.topic_id','=','topics.id')->where('posts.user_id','=',$user->id)->orderBy('posts.created_at','desc')->paginate(25);
|
||||
$results = Post::selectRaw('posts.id as id,posts.*')->with(['topic', 'user'])->leftJoin('topics', 'posts.topic_id', '=', 'topics.id')->where('posts.user_id', '=', $user->id)->orderBy('posts.created_at', 'desc')->paginate(25);
|
||||
|
||||
// Total Forums Count
|
||||
$num_forums = Forum::count();
|
||||
@@ -420,7 +434,6 @@ class ForumController extends Controller
|
||||
// Total Topics Count
|
||||
$num_topics = Topic::count();
|
||||
|
||||
|
||||
// Check if this is a category or forum
|
||||
if ($forum->parent_id != 0) {
|
||||
return redirect()->route('forum_display', ['slug' => $forum->slug, 'id' => $forum->id]);
|
||||
@@ -466,7 +479,6 @@ class ForumController extends Controller
|
||||
// Total Topics Count
|
||||
$num_topics = Topic::count();
|
||||
|
||||
|
||||
// Check if this is a category or forum
|
||||
if ($forum->parent_id == 0) {
|
||||
return redirect()->route('forum_category', ['slug' => $forum->slug, 'id' => $forum->id]);
|
||||
@@ -512,7 +524,7 @@ class ForumController extends Controller
|
||||
$category = $forum->getCategory();
|
||||
|
||||
// Get all posts
|
||||
$posts = $topic->posts()->with(['user','tips'])->paginate(25);
|
||||
$posts = $topic->posts()->with(['user', 'tips'])->paginate(25);
|
||||
|
||||
// First post
|
||||
$firstPost = Post::with('tips')->where('topic_id', '=', $topic->id)->first();
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Forum;
|
||||
use App\Topic;
|
||||
use App\Subscription;
|
||||
use App\Forum;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
|
||||
class SubscriptionController extends Controller
|
||||
@@ -42,18 +42,18 @@ class SubscriptionController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function subscribeTopic(string $route,Topic $topic)
|
||||
public function subscribeTopic(string $route, Topic $topic)
|
||||
{
|
||||
if($route == "subscriptions") {
|
||||
$logger="forum_subscriptions";
|
||||
if ($route == 'subscriptions') {
|
||||
$logger = 'forum_subscriptions';
|
||||
$params = [];
|
||||
}
|
||||
if(!isset($logger)) {
|
||||
$logger="forum_topic";
|
||||
if (! isset($logger)) {
|
||||
$logger = 'forum_topic';
|
||||
$params = ['slug' => $topic->slug, 'id' => $topic->id];
|
||||
}
|
||||
|
||||
if (! auth()->user()->isSubscribed('topic',$topic->id)) {
|
||||
if (! auth()->user()->isSubscribed('topic', $topic->id)) {
|
||||
$subscription = new Subscription();
|
||||
$subscription->user_id = auth()->user()->id;
|
||||
$subscription->topic_id = $topic->id;
|
||||
@@ -74,18 +74,18 @@ class SubscriptionController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function unsubscribeTopic(string $route,Topic $topic)
|
||||
public function unsubscribeTopic(string $route, Topic $topic)
|
||||
{
|
||||
if($route == "subscriptions") {
|
||||
$logger="forum_subscriptions";
|
||||
if ($route == 'subscriptions') {
|
||||
$logger = 'forum_subscriptions';
|
||||
$params = [];
|
||||
}
|
||||
if(!isset($logger)) {
|
||||
$logger="forum_topic";
|
||||
if (! isset($logger)) {
|
||||
$logger = 'forum_topic';
|
||||
$params = ['slug' => $topic->slug, 'id' => $topic->id];
|
||||
}
|
||||
|
||||
if (auth()->user()->isSubscribed('topic',$topic->id)) {
|
||||
if (auth()->user()->isSubscribed('topic', $topic->id)) {
|
||||
$subscription = auth()->user()->subscriptions()->where('topic_id', '=', $topic->id)->first();
|
||||
$subscription->delete();
|
||||
|
||||
@@ -104,18 +104,18 @@ class SubscriptionController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function subscribeForum(string $route,Forum $forum)
|
||||
public function subscribeForum(string $route, Forum $forum)
|
||||
{
|
||||
if($route == "subscriptions") {
|
||||
$logger="forum_subscriptions";
|
||||
if ($route == 'subscriptions') {
|
||||
$logger = 'forum_subscriptions';
|
||||
$params = [];
|
||||
}
|
||||
if(!isset($logger)) {
|
||||
$logger="forum_display";
|
||||
if (! isset($logger)) {
|
||||
$logger = 'forum_display';
|
||||
$params = ['slug' => $forum->slug, 'id' => $forum->id];
|
||||
}
|
||||
|
||||
if (! auth()->user()->isSubscribed('forum',$forum->id)) {
|
||||
if (! auth()->user()->isSubscribed('forum', $forum->id)) {
|
||||
$subscription = new Subscription();
|
||||
$subscription->user_id = auth()->user()->id;
|
||||
$subscription->forum_id = $forum->id;
|
||||
@@ -136,18 +136,18 @@ class SubscriptionController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function unsubscribeForum(string $route,Forum $forum)
|
||||
public function unsubscribeForum(string $route, Forum $forum)
|
||||
{
|
||||
if($route == "subscriptions") {
|
||||
$logger="forum_subscriptions";
|
||||
if ($route == 'subscriptions') {
|
||||
$logger = 'forum_subscriptions';
|
||||
$params = [];
|
||||
}
|
||||
if(!isset($logger)) {
|
||||
$logger="forum_display";
|
||||
if (! isset($logger)) {
|
||||
$logger = 'forum_display';
|
||||
$params = ['slug' => $forum->slug, 'id' => $forum->id];
|
||||
}
|
||||
|
||||
if (auth()->user()->isSubscribed('forum',$forum->id)) {
|
||||
if (auth()->user()->isSubscribed('forum', $forum->id)) {
|
||||
$subscription = auth()->user()->subscriptions()->where('forum_id', '=', $forum->id)->first();
|
||||
$subscription->delete();
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class ThankController extends Controller
|
||||
|
||||
//Notification
|
||||
if ($user->id != $torrent->user_id) {
|
||||
$torrent->notifyUploader('thank',$thank);
|
||||
$torrent->notifyUploader('thank', $thank);
|
||||
}
|
||||
|
||||
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])
|
||||
|
||||
@@ -61,14 +61,14 @@ class NewComment extends Notification
|
||||
if ($this->comment->anon == 0) {
|
||||
return [
|
||||
'title' => 'New Torrent Comment Received',
|
||||
'body' => $this->comment->user->username . ' has left you a comment on ' . $this->comment->torrent->name,
|
||||
'url' => '/torrents/' . $this->comment->torrent->slug . '.' . $this->comment->torrent->id,
|
||||
'body' => $this->comment->user->username.' has left you a comment on '.$this->comment->torrent->name,
|
||||
'url' => '/torrents/'.$this->comment->torrent->slug.'.'.$this->comment->torrent->id,
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'title' => 'New Torrent Comment Received',
|
||||
'body' => 'Anonymous has left you a comment on ' . $this->comment->torrent->name,
|
||||
'url' => '/torrents/' . $this->comment->torrent->slug . '.' . $this->comment->torrent->id,
|
||||
'body' => 'Anonymous has left you a comment on '.$this->comment->torrent->name,
|
||||
'url' => '/torrents/'.$this->comment->torrent->slug.'.'.$this->comment->torrent->id,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,25 +63,26 @@ class NewCommentTag extends Notification implements ShouldQueue
|
||||
{
|
||||
$appurl = config('app.url');
|
||||
|
||||
if($this->type == 'torrent') {
|
||||
if ($this->type == 'torrent') {
|
||||
return [
|
||||
'title' => $this->tagger . ' Has Tagged You In A Torrent Comment',
|
||||
'body' => $this->tagger . ' has tagged you in a Comment for Torrent: ' . $this->comment->torrent->name,
|
||||
'title' => $this->tagger.' Has Tagged You In A Torrent Comment',
|
||||
'body' => $this->tagger.' has tagged you in a Comment for Torrent: '.$this->comment->torrent->name,
|
||||
'url' => "/torrents/{$this->comment->torrent->slug}.{$this->comment->torrent->id}",
|
||||
];
|
||||
} else if($this->type == 'req') {
|
||||
} elseif ($this->type == 'req') {
|
||||
return [
|
||||
'title' => $this->tagger . ' Has Tagged You In A Request Comment',
|
||||
'body' => $this->tagger . ' has tagged you in a Comment for Request: ' . $this->comment->request->name,
|
||||
'title' => $this->tagger.' Has Tagged You In A Request Comment',
|
||||
'body' => $this->tagger.' has tagged you in a Comment for Request: '.$this->comment->request->name,
|
||||
'url' => "/request/{$this->comment->request->id}",
|
||||
];
|
||||
} else if($this->type == 'article') {
|
||||
} elseif ($this->type == 'article') {
|
||||
return [
|
||||
'title' => $this->tagger . ' Has Tagged You In An Article Comment',
|
||||
'body' => $this->tagger . ' has tagged you in a Comment for Article: ' . $this->comment->article->title,
|
||||
'title' => $this->tagger.' Has Tagged You In An Article Comment',
|
||||
'body' => $this->tagger.' has tagged you in a Comment for Article: '.$this->comment->article->title,
|
||||
'url' => "/articles/{$this->comment->article->slug}.{$this->comment->article->id}",
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'title' => '',
|
||||
'body' => '',
|
||||
|
||||
@@ -62,10 +62,10 @@ class NewPost extends Notification implements ShouldQueue
|
||||
{
|
||||
$appurl = config('app.url');
|
||||
|
||||
if($this->type == 'topic') {
|
||||
if ($this->type == 'topic') {
|
||||
return [
|
||||
'title' => $this->post->user->username . ' Has Posted In Topic',
|
||||
'body' => $this->post->user->username . ' has left a new post in Topic ' . $this->post->topic->name,
|
||||
'title' => $this->post->user->username.' Has Posted In Topic',
|
||||
'body' => $this->post->user->username.' has left a new post in Topic '.$this->post->topic->name,
|
||||
'url' => "/forums/topic/{$this->post->topic->slug}.{$this->post->topic->id}?page={$this->post->getPageNumber()}#post-{$this->post->id}",
|
||||
];
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ class NewThank extends Notification
|
||||
|
||||
return [
|
||||
'title' => 'New Torrent Thanks Received',
|
||||
'body' => $this->thank->user->username . ' has left you a thanks on ' . $this->thank->torrent->name,
|
||||
'url' => '/torrents/' . $this->thank->torrent->slug . '.' . $this->thank->torrent->id,
|
||||
'body' => $this->thank->user->username.' has left you a thanks on '.$this->thank->torrent->name,
|
||||
'url' => '/torrents/'.$this->thank->torrent->slug.'.'.$this->thank->torrent->id,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ class NewTopic extends Notification implements ShouldQueue
|
||||
$appurl = config('app.url');
|
||||
|
||||
return [
|
||||
'title' => $this->topic->first_post_user_username . ' Has Posted In Forum',
|
||||
'body' => $this->topic->first_post_user_username . ' has started a new topic in ' . $this->topic->forum->name,
|
||||
'title' => $this->topic->first_post_user_username.' Has Posted In Forum',
|
||||
'body' => $this->topic->first_post_user_username.' has started a new topic in '.$this->topic->forum->name,
|
||||
'url' => "/forums/topic/{$this->topic->slug}.{$this->topic->id}",
|
||||
];
|
||||
}
|
||||
|
||||
@@ -65,8 +65,7 @@ class NewUnfollow extends Notification implements ShouldQueue
|
||||
return [
|
||||
'title' => $this->sender_username.' Has Unfollowed You!',
|
||||
'body' => $this->sender_username.' has stopped following you so they will no longer get notifications about your activities.',
|
||||
'url' => "/".$this->sender_username.".".$this->sender_id,
|
||||
'url' => '/'.$this->sender_username.'.'.$this->sender_id,
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -42,10 +42,10 @@ class Post extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* A Post Has Many Likes.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
* A Post Has Many Likes.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function likes()
|
||||
{
|
||||
return $this->hasMany(Like::class);
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\User;
|
||||
use App\Post;
|
||||
use App\User;
|
||||
use App\Comment;
|
||||
use App\PrivateMessage;
|
||||
use App\Notifications\NewPostTag;
|
||||
@@ -124,17 +124,19 @@ class TaggedUserRepository
|
||||
|
||||
foreach ($users as $user) {
|
||||
if ($this->validate($user)) {
|
||||
$user->notify(new NewCommentTag($type,$sender,$comment));
|
||||
$user->notify(new NewCommentTag($type, $sender, $comment));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// A single User object
|
||||
|
||||
if ($this->validate($users)) {
|
||||
$users->notify(new NewCommentTag($type,$sender,$comment));
|
||||
$users->notify(new NewCommentTag($type, $sender, $comment));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -171,17 +173,19 @@ class TaggedUserRepository
|
||||
|
||||
foreach ($users as $user) {
|
||||
if ($this->validate($user)) {
|
||||
$user->notify(new NewPostTag($type,$sender,$post));
|
||||
$user->notify(new NewPostTag($type, $sender, $post));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// A single User object
|
||||
|
||||
if ($this->validate($users)) {
|
||||
$users->notify(new NewPostTag($type,$sender,$post));
|
||||
$users->notify(new NewPostTag($type, $sender, $post));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
namespace App;
|
||||
|
||||
use App\Notifications\NewTopic;
|
||||
use App\Notifications\NewPost;
|
||||
use App\Notifications\NewTopic;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Subscription extends Model
|
||||
@@ -59,7 +59,7 @@ class Subscription extends Model
|
||||
*/
|
||||
public function notifyTopic($post)
|
||||
{
|
||||
User::find($this->user_id)->notify(new NewPost('topic',$post));
|
||||
User::find($this->user_id)->notify(new NewPost('topic', $post));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,6 +69,6 @@ class Subscription extends Model
|
||||
*/
|
||||
public function notifyForum($topic)
|
||||
{
|
||||
User::find($this->user_id)->notify(new NewTopic('forum',$topic));
|
||||
User::find($this->user_id)->notify(new NewTopic('forum', $topic));
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -34,7 +34,7 @@ class Topic extends Model
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class,'first_post_user_id','id');
|
||||
return $this->belongsTo(User::class, 'first_post_user_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,11 +84,12 @@ class Topic extends Model
|
||||
/**
|
||||
* Notify Starter When An Action Is Taken.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function notifyStarter($type,$payload)
|
||||
public function notifyStarter($type, $payload)
|
||||
{
|
||||
User::find($this->first_post_user_id)->notify(new NewPost('topic',$payload));
|
||||
User::find($this->first_post_user_id)->notify(new NewPost('topic', $payload));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+7
-5
@@ -254,15 +254,17 @@ class Torrent extends Model
|
||||
/**
|
||||
* Notify Uploader When An Action Is Taken.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function notifyUploader($type,$payload)
|
||||
public function notifyUploader($type, $payload)
|
||||
{
|
||||
if($type == 'thank') {
|
||||
User::find($this->user_id)->notify(new NewThank('torrent',$payload));
|
||||
if ($type == 'thank') {
|
||||
User::find($this->user_id)->notify(new NewThank('torrent', $payload));
|
||||
|
||||
return true;
|
||||
}
|
||||
User::find($this->user_id)->notify(new NewComment('torrent',$payload));
|
||||
User::find($this->user_id)->notify(new NewComment('torrent', $payload));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -140,11 +140,12 @@ class TorrentRequest extends Model
|
||||
/**
|
||||
* Notify Requester When A New Action Is Taken.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function notifyRequester($type, $comment)
|
||||
{
|
||||
User::find($this->user_id)->notify(new NewComment('req',$comment));
|
||||
User::find($this->user_id)->notify(new NewComment('req', $comment));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -473,11 +473,12 @@ class User extends Authenticatable
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function isSubscribed(string $type = 'topic', $topic_id)
|
||||
public function isSubscribed(string $type, $topic_id)
|
||||
{
|
||||
if($type == 'topic') {
|
||||
if ($type == 'topic') {
|
||||
return (bool) $this->subscriptions()->where('topic_id', '=', $topic_id)->first(['id']);
|
||||
}
|
||||
|
||||
return (bool) $this->subscriptions()->where('forum_id', '=', $topic_id)->first(['id']);
|
||||
}
|
||||
|
||||
|
||||
@@ -400,7 +400,6 @@ Route::group(['middleware' => 'language'], function () {
|
||||
Route::get('/topic/{slug}.{id}/bug', 'ForumController@bugTopic')->name('forum_bug')->middleware('modo');
|
||||
Route::get('/topic/{slug}.{id}/suggestion', 'ForumController@suggestionTopic')->name('forum_suggestion')->middleware('modo');
|
||||
Route::get('/topic/{slug}.{id}/implemented', 'ForumController@implementedTopic')->name('forum_implemented')->middleware('modo');
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user