Skip to content

Instantly share code, notes, and snippets.

@katon26
Created October 17, 2019 12:10
Show Gist options
  • Save katon26/7e136c2ef4d186fe54640011d9222d37 to your computer and use it in GitHub Desktop.
Save katon26/7e136c2ef4d186fe54640011d9222d37 to your computer and use it in GitHub Desktop.
EmployeeController script
<?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