mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-22 02:47:27 +08:00
[api] reward + thanks
This commit is contained in:
@@ -4,7 +4,9 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Resources\ThankResource;
|
||||
use App\Models\Thank;
|
||||
use App\Models\Torrent;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ThankController extends Controller
|
||||
{
|
||||
@@ -37,7 +39,17 @@ class ThankController extends Controller
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
$request->validate(['torrent_id' => 'required']);
|
||||
$torrentId = $request->torrent_id;
|
||||
$torrent = Torrent::query()->findOrFail($torrentId, Torrent::$commentFields);
|
||||
$torrent->checkIsNormal();
|
||||
$user = Auth::user();
|
||||
if ($user->thank_torrent_logs()->where('torrentid', $torrentId)->exists()) {
|
||||
throw new \LogicException("you already thank this torrent");
|
||||
}
|
||||
$result = $user->thank_torrent_logs()->create(['torrentid' => $torrentId]);
|
||||
$resource = new ThankResource($result);
|
||||
return $this->success($resource);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user