/** * Display a listing of the resource. * * @return Response */ public function home() { $now = Carbon::now(); $now = $now->toDateTimeString(); $result = Call::orderBy('id', 'DECS')->first(); $created_at = Carbon::parse($result->created_at); $endDate = $created_at->addSeconds(3); $created_atf = $endDate->toDateTimeString(); $results = Call::with('User', 'Student', 'Student.Category')->orderBy('id', 'DECS')->paginate(6); return view('home.home', compact('results', 'created_atf', 'now')); }
/** * Display a listing of the resource. * * @return Response */ public function index(Requestt $request) { $vm = $this->vm; $ic_cr = $this->ic_cr; $ec_cn = $this->ec_cn; $in_aet_re_tr = $this->in_aet_re_tr; $sd_dg = $this->sd_dg; $dr = $this->dr; //$now = Carbon::now(); //$now = $now->toDateString(); //$query = ['date' => $now]; $query = Request::all(); $reports = \DB::table('calls')->select('calls.user_id', 'users.full_name', 'users.type_id', 'students.category_id', 'categories.description', DB::raw('COUNT(calls.user_id) as total_calls_category', 'COUNT(students.category_id) as total_category'))->where('users.type_id', 2)->groupBy('calls.user_id')->groupBy('students.category_id')->join('users', 'users.id', '=', 'calls.user_id')->join('students', 'students.id', '=', 'calls.student_id')->join('categories', 'categories.id', '=', 'students.category_id')->get(); $id = 0; //$repor = Call::with('user')->date($request->get('date'))-> $results = Call::with('user')->date($request->get('date'))->select(['user_id', 'student_id', DB::raw('COUNT(student_id) as total_calls')])->groupBy('user_id')->orderBy('total_calls', 'DECS')->paginate(10); return view('ticket.report.index', compact('results', 'reports', 'id', 'query', 'vm', 'ic_cr', 'ec_cn', 'in_aet_re_tr', 'sd_dg', 'dr')); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(CreateCallRequest $request) { $query = Call::studentid($request->get('student_id'))->get(); $id = 0; foreach ($query as $querys) { $id = $querys->id; } if ($id == 0) { $results = Call::create($request->all()); $message = 'El Ticket #' . $results->student_id . ' Fue Llamado Con Exito'; } else { $results = Call::findOrFail($id); $results->delete(); $results = Call::create($request->all()); $message = 'El Ticket # ' . $results->student_id . ' Fue Eliminado y Fue Llamado Con Exito'; } Session::flash('message', $message); return \Redirect::back(); }