<?php
namespace App\Http\Controllers\Management;
use App\Http\Controllers\Controller;
use App\Models\EventType;
use Illuminate\Http\Request;
class EventTypeController extends Controller
{
public function index()
{
return view('management.event-types', [
'types' => EventType::orderBy('name', 'asc')->paginate(15)
]);
}
public function form()
{
return view('management.event-types-form');
}
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required|min:3'
]);
$ban = new EventType();
$ban->name = $request->get('name');
$ban->save();
return redirect()->route('dashboard::management::event-type')->with('msg', [
'type' => 'success',
'msg' => _('Successfully added a new event type.')
]);
}
public function delete(int $id)
{
EventType::findOrFail($id)->delete();
return redirect()->back()->with('msg', [
'type' => 'success',
'msg' => _('Successfully removed the event type.')
]);
}
}