UserGroupController.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use Illuminate\Http\Request;
  4. use App\Http\Requests;
  5. use App\Http\Controllers\Controller;
  6. use App\User;
  7. use App\Models\Group;
  8. class UserGroupController extends Controller
  9. {
  10. public function index(){
  11. $data['title'] = "User group";
  12. $data['all'] = Group::where('depend_on',0)->orderBy('depend_on')->get();
  13. $data['all_user'] = User::where('active',1)->get();
  14. $data['all_group'] = Group::where('user_id',0)->get();
  15. return view('admin.user_group',$data);
  16. /*
  17. 1=Created;
  18. 2=in process;
  19. 3=Completed;
  20. 4=checking;
  21. 5=bugfixing;
  22. 5=done;
  23. */
  24. }
  25. public function add_group_user(Request $req){
  26. $type = $req->type;
  27. $group_name = $req->group_name;
  28. $group_id = $req->group_id;
  29. $user_id = $req->user_id;
  30. $designation = $req->designation;
  31. if($type == 1){
  32. $sav = new Group;
  33. $sav->group_name = $group_name;
  34. $sav->save();
  35. }
  36. elseif($type == 2){
  37. $sav = new Group;
  38. $sav->user_id = $user_id;
  39. $sav->depend_on = $group_id;
  40. $sav->designation = $designation;
  41. $sav->active = 1;
  42. $sav->save();
  43. }
  44. else{
  45. }
  46. return redirect()->back()->with('msg','Saved successfully !');
  47. }
  48. public function remove_group_user($id){
  49. $del = Group::find($id)->delete();
  50. return redirect()->back()->with('msg','Removed successfully !');
  51. }
  52. }