71 lines
1.5 KiB
PHP
71 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Models\Forgalom;
|
|
|
|
class forgalomController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
$adatok = Forgalom::all()->map(function($elem) {
|
|
return [
|
|
"Név:"=> $elem->termek,
|
|
"Ár:"=> $elem->nettoar,
|
|
"Típus:" => $elem->kategoria->kategoriaNev
|
|
|
|
|
|
];
|
|
});
|
|
return response()->json($adatok, 200, ["Content-Type" => "application/json"]);
|
|
}
|
|
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*/
|
|
public function show(string $id)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request)
|
|
{
|
|
$rekord = Forgalom::find($request["id"]);
|
|
if(!$rekord){
|
|
return response("Nem létező rendelés",400);
|
|
}
|
|
$rekord->update(["kiadva"=>true]);
|
|
return response("Sikeres frissítés",200);
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy(string $id)
|
|
{
|
|
$torol = Forgalom::find($id);
|
|
if(!$torol){
|
|
return response("Nem létező rendelés",404);
|
|
}
|
|
$torol->delete();
|
|
return response("Sikeres törlés",204);
|
|
|
|
}
|
|
}
|