mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-13 04:30:41 -05:00
The global search results now include the SPT version number the latest version of the mod is compatible with. Additionally, mod thumbnails and the SPT version numbers Homepage queries have been further optimized and are now cached for 5 minutes.
63 lines
1.3 KiB
PHP
63 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Requests\ModRequest;
|
|
use App\Http\Resources\ModResource;
|
|
use App\Models\Mod;
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
|
|
class ModController extends Controller
|
|
{
|
|
use AuthorizesRequests;
|
|
|
|
public function index()
|
|
{
|
|
$this->authorize('viewAny', Mod::class);
|
|
|
|
return ModResource::collection(Mod::all());
|
|
}
|
|
|
|
public function store(ModRequest $request)
|
|
{
|
|
$this->authorize('create', Mod::class);
|
|
|
|
return new ModResource(Mod::create($request->validated()));
|
|
}
|
|
|
|
public function show(int $modId, string $slug)
|
|
{
|
|
$mod = Mod::select()
|
|
->withTotalDownloads()
|
|
->with(['latestSptVersion', 'users:id,name'])
|
|
->with('license:id,name,link')
|
|
->find($modId);
|
|
|
|
if (! $mod || $mod->slug !== $slug) {
|
|
abort(404);
|
|
}
|
|
|
|
$this->authorize('view', $mod);
|
|
|
|
return view('mod.show', compact('mod'));
|
|
}
|
|
|
|
public function update(ModRequest $request, Mod $mod)
|
|
{
|
|
$this->authorize('update', $mod);
|
|
|
|
$mod->update($request->validated());
|
|
|
|
return new ModResource($mod);
|
|
}
|
|
|
|
public function destroy(Mod $mod)
|
|
{
|
|
$this->authorize('delete', $mod);
|
|
|
|
$mod->delete();
|
|
|
|
return response()->json();
|
|
}
|
|
}
|