:3
This commit is contained in:
37
resources/views/employees/create.blade.php
Normal file
37
resources/views/employees/create.blade.php
Normal file
@ -0,0 +1,37 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h1>Add New Employee</h1>
|
||||
|
||||
<form action="{{ route('employees.store') }}" method="POST">
|
||||
@csrf
|
||||
<div class="mb-3">
|
||||
<label for="first_name" class="form-label">First Name</label>
|
||||
<input type="text" class="form-control" id="first_name" name="first_name" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="last_name" class="form-label">Last Name</label>
|
||||
<input type="text" class="form-control" id="last_name" name="last_name" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="company_id" class="form-label">Company</label>
|
||||
<select class="form-select" id="company_id" name="company_id" required>
|
||||
<option value="">Select Company</option>
|
||||
@foreach($companies as $company)
|
||||
<option value="{{ $company->id }}">{{ $company->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email</label>
|
||||
<input type="email" class="form-control" id="email" name="email">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="phone" class="form-label">Phone</label>
|
||||
<input type="text" class="form-control" id="phone" name="phone">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Save Employee</button>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
37
resources/views/employees/edit.blade.php
Normal file
37
resources/views/employees/edit.blade.php
Normal file
@ -0,0 +1,37 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h1>Edit Employee</h1>
|
||||
|
||||
<form action="{{ route('employees.update', $employee) }}" method="POST">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<div class="mb-3">
|
||||
<label for="first_name" class="form-label">First Name</label>
|
||||
<input type="text" class="form-control" id="first_name" name="first_name" value="{{ old('first_name', $employee->first_name) }}" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="last_name" class="form-label">Last Name</label>
|
||||
<input type="text" class="form-control" id="last_name" name="last_name" value="{{ old('last_name', $employee->last_name) }}" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="company_id" class="form-label">Company</label>
|
||||
<select class="form-select" id="company_id" name="company_id" required>
|
||||
@foreach($companies as $company)
|
||||
<option value="{{ $company->id }}" {{ $employee->company_id == $company->id ? 'selected' : '' }}>{{ $company->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email</label>
|
||||
<input type="email" class="form-control" id="email" name="email" value="{{ old('email', $employee->email) }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="phone" class="form-label">Phone</label>
|
||||
<input type="text" class="form-control" id="phone" name="phone" value="{{ old('phone', $employee->phone) }}">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Update Employee</button>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
48
resources/views/employees/index.blade.php
Normal file
48
resources/views/employees/index.blade.php
Normal file
@ -0,0 +1,48 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h1>Employees</h1>
|
||||
<a href="{{ route('employees.create') }}" class="btn btn-primary mb-3">Add Employee</a>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>First Name</th>
|
||||
<th>Last Name</th>
|
||||
<th>Company</th>
|
||||
<th>Email</th>
|
||||
<th>Phone</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($employees as $employee)
|
||||
<tr>
|
||||
<td>{{ $employee->first_name }}</td>
|
||||
<td>{{ $employee->last_name }}</td>
|
||||
<td>
|
||||
@if ($employee->company)
|
||||
{{ $employee->company->name }}
|
||||
@else
|
||||
N/A
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $employee->email }}</td>
|
||||
<td>{{ $employee->phone }}</td>
|
||||
<td>
|
||||
<a href="{{ route('employees.show', $employee) }}" class="btn btn-info btn-sm">View</a>
|
||||
<a href="{{ route('employees.edit', $employee) }}" class="btn btn-warning btn-sm">Edit</a>
|
||||
<form action="{{ route('employees.destroy', $employee) }}" method="POST" style="display:inline;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
{{ $employees->links() }}
|
||||
</div>
|
||||
@endsection
|
15
resources/views/employees/show.blade.php
Normal file
15
resources/views/employees/show.blade.php
Normal file
@ -0,0 +1,15 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h1>Employee Details</h1>
|
||||
<ul>
|
||||
<li>First Name: {{ $employee->first_name }}</li>
|
||||
<li>Last Name: {{ $employee->last_name }}</li>
|
||||
<li>Company: {{ $employee->company->name ?? 'N/A' }}</li>
|
||||
<li>Email: {{ $employee->email }}</li>
|
||||
<li>Phone: {{ $employee->phone }}</li>
|
||||
</ul>
|
||||
<a href="{{ route('employees.index') }}" class="btn btn-primary">Back to List</a>
|
||||
</div>
|
||||
@endsection
|
Reference in New Issue
Block a user