Leave Type Approving Officer View

Create a folder called leave-type-approving-officer in resources>views

Create a file called show.blade.php in in resources>views>leave-type-approving-officer folder

leave-approving-officer

We have two sections in this view. One form to add an approving officer to the leave type. Form method is PUT. Another section is to display the list of approving officers for this leave type.

Complete source code

Note: Please use the copy button to copy the source code.

@extends('layouts.app') @section('content') <div class="container"> <h2>{{$leaveType->name}}</h2> <div class="row"> @if ($errors->any()) <div class="alert alert-danger"> <ul> @foreach ($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> @endif </div> <div class="card"> <form action="{{ route('leave_approving_officer.update', $leaveType) }}" method="post"> @method('PUT') @csrf <div class="card-body"> <div class="row"> <div class="col-sm-6"> <div class="form-group"> <label for="user_id">Approving Officer</label> <select name="user_id" id="user_id" class="form-control @error('user_id') is-invalid @enderror"> <option value="0" selected >-- Select an approving officer --</option> @foreach ($users as $user) <option value="{{ $user->id }}">{{ $user->name }}</option> @endforeach </select> </div> <div class="form-group"> <button type="submit" name="btn-submit" class="btn btn-outline-primary btn-sm">Submit</button> </div> </div> </div> </div> </form> </div> <div class="card"> <div class="card-body"> <div class="row"> @if ($approving_officers->count()) <table class="table table-striped table-bordered table-hover"> <thead> <tr> <th>Leave Type</td> <th>Approving Officer</th> <th></th> </tr> </thead> <tbody> @foreach ($approving_officers as $approving_officer) <tr> <td>{{$approving_officer->typeType}}</td> <td>{{$approving_officer->userName}}</td> <td> <form onsubmit="return confirm('Do you really want to delete it?');" action="{{ route('leave_approving_officer.delete', $approving_officer->id) }}" method="post"> @method('DELETE') @csrf <button type="submit" class="btn btn-danger btn-sm" ><i class="fa fa-times" aria-hidden="true"></i> Delete </button> </form> </td> </tr> @endforeach </tbody> </table> @else <div class="row justify-content-center"> <h3>There are no approving officer for {{$leaveType->name}}</h3> </div> @endif </div> </div> </div> </div> <script> @endsection