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;
|
namespace App\Livewire\Mod;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use App\Models\Mod;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class ModerationOptions extends Component
|
class ModerationOptions extends Component
|
||||||
{
|
{
|
||||||
|
public Mod $mod;
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.mod.moderation-options');
|
return view('livewire.mod.moderation-options');
|
||||||
@ -14,11 +16,12 @@ class ModerationOptions extends Component
|
|||||||
|
|
||||||
public function deleteMod(): void
|
public function deleteMod(): void
|
||||||
{
|
{
|
||||||
Log::info('delete');
|
$this->mod->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disableMod(): void
|
public function disableMod(): void
|
||||||
{
|
{
|
||||||
Log::info('disable');
|
$this->mod->disabled = true;
|
||||||
|
$this->mod->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Http\Filters\V1\QueryFilter;
|
use App\Http\Filters\V1\QueryFilter;
|
||||||
use App\Models\Scopes\DisabledScope;
|
|
||||||
use App\Models\Scopes\PublishedScope;
|
use App\Models\Scopes\PublishedScope;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
@ -30,7 +29,6 @@ class Mod extends Model
|
|||||||
*/
|
*/
|
||||||
protected static function booted(): void
|
protected static function booted(): void
|
||||||
{
|
{
|
||||||
static::addGlobalScope(new DisabledScope);
|
|
||||||
static::addGlobalScope(new PublishedScope);
|
static::addGlobalScope(new PublishedScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Exceptions\InvalidVersionNumberException;
|
use App\Exceptions\InvalidVersionNumberException;
|
||||||
use App\Models\Scopes\DisabledScope;
|
|
||||||
use App\Models\Scopes\PublishedScope;
|
use App\Models\Scopes\PublishedScope;
|
||||||
use App\Support\Version;
|
use App\Support\Version;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
@ -29,8 +28,6 @@ class ModVersion extends Model
|
|||||||
*/
|
*/
|
||||||
protected static function booted(): void
|
protected static function booted(): void
|
||||||
{
|
{
|
||||||
static::addGlobalScope(new DisabledScope);
|
|
||||||
|
|
||||||
static::addGlobalScope(new PublishedScope);
|
static::addGlobalScope(new PublishedScope);
|
||||||
|
|
||||||
static::saving(function (ModVersion $model) {
|
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
|
@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="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">
|
<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">
|
<div class="absolute right-0 z-50 m-2">
|
||||||
<livewire:mod.moderation-options />
|
<livewire:mod.moderation-options :mod="$mod"/>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
<div class="relative h-auto md:h-full md:shrink-0 overflow-hidden">
|
<div class="relative h-auto md:h-full md:shrink-0 overflow-hidden">
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<x-slot name="content">
|
<x-slot name="content">
|
||||||
<div>
|
<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">
|
<div class="flex">
|
||||||
<span class="pr-2">
|
<span class="pr-2">
|
||||||
{{-- Icon (circle with dash) --}}
|
{{-- Icon (circle with dash) --}}
|
||||||
@ -24,8 +24,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@if(auth()->user()->isAdmin())
|
||||||
<div>
|
<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">
|
<div class="flex">
|
||||||
<span class="pr-2">
|
<span class="pr-2">
|
||||||
{{-- Icon (trash can) --}}
|
{{-- Icon (trash can) --}}
|
||||||
@ -37,6 +38,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
</x-slot>
|
</x-slot>
|
||||||
|
|
||||||
</x-dropdown>
|
</x-dropdown>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user