MIF_E31210529/app/Http/Controllers/CriteriaController.php

82 lines
1.6 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Criteria;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use RealRashid\SweetAlert\Facades\Alert;
class CriteriaController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
$criterias = Criteria::all();
return view('kriteria.index', compact('criterias'));
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), [
'nama' => 'required',
'prioritas' => 'required',
]);
if ($validator->fails()) {
return redirect()->back()->withErrors($validator)->withInput();
}
Criteria::create([
'nama'=>$request->nama,
'prioritas'=>$request->prioritas,
]);
return redirect()->route('kriteria.index')->with('success', 'Tambah Data Berhasil!');
}
/**
* Display the specified resource.
*/
public function show(string $id)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(string $id)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
//
}
}