-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSeniorityDesignationController.php
37 lines (34 loc) · 1.41 KB
/
SeniorityDesignationController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\designation;
class SeniorityDesignationController extends Controller
{
//seniority Designation Data View
public function viewdata(){
$seniority = designation::Orderby('seniority')->get();
$max = designation::orderby('seniority')->max('seniority');
$count = designation::count('*');
return view('pages.designation.SeniorityDesignation.seniorityDesignation')->with('seniority' , $seniority)->with('max', $max)->with('count',$count);
}
//Seniority Save Data
public function saveSeniority($id ,Request $request){
$seniority = designation::where('id', '=', $id)->first();
$seniorityold = designation::where('seniority' == $seniority->seniority ? true : null )->get();
if($seniorityold == true){
//its value duplicate so if now return page
return redirect('/seniority_designation');
}else{
//its value not duplicate so if insert value and return page
$seniority->seniority = $request->seniority;
$seniority->update();
return redirect('/seniority_designation');
}
}
public function deleteSeniority($id){
$seniority = designation::where('id', '=', $id)->first();
$seniority->seniority = '0';
$seniority->update();
return redirect('/seniority_designation');
}
}