Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 36 |
| DepartmentController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 7 |
72 | |
0.00% |
0 / 36 |
| index | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 8 |
|||
| create | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
| store | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 10 |
|||
| show | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| edit | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
| update | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 7 |
|||
| destroy | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
| <?php | |
| namespace App\Http\Controllers\Admin; | |
| use App\department_table; | |
| use Illuminate\Http\Request; | |
| use App\Http\Controllers\Controller; | |
| use App\Models\Admin\Department; | |
| use Illuminate\Support\Facades\Validator; | |
| use Session; | |
| use App\Helpers\AttendanceHelper; | |
| class DepartmentController extends Controller | |
| { | |
| /** | |
| * Display a listing of the resource. | |
| * | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function index(Request $request) | |
| { | |
| $title = '/Setup/Department'; | |
| $backurl = route('home'); | |
| $departments = Department::orderBy('created_at','DESC')->get(); | |
| // For Attendance Marking | |
| $val = AttendanceHelper::getAttendanceMarkValue(); | |
| $valTeam = AttendanceHelper::getAttendanceTeam($request); | |
| $valUser = AttendanceHelper::getAttendanceUser($request); | |
| return view('administrationForms.Department.DepartmentTable', compact('title','backurl', | |
| 'val','valTeam','valUser'))->with('departments',$departments); | |
| } | |
| /** | |
| * Show the form for creating a new resource. | |
| * | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function create() | |
| { | |
| $home= 'Home'; | |
| $title = '/Setup/Create Department'; | |
| return view('administrationForms.Department.Department',compact('home','title')); | |
| } | |
| /** | |
| * Store a newly created resource in storage. | |
| * | |
| * @param \Illuminate\Http\Request $request | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function store(Request $request) | |
| { | |
| $this->validate($request,[ | |
| 'department' => 'required|max:190', | |
| ]); | |
| $input= $request->input('department'); | |
| $department = Department::where('department', $input)->first(); | |
| if($department) | |
| { | |
| Session::flash('warning', 'Department Name Already Exist!'); | |
| return redirect()->route('department.index')->withErrors($this); | |
| } | |
| else | |
| { | |
| Department::create($request->only(['department'])); | |
| Session::flash('success', ' Department Added Successfully!'); | |
| return redirect()->route('department.index')->withErrors($this); | |
| } | |
| } | |
| /** | |
| * Display the specified resource. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function show($id) | |
| { | |
| // | |
| } | |
| /** | |
| * Show the form for editing the specified resource. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function edit($id) | |
| { | |
| $title = '/Setup/Edit Department'; | |
| $departments = Department::find($id); | |
| Session::flash('warning', 'Edit Department!'); | |
| return view('administrationForms.Department.Department', compact('departments','title'))->with('department',Department::find($id)); | |
| } | |
| /** | |
| * Update the specified resource in storage. | |
| * | |
| * @param \Illuminate\Http\Request $request | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function update(Request $request) | |
| { | |
| $this->validate($request,[ | |
| 'department' => 'required|unique:departments,department', | |
| ]); | |
| $id = $request->id; | |
| $departments = Department::find($id); | |
| $departments->update($request->only(['department'])); | |
| Session::flash('success', 'Department Updated Successfully!'); | |
| return redirect()->route('department.index')->withErrors($this); | |
| } | |
| /** | |
| * Remove the specified resource from storage. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function destroy($id) | |
| { | |
| $department = Department::find($id); | |
| $department->delete(); | |
| return redirect()->route('department.index')->with('success','Department Deleted Successfully'); | |
| } | |
| } |