* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0 */ namespace App\Models; use App\Traits\Auditable; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; class Warning extends Model { use Auditable; use HasFactory; use SoftDeletes; /** * Belongs To A Torrent. */ public function torrenttitle(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Torrent::class, 'torrent'); } /** * Belongs To A User. */ public function warneduser(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(User::class, 'user_id')->withDefault([ 'username' => 'System', 'id' => '1', ]); } /** * Belongs To A USer. */ public function staffuser(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(User::class, 'warned_by')->withDefault([ 'username' => 'System', 'id' => '1', ]); } /** * Belongs To A USer. */ public function deletedBy(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(User::class, 'deleted_by')->withDefault([ 'username' => 'System', 'id' => '1', ]); } /** * Active Warnings. */ public function scopeActive($query): Builder { return $query->where('active', '=', 1); } }