ClientController.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Http\Controllers\Client;
  3. use Illuminate\Http\Request;
  4. use App\Http\Requests;
  5. use App\Http\Controllers\Controller;
  6. use App\Models\Task;
  7. use App\Models\Note;
  8. use App\Models\AssignProject;
  9. use Auth;
  10. use App\Models\Ticket;
  11. class ClientController extends Controller
  12. {
  13. public function index(){
  14. return "Client Profile";
  15. }
  16. public function client_dashboard(){
  17. $data['title'] = "Client dashboard";
  18. $user_id = Auth::user()->id;
  19. $data['notes'] = Note::where('user_id',$user_id)->orderBy('time')->get();
  20. $chk = AssignProject::where('user_id',$user_id)->distinct('proj_id')->get();
  21. $proj_id_ary = array();
  22. if(count($chk) > 0)
  23. {
  24. foreach($chk as $info)
  25. {
  26. array_push($proj_id_ary, $info->proj_id);
  27. }
  28. $data['created_task'] = Task::whereIn('proj_id',$proj_id_ary)->where('status',1)->get();
  29. $data['inprocess_task'] = Task::whereIn('proj_id',$proj_id_ary)->where('status',2)->get();
  30. }
  31. $client_id=\Auth::user()->id;
  32. if(\Auth::user()->utype==3)
  33. {
  34. $data['tickets']=Ticket::with(['user','created_user'])->where('client_id',$client_id)->orderBy('id','desc')->get();
  35. } else {
  36. $data['tickets']=Ticket::with(['user','created_user'])->orderBy('id','desc')->get();
  37. }
  38. return view('client.client_dashboard',$data);
  39. }
  40. }