Laravel Code
Laravel Code
PHP
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\employeecontroller;
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class,
'index'])->name('home');
Route::middleware('auth')->group(function () {
Route::view('about', 'about')->name('about');
Route::get('employee', [App\Http\Controllers\employeecontroller::class,
'index']);
Route::post('employee', [App\Http\Controllers\employeecontroller::class,
'index']);
Route::get('users', [\App\Http\Controllers\UserController::class,
'index'])->name('users.index');
Route::get('employee', [\App\Http\Controllers\employeecontroller::class,
'index'])->name('employee.index');
Route::get('employee/create',
[App\Http\Controllers\employeecontroller::class,
'create'])->name('employee.create');;
Route::post('employee', [App\Http\Controllers\employeecontroller::class,
'store'])->name('employee.store');
Route::get('employee/{id}/edit',
[App\Http\Controllers\employeecontroller::class,
'edit'])->name('employee.edit');
Route::put('employee/{id}/edit',
[App\Http\Controllers\employeecontroller::class,
'update'])->name('employee.update');
Route::get('employee/{id}/delete',
[App\Http\Controllers\employeecontroller::class,
'destroy'])->name('employee.delete');
Route::get('profile', [\App\Http\Controllers\ProfileController::class,
'show'])->name('profile.show');
Route::put('profile', [\App\Http\Controllers\ProfileController::class,
'update'])->name('profile.update');
});
EMPLOYEE INDEX
@extends('layouts.app')
@section('content')
<div class="card-head">
</div>
<div class="card-body">
<thead>
<tr>
<th>ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Middle Name</th>
<th>Age</th>
<th>Address</th>
<th>Zip</th>
</tr>
</thead>
<tbody >
@foreach ($employees as $items)
<tr>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="card-footer">
</div>
EMPLOYEE CONTROLLER
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Fascades\DB;
use Response;
use Illuminate\Http\Request;
use App\Models\employee;
]);
employee::create($request->all());
return view ('employee.create');
}
]);
employee::findOrFail($id)->update($request->all());
return redirect ()->back()->with('status','Employee Updated
Successfully!');
}
}