c3lf-system-3/app/Http/Controllers/EventController.php

41 lines
814 B
PHP
Raw Normal View History

2019-11-15 21:10:28 +00:00
<?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);
}
}