Applied fixes from StyleCI

This commit is contained in:
Sujit Prasad
2016-08-05 09:24:12 -04:00
committed by StyleCI Bot
parent 09bf25b5e2
commit e2390f67d4
53 changed files with 1397 additions and 1105 deletions

View File

@@ -29,14 +29,15 @@ use Lang;
*
* @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');
}
@@ -48,9 +49,11 @@ class DepartmentController extends Controller {
*
* @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');
@@ -70,7 +73,8 @@ class DepartmentController extends Controller {
*
* @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', 'agent2')->get();
@@ -93,7 +97,8 @@ class DepartmentController extends Controller {
*
* @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', 'sla'))->save();
if ($request->sla) {
@@ -116,6 +121,7 @@ class DepartmentController extends Controller {
->where('id', 1)
->update(['department' => $department->id]);
}
return redirect('departments')->with('success', Lang::get('lang.department_created_sucessfully'));
} else {
return redirect('departments')->with('fails', Lang::get('lang.failed_to_create_department'));
@@ -140,7 +146,8 @@ class DepartmentController extends Controller {
*
* @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 {
$sys_department = \DB::table('settings_system')
->select('department')
@@ -170,7 +177,8 @@ class DepartmentController extends Controller {
*
* @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);
@@ -218,9 +226,10 @@ class DepartmentController extends Controller {
*
* @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) {
return redirect('departments')->with('fails', Lang::get('lang.you_cannot_delete_default_department'));
@@ -232,7 +241,7 @@ class DepartmentController extends Controller {
} else {
$text_tickets = 'Ticket';
}
$ticket = '<li>' . $tickets . ' ' . $text_tickets . Lang::get('lang.have_been_moved_to_default_department') . '</li>';
$ticket = '<li>'.$tickets.' '.$text_tickets.Lang::get('lang.have_been_moved_to_default_department').'</li>';
} else {
$ticket = '';
}
@@ -243,7 +252,7 @@ class DepartmentController extends Controller {
} else {
$text_user = 'User';
}
$user = '<li>' . $users . ' ' . $text_user . Lang::get('lang.have_been_moved_to_default_department') . '</li>';
$user = '<li>'.$users.' '.$text_user.Lang::get('lang.have_been_moved_to_default_department').'</li>';
} else {
$user = '';
}
@@ -254,28 +263,27 @@ class DepartmentController extends Controller {
} else {
$text_emails = 'Email';
}
$email = '<li>' . $emails . ' System ' . $text_emails . Lang::get('lang.have_been_moved_to_default_department') . ' </li>';
$email = '<li>'.$emails.' System '.$text_emails.Lang::get('lang.have_been_moved_to_default_department').' </li>';
} else {
$email = '';
}
$helptopic = DB::table('help_topic')->where('department', '=', $id)->update(['department' => null], ['status' => '1']);
if ($helptopic > 0) {
$helptopic = '<li>' . Lang::get('lang.the_associated_helptopic_has_been_deactivated') . '</li>';
$helptopic = '<li>'.Lang::get('lang.the_associated_helptopic_has_been_deactivated').'</li>';
} else {
$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', Lang::get('lang.department_deleted_sucessfully') . $message);
return redirect('departments')->with('success', Lang::get('lang.department_deleted_sucessfully').$message);
} else {
return redirect('departments')->with('fails', Lang::get('lang.department_can_not_delete'));
}
}
}
}