Created
October 17, 2019 12:10
-
-
Save katon26/7e136c2ef4d186fe54640011d9222d37 to your computer and use it in GitHub Desktop.
EmployeeController script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Department; | |
use App\Job; | |
use App\Employee; | |
use Illuminate\Http\Request; | |
class EmployeeController extends Controller | |
{ | |
/** | |
* Display a listing of the resource. | |
* | |
* @return \Illuminate\Http\Response | |
*/ | |
public function index() | |
{ | |
$departments = Department::all(); | |
$jobs = Job::all(); | |
$employees = Employee::all(); | |
return view('employees.index',compact('employees','jobs','departments')); | |
} | |
/** | |
* Show the form for creating a new resource. | |
* | |
* @return \Illuminate\Http\Response | |
*/ | |
public function create(Request $request) | |
{ | |
Employee::create($request->all()); | |
return redirect('/employees')->with('Success','Data has been added successfully!'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment