api/app/Http/Controllers/HuntStepsController.php

55 lines
1.3 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\HuntSteps;
use Illuminate\Http\Request;
class HuntStepsController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
/**
* Store a newly created resource in storage.
*/
public function store(Request $request, \App\Models\Hunts $hunt)
{
if ($hunt->creator_id !== auth()->id()) {
return response()->json(['message' => 'Unauthorized'], 403);
}
$validated = $request->validate([
'step_number' => 'required|integer',
'title' => 'required|string|max:255',
'description' => 'nullable|string',
'hint_text' => 'required|string',
'hint_media_url' => 'nullable|string',
'latitude' => 'required|numeric',
'longitude' => 'required|numeric',
'radius_m' => 'integer|min:1',
'xp' => 'integer|min:0',
]);
$step = $hunt->steps()->create($validated);
return response()->json($step, 201);
}
}