mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-05-08 04:00:14 -05:00
refactor: simplify user model
Models shouldn't contain custom logic
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Auditable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -48,4 +49,20 @@ class Subscription extends Model
|
||||
{
|
||||
return $this->belongsTo(Forum::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Only include subscriptions of a forum
|
||||
*/
|
||||
public function scopeOfForum($query, $forum_id): Builder
|
||||
{
|
||||
return $query->where('forum_id', '=', $forum_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Only include subscriptions of a topic
|
||||
*/
|
||||
public function scopeOfTopic($query, $topic_id): Builder
|
||||
{
|
||||
return $query->where('topic_id', '=', $topic_id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user