api/app/Http/Controllers/HuntStepsController.php

42 lines
830 B
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.
*/
public function store(\App\Http\Requests\StoreHuntStepRequest $request, \App\Models\Hunts $hunt)
{
if ($hunt->creator_id !== auth()->id()) {
return response()->json(['message' => 'Unauthorized'], 403);
}
$validated = $request->validated();
$step = $hunt->steps()->create($validated);
return response()->json($step, 201);
}
}