Kész(?????)

This commit is contained in:
Sándor Máté Magony
2025-05-12 14:44:52 +02:00
parent edcfe3cf55
commit 8288e5d345
3 changed files with 18 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Models\WcAdatok;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class WcController extends Controller
{
@@ -13,6 +14,12 @@ class WcController extends Controller
return response()->json($mosdok);
}
public function __construct()
{
$this->middleware('auth:api')->only(['store', 'destroy']);
}
public function store(Request $request)
{
$validatedData = $request->validate([
@@ -56,7 +63,7 @@ class WcController extends Controller
'utvonal' => $validatedData['utvonal'],
'szel_koord' => $szelesseg,
'hossz_koord' => $hosszusag,
'felhasznalo_id' => $validatedData['felhasznalo_id'] ?? null
'felhasznalo_id' => auth('api')->id()
]);
return response()->json([

View File

@@ -25,11 +25,13 @@ export default function Csempe() {
}, []);
function mosdoTorles(mosdoId){
const token = localStorage.getItem("token");
fetch("http://localhost:8000/api/mosdotorles/" + mosdoId, {
method: "DELETE",
header: {
headers: {
"Accept" : "application/json",
"Content-Type" : "application/json"
"Content-Type" : "application/json",
"Authorization": `Bearer ${token}`
}
})
.then(response => {

View File

@@ -37,14 +37,17 @@ export default function HozzaadForm() {
ar,
nyitva,
utvonal,
koordinatak,
felhasznalo_id: null
koordinatak
};
try {
const token = localStorage.getItem("token");
const response = await fetch("http://localhost:8000/api/hozzaadas", {
method: "POST",
headers: { "Content-Type": "application/json" },
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
},
body: JSON.stringify(wcInfo)
});