c3lf-system-3/app/Http/Controllers/EventController.php
2019-11-15 22:10:28 +01:00

41 lines
No EOL
814 B
PHP

<?php
namespace App\Http\Controllers;
use App\Event;
use Illuminate\Http\Request;
class EventController extends Controller
{
public function showAllEvents()
{
return response()->json(Event::all());
}
public function showOneEvent($id)
{
return response()->json(Event::find($id));
}
public function create(Request $request)
{
$event = Event::create($request->all());
return response()->json($event, 201);
}
public function update($id, Request $request)
{
$event = Event::findOrFail($id);
$event->update($request->all());
return response()->json($event, 200);
}
public function delete($id)
{
Event::findOrFail($id)->delete();
return response('Deleted Successfully', 200);
}
}