Exemplo n.º 1
0
 public function update(AnnoucementRequest $request, Annoucement $annoucement)
 {
     if (!Helper::getMode()) {
         return redirect()->back()->withErrors(config('constants.DISABLE_MESSAGE'));
     }
     if (!Entrust::can('edit_annoucement')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     $data = $request->all();
     $annoucement->fill($data);
     $annoucement->save();
     $annoucement->role()->sync($request->input('role_id') ?: []);
     Helper::updateCustomField($this->form, $annoucement->id, $data);
     $activity = 'Edit an annoucement';
     Activity::log($activity);
     return redirect('/annoucement')->withSuccess(config('constants.SAVED'));
 }
Exemplo n.º 2
0
 public function update(TicketRequest $request, Ticket $ticket)
 {
     if (!Entrust::can('edit_ticket')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     if (!Helper::getMode()) {
         return redirect()->back()->withErrors(config('constants.DISABLE_MESSAGE'));
     }
     $data = $request->except('user_id');
     $ticket->fill($data)->save();
     $service_time = Helper::getServiceTime($ticket->ticket_priority);
     if ($service_time['resolution_time_type'] == 'business_hour') {
         $ticket->resolution_due_time = Helper::calculateDueTime($service_time['resolution_time'], $ticket->created_at);
     } else {
         $ticket->resolution_due_time = date('Y-m-d H:i', $service_time['resolution_time'] * 60 + strtotime($ticket->created_at));
     }
     if ($service_time['response_time_type'] == 'business_hour') {
         $ticket->response_due_time = Helper::calculateDueTime($service_time['response_time'], $ticket->created_at);
     } else {
         $ticket->response_due_time = date('Y-m-d H:i', $service_time['response_time'] * 60 + strtotime($ticket->created_at));
     }
     $ticket->save();
     Helper::updateCustomField($this->form, $ticket->id, $data);
     $ticket->assignedUser()->sync($request->input('user_id') ?: []);
     return redirect()->back()->withSuccess(config('constants.ADDED'));
 }
Exemplo n.º 3
0
 public function update(HolidayRequest $request, Holiday $holiday)
 {
     if (!Entrust::can('edit_holiday')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     if (!Helper::getMode()) {
         return redirect()->back()->withErrors(config('constants.DISABLE_MESSAGE'));
     }
     $dates = explode(',', $request->input('date'));
     if (count($dates) > 1) {
         return redirect()->back()->withErrors('Only one date can be edited at a time.');
     }
     $data = $request->all();
     $holiday->fill($data);
     $holiday->save();
     Helper::updateCustomField($this->form, $holiday->id, $data);
     $activity = 'Updated a holiday';
     Activity::log($activity);
     return redirect('/holiday')->withSuccess(config('constants.UPDATED'));
 }
Exemplo n.º 4
0
 public function update(PageRequest $request, Page $page)
 {
     if (!Entrust::can('edit_page')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     $data = $request->all();
     $page->fill($data);
     $page->page_slug = Helper::createSlug($data['page_title']);
     $page->save();
     Helper::updateCustomField($this->form, $page->id, $data);
     $activity = 'Edit a page';
     Activity::log($activity);
     return redirect('/page')->withSuccess(config('constants.SAVED'));
 }
Exemplo n.º 5
0
 public function update(UserRequest $request, User $user)
 {
     if (!Entrust::can('edit_user')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     if (!Helper::getMode()) {
         return redirect()->back()->withErrors(config('constants.DISABLE_MESSAGE'));
     }
     $profile = $user->Profile;
     $user->name = $request->input('name');
     $user->email = $request->input('email');
     $profile->department_id = $request->input('department_id') ?: null;
     $roles[] = $request->input('role_id');
     $user->roles()->sync($roles);
     $user->save();
     $profile->save();
     Helper::updateCustomField($this->form, $user->id, $request->all());
     return redirect()->back()->withSuccess(config('constants.SAVED'));
 }