laravel

 /* Item Routes */


Route::get('/item',[ItemController::class, 'index']);

Route::get('/item/item-create',[ItemController::class,'create']);

Route::post('/item/item-store',[ItemController::class,'store']);

Route::get('/item-edit/{id}', [ItemController::class,'edit']);

Route::put('/item-update/{id}', [ItemController::class,'update']);

Route::delete('/item-delete/{id}', [ItemController::class,'delete']);




/*********************controller*************************/
<?php

namespace App\Http\Controllers;

use App\Models\item;
use Illuminate\Http\Request;
use App\Models\Itemnew;

class ItemController extends Controller
{
    public function index(){
       
        $item = item::get();

        return view('item.list',['items' => $item]);
    }

   public function create(){
        return view('item.create');
    }

    public function store(Request $request){
        $items = new item;

        $items->inm = $request->inm;

        $items->save();

        return redirect('/item');
    }

    public function edit($id){
        $items = item::where('id', $id)->first();

        return view('item.edit',['item' => $items]);
    }

    public function update(Request $request, $id){
        $items = item::where('id', $id)->first();
        $items->inm = $request->inm;

        $items->save();

        return redirect('/item');
    }

    public  function delete($id){
        $items = item::whereId($id)->first();

        $items->delete();

        return redirect('/item');


    }

}


/*********************edit********/
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Edit Items</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>

<div class="container mt-5">
  <h2>Edit Items</h2>
  <form action="/item-update/{{ $item->id }}" method="post">
      @csrf
      @method('put')
    <div class="mb-3 mt-3">
      <label for="inm">Item Name:</label>
      <input type="text" class="form-control" id="inm" placeholder="Enter Item" name="inm" value="{{ $item->inm }}">
    </div>
    <button type="submit" class="btn btn-sm btn-info">Update</button>
  </form>
</div>

</body>
</html>


/* ***********************************create*/

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Add Items</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>

<div class="container mt-5">
  <h2>Add Items</h2>
  <form action="/item/item-store" method="post">
      @csrf
    <div class="mb-3 mt-3">
      <label for="inm">Item Name:</label>
      <input type="text" class="form-control" id="inm" placeholder="Enter Item" name="inm">
    </div>
    <button type="submit" class="btn btn-sm btn-info">New Item Add</button>
  </form>
</div>

</body>
</html>


/*************************************list*/
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Item List Page</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>

<div class="container mt-5">
  <h2>Item List Table <a href="/item/item-create" class="btn btn-sm btn-info">Add New Item</a></h2>  
  <table class="table mt-5">
    <thead>
      <tr>
        <th>S.no.</th>
        <th>Item Name:</th>
        <th>Action</th>
      </tr>
    </thead>
    <tbody>
        @foreach($items as $it)
        <tr>
            <td>{{ $loop->index+1 }}</td>
            <td>{{ $it->inm }}</td>
            <td>
                <a href="/item-edit/{{ $it->id }}" class="btn btn-sm btn-info">Edit</a>

                <form action="/item-delete/{{$it->id}}" method="post">
                  @csrf
                  @method('delete')
                <button class="btn btn-sm btn-danger" >Delete</button>
                </form>
            </td>
        </tr>
        @endforeach
    </tbody>
  </table>
</div>

</body>
</html>