Commit ca2dd9e0 authored by Kenneth Kaigu's avatar Kenneth Kaigu

Add an employee to the database and display the employee to ensure that they are visible on the ui

parent cc4a1fdd
This diff is collapsed.
...@@ -60,9 +60,24 @@ class EmployeeController extends Controller ...@@ -60,9 +60,24 @@ class EmployeeController extends Controller
'nhif' => ['required'], 'nhif' => ['required'],
'nssf' => ['required'], 'nssf' => ['required'],
'employmentdate' => ['required'], 'employmentdate' => ['required'],
'gender' => ['required'], 'gender' => ['required'],
'yearsofexperience' => ['required'], 'yearsofexperience' => ['required'],
]); ]);
$employeeTest->prefix = $request->prefix;
$employeeTest->firstname = $request->firstname;
$employeeTest->middlename = $request->middlename;
$employeeTest->lastname = $request->lastname;
$employeeTest->phonenumber = $request->phonenumber;
$employeeTest->krapin = $request->krapin;
$employeeTest->nhif = $request->nhif;
$employeeTest->nssf = $request->nssf;
$employeeTest->employmentdate = $request->employmentdate;
$employeeTest->gender = $request->gender;
$employeeTest->yearsofexperience = $request->yearsofexperience;
$employeeTest->saveOrFail();
return response()->json($employeeTest);
} }
/** /**
...@@ -169,55 +184,4 @@ class EmployeeController extends Controller ...@@ -169,55 +184,4 @@ class EmployeeController extends Controller
} }
public function personalinfo(Request $request)
{
$request->validate([
'name' => 'required',
'dateofBirth' => 'required',
'relation' => 'required',
]);
$dependant = new Dependants([
'name' => $request->get('name'),
'dateofBirth' => $request->get('dateofBirth'),
'relation' => $request->get('relation'),
]);
$dependant->save();
return redirect('/employees/create')->with('success', 'Dependant has been added');
}
public function dependantedit($id)
{
$dependant = Dependants::find($id);
return redirect('/employees/create', compact('dependant'));
}
public function updateDependant(Request $request, $id)
{
$request->validate([
'name' => 'required',
'dateofBirth' => 'required',
'relation' => 'required',
]);
$dependant = Dependants::find($id);
$dependant->name = $request->get('name');
$dependant->dateofBirth = $request->get('dateofBirth');
$dependant->relation = $request->get('relation');
$dependant->save();
return redirect('/employees/create')->with('success', 'Dependant has been updated');
}
public function dependantdestroy($id)
{
$dependant = Dependants::find($id);
dd($dependant);
$dependant->delete();
return redirect('/employees/create')->with('success', 'Dependant has been deleted successfully');
}
} }
This diff is collapsed.
<!doctype html> @extends('Layout.Employeesmaster')
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head> @section('title', 'Dashboard')
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> @section('content')
<div class="scrollable padder">
<title>Laravel</title> <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
<li><a href=""><i class="fa fa-home"></i> Home</a></li>
<!-- Fonts --> <li class="active">Dashboard</li>
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet" type="text/css"> </ul>
<div class="m-b-md">
<!-- Styles --> <h3 class="m-b-none">Dashboard</h3>
<style> <small>Welcome back, User Name</small>
html, body { </div>
background-color: #fff; <section class="panel panel-default">
color: #636b6f; <div class="row m-l-none m-r-none bg-light lter">
font-family: 'Nunito', sans-serif; <div class="col-sm-6 col-md-3 padder-v b-r b-light">
font-weight: 200; <span class="fa-stack fa-2x pull-left m-r-sm">
height: 100vh; <i class="fa fa-circle fa-stack-2x text-info"></i>
margin: 0; <i class="fa fa-male fa-stack-1x text-white"></i>
} </span>
<a class="clear" href="#">
.full-height { <span class="h3 block m-t-xs"><strong>{{ \App\EmployeeTest::all()->count() }}</strong></span>
height: 100vh; <small class="text-muted text-uc">Employees</small>
} </a>
</div>
.flex-center { </div>
align-items: center; </section>
display: flex; </div>
justify-content: center; @endsection
}
.position-ref {
position: relative;
}
.top-right {
position: absolute;
right: 10px;
top: 18px;
}
.content {
text-align: center;
}
.title {
font-size: 84px;
}
.links > a {
color: #636b6f;
padding: 0 25px;
font-size: 13px;
font-weight: 600;
letter-spacing: .1rem;
text-decoration: none;
text-transform: uppercase;
}
.m-b-md {
margin-bottom: 30px;
}
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
@if (Route::has('login'))
<div class="top-right links">
@auth
<a href="{{ url('/home') }}">Home</a>
@else
<a href="{{ route('login') }}">Login</a>
@if (Route::has('register'))
<a href="{{ route('register') }}">Register</a>
@endif
@endauth
</div>
@endif
</div>
</div>
</body>
</html>
...@@ -2,137 +2,92 @@ ...@@ -2,137 +2,92 @@
@section('title', 'Employees') @section('title', 'Employees')
<style> <style>
#import_file{ #import_file {
-webkit-appearance:none; -webkit-appearance: none;
position:absolute; position: absolute;
top:0; top: 0;
left:0; left: 0;
opacity:0; opacity: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
</style> </style>
@section('content') @section('content')
<section id="content"> <section id="content">
<section class="scrollable padder"> <section class="scrollable padder">
<ul class="breadcrumb no-border no-radius b-b b-light pull-in"> <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
<li><a href="."><i class="fa fa-home"></i> Home</a></li> <li><a href="."><i class="fa fa-home"></i> Home</a></li>
<li class="active">Employees</li> <li class="active">Employees</li>
</ul> </ul>
<div class=container-fluid>
@if ( session('success') ) <div class=row style="float:right;position:relative">
<div class="alert alert-success alert-dismissible" role="alert"> <div class=col-md-3 style=width:49.5%>
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> <a href="{{ route('export') }}">
<span aria-hidden="true">×</span> <button class="btn btn-success">Download Excel xls</button>
<span class="sr-only">Close</span> </a>
</button> </div>
<strong>{{ session('success') }}</strong> <div class=col-md-3 style=width:49.5%>
</div> <form action="{{ route('import') }}" method="POST" enctype="multipart/form-data"
@endif id="importForm">
{{ csrf_field() }}
@if (session('error')) <input type="file" name="file" class="form-control" id="import_file">
<div class="alert alert-danger alert-dismissible" role="alert"> <input type="submit" class="btn btn-success" value="Import File">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> </form>
<span aria-hidden="true">×</span> </div>
<span class="sr-only">Close</span> </div>
</button> <div class=row>
<strong>{{ session('error') }}</strong> <legend style="padding:25px 5px 5px 10px">Employees</legend>
</div> <div class="pull-right" style="margin:5px 20px 5px 10px;">
@endif <a href="{{ route('employees.create') }}" class="btn btn-info btn-sm"><i class="fa fa-plus"></i>Add
Employee</a>
@if (count($errors) > 0) </div>
<div class="alert alert-danger"> </div>
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a> <div class=row style="padding:0px 5px 5px 10px">
<div> <div class="table-responsive" style="padding:0px 5px 5px 10px">
@foreach ($errors->all() as $error) <table class="table table-striped m-b-sm datagrid">
<p>{{ $error }}</p> <thead>
@endforeach <tr>
</div> <th>Action</th>
</div> <th>First Name</th>
@endif <th>Last Name</th>
<div class=container-fluid> <th>Email</th>
<div class=row style="float:right;position:relative"> <th>Phone No.</th>
<div class=col-md-3 style=width:49.5%> </tr>
<a href="{{ route('export') }}"><button class="btn btn-success">Download Excel xls</button></a> </thead>
</div> <tbody>
<div class=col-md-3 style=width:49.5%> @foreach(\App\EmployeeTest::all() as $employee)
<form action="{{ route('import') }}" method="POST" enctype="multipart/form-data" id="importForm"> <tr>
{{ csrf_field() }} <td>
<input type="file" name="file" class="form-control" id="import_file" > <a href=""><span class="btn btn-default btn-sm"><i class="fa fa-eye no-margin"></i></span></a>
<input type="submit" class="btn btn-success" value="Import File" > <a href=""><span class="btn btn-default btn-sm"><i class="fa fa-edit no-margin"></i></span></a>
</form>
</div>
</div>
<div class=row>
<legend style="padding:25px 5px 5px 10px">Employees</legend>
<div class="pull-right" style="margin:5px 20px 5px 10px;">
<a href="{{ route('employees.create') }}" class="btn btn-info btn-sm"><i class="fa fa-plus"></i>Add Employee</a>
</div>
</div>
<div class=row style="padding:0px 5px 5px 10px">
<div class="table-responsive" style="padding:0px 5px 5px 10px">
<table class="table table-striped m-b-sm datagrid">
<thead>
<tr>
<th>Action</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Phone No.</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href=""><span class="btn btn-default btn-sm"><i class="fa fa-eye no-margin"></i></span></a>
<a href=""><span class="btn btn-default btn-sm"><i class="fa fa-edit no-margin"></i></span></a>
</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="2" class="text-center">Nothing to display</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
<script>
var form = document.getElementById('importForm');
var input = document.getElementById('import_file');
var change_running = false;
input.addEventListener('change', function(){
if(!change_running){
setTimeout(function(){
change_running = true;
form.submit();
change_running = false;
}, 300);
}
});
</script>
@endsection
@section('footer-include')
<!-- fuelux -->
<script src="/js/libs/underscore-min.js"></script>
<script src="/js/fuelux/fuelux.js"></script>
{{--<script src="js/fuelux/demo.datagrid.js"></script>--}}
<!-- select2 -->
@endsection
@section('j-script') </td>
<!-- Jquery --> <td>{{ $employee->firstname }} {{ $employee->middlename }} </td>
<td>{{ $employee->lastname }}</td>
<td>{{ $employee->email ?? '' }}</td>
<td>{{ $employee->phonenumber }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</section>
</section>
<script> <script>
$(document).on('ready', function(){ var form = document.getElementById('importForm');
var input = document.getElementById('import_file');
var change_running = false;
input.addEventListener('change', function () {
if (!change_running) {
setTimeout(function () {
change_running = true;
form.submit();
change_running = false;
}, 300);
}
}); });
</script> </script>
@endsection
@endsection
\ No newline at end of file
...@@ -263,6 +263,6 @@ ...@@ -263,6 +263,6 @@
<script src="{{asset('js/bootstrap.js')}}"></script> <script src="{{asset('js/bootstrap.js')}}"></script>
<script src="{{ asset('js/app.js') }}"></script> <script src="{{ asset('js/app.js') }}"></script>
<!-- App --> <!-- App -->
{{--<script src="{{asset('js/app.kinetic.js')}}"></script>--}} <script src="{{asset('js/app.kinetic.js')}}"></script>
</body> </body>
</html> </html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment