You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

85 lines
2.3 KiB

<?php
namespace App\Http\Controllers;
use App\Models\SeminarType;
use Illuminate\Http\Request;
use App\Http\Requests\SeminarTypeRequest;
use App\Http\Requests\ShowSeminarTypesRequest;
use App\Http\Requests\DeleteSeminarTypeRequest;
use App\Http\Resources\SeminarType as SeminarTypeResource;
use App\Http\Resources\SeminarTypes as SeminarTypeCollection;
class SeminarTypeController extends Controller
{
/**
* Display a listing of the seminar types.
*
* @return \Illuminate\Http\Response
*/
public function index(ShowSeminarTypesRequest $request)
{
$seminarTypes = SeminarType::all();
return new SeminarTypeCollection($seminarTypes);
}
/**
* Store a newly created seminar type in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(SeminarTypeRequest $request)
{
$seminarType = new SeminarType($request->all());
if(!$seminarType->save()) {
abort(500);
}
return (new SeminarTypeResource($seminarType))
->response()
->setStatusCode(201);
}
/**
* Display the specified seminar type.
*
* @param \App\SeminarType $seminarType
* @return \Illuminate\Http\Response
*/
public function show(ShowSeminarTypesRequest $request, SeminarType $seminarType)
{
return new SeminarTypeResource($seminarType);
}
/**
* Update the specified seminar type in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\SeminarType $seminarType
* @return \Illuminate\Http\Response
*/
public function update(SeminarTypeRequest $request, SeminarType $seminarType)
{
$seminarType->update($request->all());
if(!$seminarType->save()) {
abort(500);
}
return new SeminarTypeResource($seminarType);
}
/**
* Remove the specified seminar type from storage.
*
* @param \App\SeminarType $seminarType
* @return \Illuminate\Http\Response
*/
public function destroy(DeleteSeminarRequest $request, SeminarType $seminarType)
{
// TODO: map all seminars to null type
if (!$seminarType->destroy()) {
abort(500);
}
return response(204);
}
}