Applied fixes from StyleCI
This commit is contained in:

committed by
StyleCI Bot

parent
be5df5334f
commit
d637c2b23f
@@ -9,46 +9,50 @@ use App\Http\Requests\helpdesk\DepartmentRequest;
|
||||
use App\Http\Requests\helpdesk\DepartmentUpdate;
|
||||
// model
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Agent\Groups;
|
||||
use App\Model\helpdesk\Agent\Group_assign_department;
|
||||
use App\Model\helpdesk\Agent\Groups;
|
||||
use App\Model\helpdesk\Agent\Teams;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Email\Template;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Manage\Sla_plan;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\User;
|
||||
// classes
|
||||
use DB;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* DepartmentController
|
||||
* DepartmentController.
|
||||
*
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class DepartmentController extends Controller {
|
||||
|
||||
class DepartmentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index page
|
||||
* Get index page.
|
||||
*
|
||||
* @param type Department $department
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function index(Department $department) {
|
||||
public function index(Department $department)
|
||||
{
|
||||
try {
|
||||
$departments = $department->get();
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.departments.index', compact('departments'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
@@ -57,16 +61,19 @@ class DepartmentController extends Controller {
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @param type User $user
|
||||
*
|
||||
* @param type User $user
|
||||
* @param type Group_assign_department $group_assign_department
|
||||
* @param type Department $department
|
||||
* @param type Sla_plan $sla
|
||||
* @param type Template $template
|
||||
* @param type Emails $email
|
||||
* @param type Groups $group
|
||||
* @param type Department $department
|
||||
* @param type Sla_plan $sla
|
||||
* @param type Template $template
|
||||
* @param type Emails $email
|
||||
* @param type Groups $group
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function create(User $user, Group_assign_department $group_assign_department, Department $department, Sla_plan $sla, Template $template, Emails $email, Groups $group) {
|
||||
public function create(User $user, Group_assign_department $group_assign_department, Department $department, Sla_plan $sla, Template $template, Emails $email, Groups $group)
|
||||
{
|
||||
try {
|
||||
$slas = $sla->get();
|
||||
$user = $user->where('role', 'agent')->get();
|
||||
@@ -74,6 +81,7 @@ class DepartmentController extends Controller {
|
||||
$templates = $template->get();
|
||||
$department = $department->get();
|
||||
$groups = $group->lists('id', 'name');
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.departments.create', compact('department', 'templates', 'slas', 'user', 'emails', 'groups'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
@@ -82,11 +90,14 @@ class DepartmentController extends Controller {
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param type Department $department
|
||||
*
|
||||
* @param type Department $department
|
||||
* @param type DepartmentRequest $request
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function store(Department $department, DepartmentRequest $request) {
|
||||
public function store(Department $department, DepartmentRequest $request)
|
||||
{
|
||||
try {
|
||||
$department->fill($request->except('group_id', 'manager'))->save();
|
||||
$requests = $request->input('group_id');
|
||||
@@ -113,18 +124,21 @@ class DepartmentController extends Controller {
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
* @param type Group_assign_department $group_assign_department
|
||||
* @param type Template $template
|
||||
* @param type Teams $team
|
||||
* @param type Department $department
|
||||
* @param type Sla_plan $sla
|
||||
* @param type Emails $email
|
||||
* @param type Groups $group
|
||||
* @param type Template $template
|
||||
* @param type Teams $team
|
||||
* @param type Department $department
|
||||
* @param type Sla_plan $sla
|
||||
* @param type Emails $email
|
||||
* @param type Groups $group
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function edit($id, User $user, Group_assign_department $group_assign_department, Template $template, Teams $team, Department $department, Sla_plan $sla, Emails $email, Groups $group) {
|
||||
public function edit($id, User $user, Group_assign_department $group_assign_department, Template $template, Teams $team, Department $department, Sla_plan $sla, Emails $email, Groups $group)
|
||||
{
|
||||
try {
|
||||
$slas = $sla->get();
|
||||
$user = $user->where('role', 'agent')->get();
|
||||
@@ -133,6 +147,7 @@ class DepartmentController extends Controller {
|
||||
$departments = $department->whereId($id)->first();
|
||||
$groups = $group->lists('id', 'name');
|
||||
$assign = $group_assign_department->where('department_id', $id)->lists('group_id');
|
||||
|
||||
return view('themes.default1.admin.helpdesk.agent.departments.edit', compact('assign', 'team', 'templates', 'departments', 'slas', 'user', 'emails', 'groups'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
@@ -141,13 +156,16 @@ class DepartmentController extends Controller {
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param type int $id
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type Group_assign_department $group_assign_department
|
||||
* @param type Department $department
|
||||
* @param type DepartmentUpdate $request
|
||||
* @param type Department $department
|
||||
* @param type DepartmentUpdate $request
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function update($id, Group_assign_department $group_assign_department, Department $department, DepartmentUpdate $request) {
|
||||
public function update($id, Group_assign_department $group_assign_department, Department $department, DepartmentUpdate $request)
|
||||
{
|
||||
// dd($id);
|
||||
try {
|
||||
$table = $group_assign_department->where('department_id', $id);
|
||||
@@ -177,12 +195,15 @@ class DepartmentController extends Controller {
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param type int $id
|
||||
* @param type Department $department
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type Department $department
|
||||
* @param type Group_assign_department $group_assign_department
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function destroy($id, Department $department, Group_assign_department $group_assign_department, System $system, Tickets $tickets) {
|
||||
public function destroy($id, Department $department, Group_assign_department $group_assign_department, System $system, Tickets $tickets)
|
||||
{
|
||||
// try {
|
||||
$system = $system->where('id', '=', '1')->first();
|
||||
if ($system->department == $id) {
|
||||
@@ -191,54 +212,53 @@ class DepartmentController extends Controller {
|
||||
$tickets = DB::table('tickets')->where('dept_id', '=', $id)->update(['dept_id' => $system->department]);
|
||||
if ($tickets > 0) {
|
||||
if ($tickets > 1) {
|
||||
$text_tickets = "Tickets";
|
||||
$text_tickets = 'Tickets';
|
||||
} else {
|
||||
$text_tickets = "Ticket";
|
||||
$text_tickets = 'Ticket';
|
||||
}
|
||||
$ticket = '<li>' . $tickets . ' ' . $text_tickets . ' have been moved to default department</li>';
|
||||
$ticket = '<li>'.$tickets.' '.$text_tickets.' have been moved to default department</li>';
|
||||
} else {
|
||||
$ticket = "";
|
||||
$ticket = '';
|
||||
}
|
||||
$users = DB::table('users')->where('primary_dpt', '=', $id)->update(['primary_dpt' => $system->department]);
|
||||
if ($users > 0) {
|
||||
if ($users > 1) {
|
||||
$text_user = "Users";
|
||||
$text_user = 'Users';
|
||||
} else {
|
||||
$text_user = "User";
|
||||
$text_user = 'User';
|
||||
}
|
||||
$user = '<li>' . $users . ' ' . $text_user . ' have been moved to default department</li>';
|
||||
$user = '<li>'.$users.' '.$text_user.' have been moved to default department</li>';
|
||||
} else {
|
||||
$user = "";
|
||||
$user = '';
|
||||
}
|
||||
$emails = DB::table('emails')->where('department', '=', $id)->update(['department' => $system->department]);
|
||||
if ($emails > 0) {
|
||||
if ($emails > 1) {
|
||||
$text_emails = "Emails";
|
||||
$text_emails = 'Emails';
|
||||
} else {
|
||||
$text_emails = "Email";
|
||||
$text_emails = 'Email';
|
||||
}
|
||||
$email = '<li>' . $emails . ' System ' . $text_emails . ' have been moved to default department</li>';
|
||||
$email = '<li>'.$emails.' System '.$text_emails.' have been moved to default department</li>';
|
||||
} else {
|
||||
$email = "";
|
||||
$email = '';
|
||||
}
|
||||
$helptopic = DB::table('help_topic')->where('department', '=', $id)->update(['department' => null], ['status' => '1']);
|
||||
if ($helptopic > 0) {
|
||||
$helptopic = '<li>The associated helptopic has been deactivated</li>';
|
||||
} else {
|
||||
$helptopic = "";
|
||||
$helptopic = '';
|
||||
}
|
||||
$message = $ticket . $user . $email . $helptopic;
|
||||
$message = $ticket.$user.$email.$helptopic;
|
||||
/* Becouse of foreign key we delete group_assign_department first */
|
||||
$group_assign_department = $group_assign_department->where('department_id', $id);
|
||||
$group_assign_department->delete();
|
||||
$departments = $department->whereId($id)->first();
|
||||
/* Check the function is Success or Fail */
|
||||
if ($departments->delete() == true) {
|
||||
return redirect('departments')->with('success', 'Department Deleted sucessfully' . $message);
|
||||
return redirect('departments')->with('success', 'Department Deleted sucessfully'.$message);
|
||||
} else {
|
||||
return redirect('departments')->with('fails', 'Department can not Delete');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user