Created FilamentTypeController & FilamentType Model
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\FilamentType;
|
||||
|
||||
class FilamentTypeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$types = FilamentType::all();
|
||||
return view('types.index', compact('types'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
return view('types.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
$type = new FilamentType();
|
||||
$type->name = $request->name;
|
||||
$type->description = $request->description;
|
||||
$type->save();
|
||||
return redirect()->route('types.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
// Show Single Type
|
||||
$type = FilamentType::find($id);
|
||||
|
||||
|
||||
return view('types.show', compact('type'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
//
|
||||
$type = FilamentType::find($id);
|
||||
return view('types.edit', compact('type'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
// Store updated type
|
||||
$type = FilamentType::find($id);
|
||||
$type->name = $request->name;
|
||||
$type->description = $request->description;
|
||||
$type->save();
|
||||
return redirect()->route('types.show', $type->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
// Delete Type
|
||||
$type = FilamentType::find($id);
|
||||
$type->delete();
|
||||
return redirect()->route('types.index')->with('success','Type deleted successfully.');
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user