mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-13 04:30:41 -05:00
remove disabled scope
This commit is contained in:
parent
f9378b2044
commit
593951b409
@ -2,11 +2,13 @@
|
||||
|
||||
namespace App\Livewire\Mod;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Models\Mod;
|
||||
use Livewire\Component;
|
||||
|
||||
class ModerationOptions extends Component
|
||||
{
|
||||
public Mod $mod;
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.mod.moderation-options');
|
||||
@ -14,11 +16,12 @@ class ModerationOptions extends Component
|
||||
|
||||
public function deleteMod(): void
|
||||
{
|
||||
Log::info('delete');
|
||||
$this->mod->delete();
|
||||
}
|
||||
|
||||
public function disableMod(): void
|
||||
{
|
||||
Log::info('disable');
|
||||
$this->mod->disabled = true;
|
||||
$this->mod->save();
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Http\Filters\V1\QueryFilter;
|
||||
use App\Models\Scopes\DisabledScope;
|
||||
use App\Models\Scopes\PublishedScope;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
@ -30,7 +29,6 @@ class Mod extends Model
|
||||
*/
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::addGlobalScope(new DisabledScope);
|
||||
static::addGlobalScope(new PublishedScope);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Exceptions\InvalidVersionNumberException;
|
||||
use App\Models\Scopes\DisabledScope;
|
||||
use App\Models\Scopes\PublishedScope;
|
||||
use App\Support\Version;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@ -29,8 +28,6 @@ class ModVersion extends Model
|
||||
*/
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::addGlobalScope(new DisabledScope);
|
||||
|
||||
static::addGlobalScope(new PublishedScope);
|
||||
|
||||
static::saving(function (ModVersion $model) {
|
||||
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Scopes;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Scope;
|
||||
|
||||
class DisabledScope implements Scope
|
||||
{
|
||||
/**
|
||||
* Apply the scope to a given Eloquent query builder.
|
||||
*/
|
||||
public function apply(Builder $builder, Model $model): void
|
||||
{
|
||||
$builder->where($model->getTable().'.disabled', false);
|
||||
}
|
||||
}
|
@ -6,9 +6,9 @@
|
||||
@endif
|
||||
<div class="flex flex-col group h-full w-full bg-white dark:bg-gray-950 rounded-xl shadow-md dark:shadow-gray-950 drop-shadow-2xl overflow-hidden hover:shadow-lg hover:bg-gray-50 dark:hover:bg-black hover:shadow-gray-400 dark:hover:shadow-black transition-colors ease-out duration-700">
|
||||
<div class="h-auto md:h-full md:flex">
|
||||
@if (auth()->check() && auth()->user()->isAdmin())
|
||||
@if (auth()->check() && (auth()->user()->isAdmin() || auth()->user()->isMod()))
|
||||
<div class="absolute right-0 z-50 m-2">
|
||||
<livewire:mod.moderation-options />
|
||||
<livewire:mod.moderation-options :mod="$mod"/>
|
||||
</div>
|
||||
@endif
|
||||
<div class="relative h-auto md:h-full md:shrink-0 overflow-hidden">
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
<x-slot name="content">
|
||||
<div>
|
||||
<button wire:click.prevent="disableMod" wire:confirm="Disable the mod?" class="p-2 h-full w-full text-blue-500 dark:text-blue-500 bg-gray-200 dark:bg-gray-800 hover:text-blue-400 dark:hover:text-blue-400">
|
||||
<button wire:click.prevent="disableMod" wire:confirm="Disable the mod '{{$this->mod->name}}'?" class="p-2 h-full w-full text-blue-500 dark:text-blue-500 bg-gray-200 dark:bg-gray-800 hover:text-blue-400 dark:hover:text-blue-400">
|
||||
<div class="flex">
|
||||
<span class="pr-2">
|
||||
{{-- Icon (circle with dash) --}}
|
||||
@ -24,8 +24,9 @@
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
@if(auth()->user()->isAdmin())
|
||||
<div>
|
||||
<button wire:click.prevent="deleteMod" wire:confirm="Delete the mod?" class="p-2 h-full w-full text-red-500 dark:text-red-500 bg-gray-200 dark:bg-gray-800 hover:text-red-400 dark:hover:text-red-400">
|
||||
<button wire:click.prevent="deleteMod" wire:confirm="Delete the mod '{{$this->mod->name}}'?" class="p-2 h-full w-full text-red-500 dark:text-red-500 bg-gray-200 dark:bg-gray-800 hover:text-red-400 dark:hover:text-red-400">
|
||||
<div class="flex">
|
||||
<span class="pr-2">
|
||||
{{-- Icon (trash can) --}}
|
||||
@ -37,6 +38,7 @@
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
</x-slot>
|
||||
|
||||
</x-dropdown>
|
||||
|
Loading…
x
Reference in New Issue
Block a user