diff --git a/app/Commands/Command.php b/app/Commands/Command.php index 018bc2192..c9b0a33a6 100644 --- a/app/Commands/Command.php +++ b/app/Commands/Command.php @@ -1,7 +1,8 @@ -comment(PHP_EOL.Inspiring::quote().PHP_EOL); - } + /** + * The console command description. + * + * @var string + */ + protected $description = 'Display an inspiring quote'; + /** + * Execute the console command. + * + * @return mixed + */ + public function handle() + { + $this->comment(PHP_EOL.Inspiring::quote().PHP_EOL); + } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index cb183d946..bce2f0715 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -1,37 +1,38 @@ -command('inspire') + ->hourly(); - /** - * Define the application's command schedule. - * - * @param \Illuminate\Console\Scheduling\Schedule $schedule - * @return void - */ - protected function schedule(Schedule $schedule) - { - $schedule->command('inspire') - ->hourly(); - - $schedule->call(function () { - - $user = new User; - $user->save(); - - })->everyFiveMinutes(); + $schedule->call(function () { - } + $user = new User(); + $user->save(); + })->everyFiveMinutes(); + } } diff --git a/app/Events/ClientTicketForm.php b/app/Events/ClientTicketForm.php index ab534034e..4288c16c4 100644 --- a/app/Events/ClientTicketForm.php +++ b/app/Events/ClientTicketForm.php @@ -1,27 +1,25 @@ -para1 = $para1; - $this->para2 = $para2; - $this->para3 = $para3; - $this->para4 = $para4; - $this->para5 = $para5; - - } + public $para1; + public $para2; + public $para3; + public $para4; + public $para5; + public function __construct($para1 = '', $para2 = '', $para3 = '', $para4 = '', $para5 = '') + { + $this->para1 = $para1; + $this->para2 = $para2; + $this->para3 = $para3; + $this->para4 = $para4; + $this->para5 = $para5; + } } diff --git a/app/Events/ClientTicketFormPost.php b/app/Events/ClientTicketFormPost.php index ae045d75a..f242c5f5d 100644 --- a/app/Events/ClientTicketFormPost.php +++ b/app/Events/ClientTicketFormPost.php @@ -1,28 +1,25 @@ -para1 = $para1; - $this->para2 = $para2; - $this->para3 = $para3; - $this->para4 = $para4; - $this->para5 = $para5; - - } +class ClientTicketFormPost extends Event +{ + use SerializesModels; + public $para1; + public $para2; + public $para3; + public $para4; + public $para5; + public function __construct($para1 = '', $para2 = '', $para3 = '', $para4 = '', $para5 = '') + { + $this->para1 = $para1; + $this->para2 = $para2; + $this->para3 = $para3; + $this->para4 = $para4; + $this->para5 = $para5; + } } diff --git a/app/Events/Event.php b/app/Events/Event.php index d59f7690f..ba2f88838 100644 --- a/app/Events/Event.php +++ b/app/Events/Event.php @@ -1,7 +1,8 @@ -para1 = $para1; - $this->para2 = $para2; - $this->para3 = $para3; - $this->para4 = $para4; - $this->para5 = $para5; - } - +class FaveoAfterReply extends Event +{ + use SerializesModels; + public $para1; + public $para2; + public $para3; + public $para4; + public $para5; + /** + * Create a new event instance. + * + * @return void + */ + public function __construct($para1 = '', $para2 = '', $para3 = '', $para4 = '', $para5 = '') + { + $this->para1 = $para1; + $this->para2 = $para2; + $this->para3 = $para3; + $this->para4 = $para4; + $this->para5 = $para5; + } } diff --git a/app/Events/FormRegisterEvent.php b/app/Events/FormRegisterEvent.php index fe0bc0f51..c5398916f 100644 --- a/app/Events/FormRegisterEvent.php +++ b/app/Events/FormRegisterEvent.php @@ -1,31 +1,30 @@ -para1 = $para1; - $this->para2 = $para2; - $this->para3 = $para3; - $this->para4 = $para4; - $this->para5 = $para5; - } + public $para1; + public $para2; + public $para3; + public $para4; + public $para5; + /** + * Create a new event instance. + * + * @return void + */ + public function __construct($para1 = '', $para2 = '', $para3 = '', $para4 = '', $para5 = '') + { + $this->para1 = $para1; + $this->para2 = $para2; + $this->para3 = $para3; + $this->para4 = $para4; + $this->para5 = $para5; + } } diff --git a/app/Events/LoginEvent.php b/app/Events/LoginEvent.php index 899084513..486a8f8c8 100644 --- a/app/Events/LoginEvent.php +++ b/app/Events/LoginEvent.php @@ -1,31 +1,29 @@ -para1 = $para1; - $this->para2 = $para2; - $this->para3 = $para3; - $this->para4 = $para4; - $this->para5 = $para5; - } - +class LoginEvent extends Event +{ + use SerializesModels; + public $para1; + public $para2; + public $para3; + public $para4; + public $para5; + /** + * Create a new event instance. + * + * @return void + */ + public function __construct($para1 = '', $para2 = '', $para3 = '', $para4 = '', $para5 = '') + { + $this->para1 = $para1; + $this->para2 = $para2; + $this->para3 = $para3; + $this->para4 = $para4; + $this->para5 = $para5; + } } diff --git a/app/Events/PostRegisterEvent.php b/app/Events/PostRegisterEvent.php index 1d116ace7..e75f90c7d 100644 --- a/app/Events/PostRegisterEvent.php +++ b/app/Events/PostRegisterEvent.php @@ -1,30 +1,29 @@ -para1 = $para1; - $this->para2 = $para2; - $this->para3 = $para3; - $this->para4 = $para4; - $this->para5 = $para5; - } +class PostRegisterEvent extends Event +{ + use SerializesModels; + public $para1; + public $para2; + public $para3; + public $para4; + public $para5; + /** + * Create a new event instance. + * + * @return void + */ + public function __construct($para1 = '', $para2 = '', $para3 = '', $para4 = '', $para5 = '') + { + $this->para1 = $para1; + $this->para2 = $para2; + $this->para3 = $para3; + $this->para4 = $para4; + $this->para5 = $para5; + } } diff --git a/app/Events/ReadMailEvent.php b/app/Events/ReadMailEvent.php index f3c6b7cbd..9ecaf66ae 100644 --- a/app/Events/ReadMailEvent.php +++ b/app/Events/ReadMailEvent.php @@ -1,31 +1,29 @@ -para1 = $para1; - $this->para2 = $para2; - $this->para3 = $para3; - $this->para4 = $para4; - $this->para5 = $para5; - } - +class ReadMailEvent extends Event +{ + use SerializesModels; + public $para1; + public $para2; + public $para3; + public $para4; + public $para5; + /** + * Create a new event instance. + * + * @return void + */ + public function __construct($para1 = '', $para2 = '', $para3 = '', $para4 = '', $para5 = '') + { + $this->para1 = $para1; + $this->para2 = $para2; + $this->para3 = $para3; + $this->para4 = $para4; + $this->para5 = $para5; + } } diff --git a/app/Events/TicketBoxHeader.php b/app/Events/TicketBoxHeader.php index 05c78ae48..4a2d4a4b1 100644 --- a/app/Events/TicketBoxHeader.php +++ b/app/Events/TicketBoxHeader.php @@ -1,30 +1,29 @@ -para1 = $para1; - $this->para2 = $para2; - $this->para3 = $para3; - $this->para4 = $para4; - $this->para5 = $para5; - } +class TicketBoxHeader extends Event +{ + use SerializesModels; + public $para1; + public $para2; + public $para3; + public $para4; + public $para5; + /** + * Create a new event instance. + * + * @return void + */ + public function __construct($para1 = '', $para2 = '', $para3 = '', $para4 = '', $para5 = '') + { + $this->para1 = $para1; + $this->para2 = $para2; + $this->para3 = $para3; + $this->para4 = $para4; + $this->para5 = $para5; + } } diff --git a/app/Events/TicketDetailTable.php b/app/Events/TicketDetailTable.php index b5f05a84a..e630efd07 100644 --- a/app/Events/TicketDetailTable.php +++ b/app/Events/TicketDetailTable.php @@ -1,30 +1,29 @@ -para1 = $para1; - $this->para2 = $para2; - $this->para3 = $para3; - $this->para4 = $para4; - $this->para5 = $para5; - } +class TicketDetailTable extends Event +{ + use SerializesModels; + public $para1; + public $para2; + public $para3; + public $para4; + public $para5; + /** + * Create a new event instance. + * + * @return void + */ + public function __construct($para1 = '', $para2 = '', $para3 = '', $para4 = '', $para5 = '') + { + $this->para1 = $para1; + $this->para2 = $para2; + $this->para3 = $para3; + $this->para4 = $para4; + $this->para5 = $para5; + } } diff --git a/app/Events/TimeLineFormEvent.php b/app/Events/TimeLineFormEvent.php index 3417a1773..b795dd585 100644 --- a/app/Events/TimeLineFormEvent.php +++ b/app/Events/TimeLineFormEvent.php @@ -1,30 +1,29 @@ -para1 = $para1; - $this->para2 = $para2; - $this->para3 = $para3; - $this->para4 = $para4; - $this->para5 = $para5; - } +class TimeLineFormEvent extends Event +{ + use SerializesModels; + public $para1; + public $para2; + public $para3; + public $para4; + public $para5; + /** + * Create a new event instance. + * + * @return void + */ + public function __construct($para1 = '', $para2 = '', $para3 = '', $para4 = '', $para5 = '') + { + $this->para1 = $para1; + $this->para2 = $para2; + $this->para3 = $para3; + $this->para4 = $para4; + $this->para5 = $para5; + } } diff --git a/app/Events/Timeline.php b/app/Events/Timeline.php index 52cb947ba..e8ba8c913 100644 --- a/app/Events/Timeline.php +++ b/app/Events/Timeline.php @@ -1,31 +1,30 @@ -para1 = $para1; - $this->para2 = $para2; - $this->para3 = $para3; - $this->para4 = $para4; - $this->para5 = $para5; - } + public $para1; + public $para2; + public $para3; + public $para4; + public $para5; + /** + * Create a new event instance. + * + * @return void + */ + public function __construct($para1 = '', $para2 = '', $para3 = '', $para4 = '', $para5 = '') + { + $this->para1 = $para1; + $this->para2 = $para2; + $this->para3 = $para3; + $this->para4 = $para4; + $this->para5 = $para5; + } } diff --git a/app/Events/TopNavEvent.php b/app/Events/TopNavEvent.php index 74c56f7e5..019681f79 100644 --- a/app/Events/TopNavEvent.php +++ b/app/Events/TopNavEvent.php @@ -1,21 +1,20 @@ -json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]); //dd($e); - } else if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) { + } elseif ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) { return response()->json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]); } @@ -81,13 +85,13 @@ class Handler extends ExceptionHandler { return parent::render($request, $e); } - protected function renderExceptionWithWhoops(Exception $e) { - $whoops = new \Whoops\Run; + protected function renderExceptionWithWhoops(Exception $e) + { + $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); return new \Illuminate\Http\Response( $whoops->handleException($e), $e->getStatusCode(), $e->getHeaders() ); } - } diff --git a/app/Http/Controllers/Admin/helpdesk/AgentController.php b/app/Http/Controllers/Admin/helpdesk/AgentController.php index d2158967a..b8ca005af 100644 --- a/app/Http/Controllers/Admin/helpdesk/AgentController.php +++ b/app/Http/Controllers/Admin/helpdesk/AgentController.php @@ -3,47 +3,47 @@ namespace App\Http\Controllers\Admin\helpdesk; // controller -use App\Http\Controllers\Controller; -use App\Http\Controllers\Common\SettingsController; use App\Http\Controllers\Common\PhpMailController; +use App\Http\Controllers\Common\SettingsController; +use App\Http\Controllers\Controller; // request use App\Http\Requests\helpdesk\AgentRequest; use App\Http\Requests\helpdesk\AgentUpdate; // model -use App\User; use App\Model\helpdesk\Agent\Assign_team_agent; use App\Model\helpdesk\Agent\Department; use App\Model\helpdesk\Agent\Groups; use App\Model\helpdesk\Agent\Teams; -use App\Model\helpdesk\Utility\Timezones; +use App\Model\helpdesk\Email\Emails; use App\Model\helpdesk\Settings\Company; use App\Model\helpdesk\Settings\Email; -use App\Model\helpdesk\Email\Emails; +use App\Model\helpdesk\Utility\Timezones; +use App\User; // classes use DB; -use Mail; -use Hash; use Exception; +use Hash; +use Mail; /** * AgentController - * This controller is used to CRUD category + * This controller is used to CRUD category. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class AgentController extends Controller { - +class AgentController extends Controller +{ /** * Create a new controller instance. * constructor to check * 1. authentication * 2. user roles - * 3. roles must be agent + * 3. roles must be agent. + * * @return void */ - public function __construct(PhpMailController $PhpMailController) { + public function __construct(PhpMailController $PhpMailController) + { $this->PhpMailController = $PhpMailController; SettingsController::smtp(); // checking authentication @@ -53,11 +53,14 @@ class AgentController extends Controller { } /** - * Get all agent list page + * Get all agent list page. + * * @param type User $user + * * @return type Response */ - public function index() { + public function index() + { try { return view('themes.default1.admin.helpdesk.agent.agents.index'); } catch (Exception $e) { @@ -66,21 +69,25 @@ class AgentController extends Controller { } /** - * creating a new agent + * creating a new agent. + * * @param type Assign_team_agent $team_assign_agent - * @param type Timezones $timezone - * @param type Groups $group - * @param type Department $department - * @param type Teams $team + * @param type Timezones $timezone + * @param type Groups $group + * @param type Department $department + * @param type Teams $team + * * @return type view */ - public function create(Assign_team_agent $team_assign_agent, Timezones $timezone, Groups $group, Department $department, Teams $team) { + public function create(Assign_team_agent $team_assign_agent, Timezones $timezone, Groups $group, Department $department, Teams $team) + { try { $team = $team->get(); $timezones = $timezone->get(); $groups = $group->get(); $departments = $department->get(); $teams = $team->lists('id', 'name'); + return view('themes.default1.admin.helpdesk.agent.agents.create', compact('assign', 'teams', 'agents', 'timezones', 'groups', 'departments', 'team')); } catch (Exception $e) { return redirect()->back()->with('fails', $e->errorInfo[2]); @@ -88,13 +95,16 @@ class AgentController extends Controller { } /** - * store a new agent - * @param type User $user - * @param type AgentRequest $request + * store a new agent. + * + * @param type User $user + * @param type AgentRequest $request * @param type Assign_team_agent $team_assign_agent + * * @return type Response */ - public function store(User $user, AgentRequest $request, Assign_team_agent $team_assign_agent) { + public function store(User $user, AgentRequest $request, Assign_team_agent $team_assign_agent) + { // dd($this->system_mail()); @@ -120,6 +130,7 @@ class AgentController extends Controller { } catch (Exception $e) { return redirect('agents')->with('fails', 'Some error occured while sending mail to the agent. Please check email settings and try again'); } + return redirect('agents')->with('success', 'Agent Created sucessfully'); } else { return redirect('agents')->with('fails', 'Agent can not Create'); @@ -127,17 +138,20 @@ class AgentController extends Controller { } /** - * Editing a selected agent - * @param type int $id - * @param type User $user + * Editing a selected agent. + * + * @param type int $id + * @param type User $user * @param type Assign_team_agent $team_assign_agent - * @param type Timezones $timezone - * @param type Groups $group - * @param type Department $department - * @param type Teams $team + * @param type Timezones $timezone + * @param type Groups $group + * @param type Department $department + * @param type Teams $team + * * @return type Response */ - public function edit($id, User $user, Assign_team_agent $team_assign_agent, Timezones $timezone, Groups $group, Department $department, Teams $team) { + public function edit($id, User $user, Assign_team_agent $team_assign_agent, Timezones $timezone, Groups $group, Department $department, Teams $team) + { try { $user = $user->whereId($id)->first(); $team = $team->get(); @@ -148,6 +162,7 @@ class AgentController extends Controller { $table = $team_assign_agent->where('agent_id', $id)->first(); $teams = $team->lists('id', 'name'); $assign = $team_assign_agent->where('agent_id', $id)->lists('team_id'); + return view('themes.default1.admin.helpdesk.agent.agents.edit', compact('teams', 'assign', 'table', 'teams1', 'selectedTeams', 'user', 'timezones', 'groups', 'departments', 'team', 'exp', 'counted')); } catch (Exception $e) { return redirect('agents')->with('fail', 'No such file'); @@ -156,13 +171,16 @@ class AgentController extends Controller { /** * Update the specified agent in storage. - * @param type int $id - * @param type User $user - * @param type AgentUpdate $request + * + * @param type int $id + * @param type User $user + * @param type AgentUpdate $request * @param type Assign_team_agent $team_assign_agent + * * @return type Response */ - public function update($id, User $user, AgentUpdate $request, Assign_team_agent $team_assign_agent) { + public function update($id, User $user, AgentUpdate $request, Assign_team_agent $team_assign_agent) + { // storing all the details $user = $user->whereId($id)->first(); @@ -181,20 +199,24 @@ class AgentController extends Controller { //Todo For success and failure conditions try { $user->fill($request->except('daylight_save', 'limit_access', 'directory_listing', 'vocation_mode', 'assign_team'))->save(); + return redirect('agents')->with('success', 'Agent Updated sucessfully'); } catch (Exception $e) { - return redirect('agents')->with('fails', 'Agent did not update' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('agents')->with('fails', 'Agent did not update'.'
  • '.$e->errorInfo[2].'
  • '); } } /** * Remove the specified agent from storage. - * @param type int $id - * @param type User $user + * + * @param type int $id + * @param type User $user * @param type Assign_team_agent $team_assign_agent + * * @return type Response */ - public function destroy($id, User $user, Assign_team_agent $team_assign_agent) { + public function destroy($id, User $user, Assign_team_agent $team_assign_agent) + { /* Becouse of foreign key we delete team_assign_agent first */ error_reporting(E_ALL & ~E_NOTICE); $team_assign_agent = $team_assign_agent->where('agent_id', $id); @@ -205,43 +227,52 @@ class AgentController extends Controller { $user->id; $user->delete(); throw new \Exception($error); + return redirect('agents')->with('success', 'Agent Deleted sucessfully'); } catch (\Exception $e) { dd($e->errorInfo); + return redirect('agents')->with('fails', $error); } } /** - * Generate a random string for password + * Generate a random string for password. + * * @param type $length + * * @return type string */ - public function generateRandomString($length = 10) { + public function generateRandomString($length = 10) + { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } + return $randomString; } /** - * Fetching comapny name to send mail + * Fetching comapny name to send mail. + * * @return type */ - public function company() { + public function company() + { $company = Company::Where('id', '=', '1')->first(); if ($company->company_name == null) { - $company = "Support Center"; + $company = 'Support Center'; } else { $company = $company->company_name; } + return $company; } - /** + /* * System default email */ // public function system_mail() { diff --git a/app/Http/Controllers/Admin/helpdesk/BanlistController.php b/app/Http/Controllers/Admin/helpdesk/BanlistController.php index ae7c32730..29b05d4a7 100644 --- a/app/Http/Controllers/Admin/helpdesk/BanlistController.php +++ b/app/Http/Controllers/Admin/helpdesk/BanlistController.php @@ -8,29 +8,30 @@ use App\Http\Controllers\Controller; use App\Http\Requests\helpdesk\BanlistRequest; use App\Http\Requests\helpdesk\BanRequest; // model -use App\User; use App\Model\helpdesk\Email\Banlist; +use App\User; //classes use Exception; /** * BanlistController - * In this controller in the CRUD function for all the banned emails - * @package Controllers - * @subpackage Controller + * In this controller in the CRUD function for all the banned emails. + * * @author Ladybird */ -class BanlistController extends Controller { - +class BanlistController extends Controller +{ /** * Create a new controller instance. * constructor to check * 1. authentication * 2. user roles - * 3. roles must be agent + * 3. roles must be agent. + * * @return void */ - public function __construct() { + public function __construct() + { // checking authentication $this->middleware('auth'); // checking admin roles @@ -39,12 +40,16 @@ class BanlistController extends Controller { /** * Display a listing of the resource. + * * @param type Banlist $ban + * * @return type Response */ - public function index() { + public function index() + { try { $bans = User::where('ban', '=', 1)->get(); + return view('themes.default1.admin.helpdesk.emails.banlist.index', compact('bans')); } catch (Exception $e) { return view('404'); @@ -53,9 +58,11 @@ class BanlistController extends Controller { /** * Show the form for creating a new resource. + * * @return type Response */ - public function create() { + public function create() + { try { return view('themes.default1.admin.helpdesk.emails.banlist.create'); } catch (Exception $e) { @@ -65,12 +72,15 @@ class BanlistController extends Controller { /** * Store a newly created resource in storage. - * @param type banlist $ban + * + * @param type banlist $ban * @param type BanRequest $request - * @param type User $user + * @param type User $user + * * @return type Response */ - public function store(BanRequest $request, User $user) { + public function store(BanRequest $request, User $user) + { // dd($request); try { //adding field to user whether it is banned or not @@ -83,11 +93,12 @@ class BanlistController extends Controller { // $user->create($request->input())->save(); return redirect('banlist')->with('success', 'Email Banned sucessfully'); } else { - $user = new User; + $user = new User(); $user->email = $adban; $user->ban = $request->input('ban'); $user->internal_note = $request->input('internal_note'); $user->save(); + return redirect('banlist')->with('success', 'Email Banned sucessfully'); } } catch (Exception $e) { @@ -98,22 +109,28 @@ class BanlistController extends Controller { /** * Display the specified resource. * - * @param int $id + * @param int $id + * * @return Response */ - public function show($id) { + public function show($id) + { // } /** * Show the form for editing the specified resource. - * @param type int $id + * + * @param type int $id * @param type Banlist $ban + * * @return type Response */ - public function edit($id, User $ban) { + public function edit($id, User $ban) + { try { $bans = $ban->whereId($id)->first(); + return view('themes.default1.admin.helpdesk.emails.banlist.edit', compact('bans')); } catch (Exception $e) { return view('404'); @@ -122,12 +139,15 @@ class BanlistController extends Controller { /** * Update the specified resource in storage. - * @param type int $id - * @param type Banlist $ban + * + * @param type int $id + * @param type Banlist $ban * @param type BanlistRequest $request + * * @return type Response */ - public function update($id, User $ban, BanlistRequest $request) { + public function update($id, User $ban, BanlistRequest $request) + { try { $bans = $ban->whereId($id)->first(); $bans->internal_note = $request->input('internal_note'); @@ -143,7 +163,7 @@ class BanlistController extends Controller { } } - /** + /* * Remove the specified resource from storage. * @param type int $id * @param type Banlist $ban diff --git a/app/Http/Controllers/Admin/helpdesk/DepartmentController.php b/app/Http/Controllers/Admin/helpdesk/DepartmentController.php index b6122cb21..749eb942f 100644 --- a/app/Http/Controllers/Admin/helpdesk/DepartmentController.php +++ b/app/Http/Controllers/Admin/helpdesk/DepartmentController.php @@ -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 */ -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 = '
  • ' . $tickets . ' ' . $text_tickets . ' have been moved to default department
  • '; + $ticket = '
  • '.$tickets.' '.$text_tickets.' have been moved to default department
  • '; } 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 = '
  • ' . $users . ' ' . $text_user . ' have been moved to default department
  • '; + $user = '
  • '.$users.' '.$text_user.' have been moved to default department
  • '; } 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 = '
  • ' . $emails . ' System ' . $text_emails . ' have been moved to default department
  • '; + $email = '
  • '.$emails.' System '.$text_emails.' have been moved to default department
  • '; } else { - $email = ""; + $email = ''; } $helptopic = DB::table('help_topic')->where('department', '=', $id)->update(['department' => null], ['status' => '1']); if ($helptopic > 0) { $helptopic = '
  • The associated helptopic has been deactivated
  • '; } 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'); } } } - } diff --git a/app/Http/Controllers/Admin/helpdesk/EmailsController.php b/app/Http/Controllers/Admin/helpdesk/EmailsController.php index c8259403c..a4a10f8ab 100644 --- a/app/Http/Controllers/Admin/helpdesk/EmailsController.php +++ b/app/Http/Controllers/Admin/helpdesk/EmailsController.php @@ -11,39 +11,43 @@ use App\Http\Requests\helpdesk\EmailsRequest; use App\Model\helpdesk\Agent\Department; use App\Model\helpdesk\Email\Emails; use App\Model\helpdesk\Manage\Help_topic; -use App\Model\helpdesk\Utility\MailboxProtocol; -use App\Model\helpdesk\Ticket\Ticket_Priority; use App\Model\helpdesk\Settings\Email; +use App\Model\helpdesk\Ticket\Ticket_Priority; +use App\Model\helpdesk\Utility\MailboxProtocol; // classes use Crypt; use Exception; /** - * EmailsController + * EmailsController. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class EmailsController extends Controller { - +class EmailsController extends Controller +{ /** * Create a new controller instance. + * * @return type */ - public function __construct() { + public function __construct() + { $this->middleware('auth'); $this->middleware('roles'); } /** * Display a listing of the resource. + * * @param type Emails $emails + * * @return type Response */ - public function index(Emails $emails) { + public function index(Emails $emails) + { try { $emails = $emails->get(); + return view('themes.default1.admin.helpdesk.emails.emails.index', compact('emails')); } catch (Exception $e) { return view('404'); @@ -52,18 +56,22 @@ class EmailsController extends Controller { /** * Show the form for creating a new resource. - * @param type Department $department - * @param type Help_topic $help - * @param type Priority $priority + * + * @param type Department $department + * @param type Help_topic $help + * @param type Priority $priority * @param type MailboxProtocol $mailbox_protocol + * * @return type Response */ - public function create(Department $department, Help_topic $help, Ticket_Priority $priority, MailboxProtocol $mailbox_protocol) { + public function create(Department $department, Help_topic $help, Ticket_Priority $priority, MailboxProtocol $mailbox_protocol) + { try { $departments = $department->get(); $helps = $help->get(); $priority = $priority->get(); $mailbox_protocols = $mailbox_protocol->get(); + return view('themes.default1.admin.helpdesk.emails.emails.create', compact('mailbox_protocols', 'priority', 'departments', 'helps')); } catch (Exception $e) { return view('404'); @@ -72,11 +80,14 @@ class EmailsController extends Controller { /** * Store a newly created resource in storage. - * @param type Emails $email + * + * @param type Emails $email * @param type EmailsRequest $request + * * @return type Response */ - public function store(Emails $email, EmailsRequest $request) { + public function store(Emails $email, EmailsRequest $request) + { try { $password = $request->input('password'); $encrypted = Crypt::encrypt($password); @@ -115,30 +126,36 @@ class EmailsController extends Controller { /** * Display the specified resource. * - * @param int $id + * @param int $id + * * @return Response */ - public function show($id) { + public function show($id) + { // } /** * Show the form for editing the specified resource. - * @param type int $id - * @param type Department $department - * @param type Help_topic $help - * @param type Emails $email - * @param type Priority $priority + * + * @param type int $id + * @param type Department $department + * @param type Help_topic $help + * @param type Emails $email + * @param type Priority $priority * @param type MailboxProtocol $mailbox_protocol + * * @return type Response */ - public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $priority, MailboxProtocol $mailbox_protocol) { + public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $priority, MailboxProtocol $mailbox_protocol) + { try { $emails = $email->whereId($id)->first(); $departments = $department->get(); $helps = $help->get(); $priority = $priority->get(); $mailbox_protocols = $mailbox_protocol->get(); + return view('themes.default1.admin.helpdesk.emails.emails.edit', compact('mailbox_protocols', 'priority', 'departments', 'helps', 'emails')); } catch (Exception $e) { return view('404'); @@ -147,12 +164,15 @@ class EmailsController extends Controller { /** * Update the specified resource in storage. - * @param type $id - * @param type Emails $email + * + * @param type $id + * @param type Emails $email * @param type EmailsEditRequest $request + * * @return type Response */ - public function update($id, Emails $email, EmailsEditRequest $request) { + public function update($id, Emails $email, EmailsEditRequest $request) + { $password = $request->input('password'); $encrypted = Crypt::encrypt($password); //echo $encrypted; @@ -179,6 +199,7 @@ class EmailsController extends Controller { } $emails->password = $encrypted; $emails->save(); + return redirect('emails')->with('success', 'Email Updated sucessfully'); } catch (Exception $e) { return redirect('emails')->with('fails', 'Email not updated'); @@ -187,11 +208,14 @@ class EmailsController extends Controller { /** * Remove the specified resource from storage. - * @param type int $id + * + * @param type int $id * @param type Emails $email + * * @return type Response */ - public function destroy($id, Emails $email) { + public function destroy($id, Emails $email) + { $default_system_email = Email::where('id', '=', '1')->first(); if ($default_system_email->id) { if ($id == $default_system_email->id) { @@ -209,5 +233,4 @@ class EmailsController extends Controller { return redirect('emails')->with('fails', 'Email can not Delete '); } } - } diff --git a/app/Http/Controllers/Admin/helpdesk/FormController.php b/app/Http/Controllers/Admin/helpdesk/FormController.php index 4aa013c55..786c87546 100644 --- a/app/Http/Controllers/Admin/helpdesk/FormController.php +++ b/app/Http/Controllers/Admin/helpdesk/FormController.php @@ -13,58 +13,66 @@ use Illuminate\Http\Request; // Class use Input; use Redirect; -use Exception; /** * FormController - * This controller is used to CRUD Custom Forms + * This controller is used to CRUD Custom Forms. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class FormController extends Controller { - +class FormController extends Controller +{ private $fields; private $forms; - public function __construct(Fields $fields, Forms $forms) { + public function __construct(Fields $fields, Forms $forms) + { $this->fields = $fields; $this->forms = $forms; // $this->middleware('auth'); } /** - * home + * home. + * * @return type */ - public function home() { + public function home() + { return view('forms.home'); } /** - * list of forms - * @param type Forms $forms + * list of forms. + * + * @param type Forms $forms + * * @return Response */ - public function index(Forms $forms) { + public function index(Forms $forms) + { return view('themes.default1.admin.helpdesk.manage.form.index', compact('forms')); } /** * Show the form for creating a new resource. + * * @return Response */ - public function create() { + public function create() + { return view('themes.default1.admin.helpdesk.manage.form.form'); } /** * Display the specified resource. - * @param int $id + * + * @param int $id + * * @return Response */ - public function show($id) { + public function show($id) + { return view('themes.default1.admin.helpdesk.manage.form.preview', compact('id')); } @@ -73,13 +81,14 @@ class FormController extends Controller { * * @return Response */ - public function store(Forms $forms) { + public function store(Forms $forms) + { if (!Input::get('formname')) { return Redirect::back()->with('fails', 'Please fill Form name'); } $required = Input::get('required'); $count = count($required); - $require = array(); + $require = []; for ($i = 2; $i < $count + 2; $i++) { for ($j = 0; $j < 1; $j++) { array_push($require, $required[$i][$j]); @@ -88,24 +97,26 @@ class FormController extends Controller { $forms->formname = Input::get('formname'); $forms->save(); $count = count(Input::get('name')); - $fields = array(); + $fields = []; for ($i = 0; $i <= $count; $i++) { if (!empty(Input::get('name')[$i])) { - array_push($fields, array( + array_push($fields, [ 'forms_id' => $forms->id, - 'label' => Input::get('label')[$i], - 'name' => Input::get('name')[$i], - 'type' => Input::get('type')[$i], - 'value' => Input::get('value')[$i], + 'label' => Input::get('label')[$i], + 'name' => Input::get('name')[$i], + 'type' => Input::get('type')[$i], + 'value' => Input::get('value')[$i], 'required' => $require[$i], - )); + ]); } } Fields::insert($fields); + return Redirect::back()->with('success', 'Successfully created Form'); } - public function delete($id, Forms $forms, Fields $field, Help_topic $help_topic) { + public function delete($id, Forms $forms, Fields $field, Help_topic $help_topic) + { $fields = $field->where('forms_id', $id)->get(); $help_topics = $help_topic->where('custom_form', '=', $id)->get(); foreach ($help_topics as $help_topic) { @@ -117,7 +128,7 @@ class FormController extends Controller { } $forms = $forms->where('id', $id)->first(); $forms->delete(); + return redirect()->back()->with('success', 'Deleted Successfully'); } - } diff --git a/app/Http/Controllers/Admin/helpdesk/GroupController.php b/app/Http/Controllers/Admin/helpdesk/GroupController.php index 139b55b54..9e8392cc7 100644 --- a/app/Http/Controllers/Admin/helpdesk/GroupController.php +++ b/app/Http/Controllers/Admin/helpdesk/GroupController.php @@ -6,45 +6,49 @@ namespace App\Http\Controllers\Admin\helpdesk; use App\Http\Controllers\Controller; // requests use App\Http\Requests\helpdesk\GroupRequest; -use Illuminate\Http\Request; -// models use App\Model\helpdesk\Agent\Department; -use App\Model\helpdesk\Agent\Groups; +// models use App\Model\helpdesk\Agent\Group_assign_department; +use App\Model\helpdesk\Agent\Groups; use App\User; -// classes -use Illuminate\Support\Facades\Input; use Exception; +// classes +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Input; /** - * GroupController + * GroupController. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class GroupController extends Controller { - +class GroupController extends Controller +{ /** * Create a new controller instance. + * * @return type void */ - public function __construct() { + public function __construct() + { $this->middleware('auth'); $this->middleware('roles'); } /** * Display a listing of the resource. - * @param type Groups $group - * @param type Department $department + * + * @param type Groups $group + * @param type Department $department * @param type Group_assign_department $group_assign_department + * * @return type Response */ - public function index(Groups $group, Department $department, Group_assign_department $group_assign_department) { + public function index(Groups $group, Department $department, Group_assign_department $group_assign_department) + { try { $groups = $group->get(); $departments = $department->lists('id'); + return view('themes.default1.admin.helpdesk.agent.groups.index', compact('departments', 'group_assign_department', 'groups')); } catch (Exception $e) { return view('404'); @@ -53,9 +57,11 @@ class GroupController extends Controller { /** * Show the form for creating a new resource. + * * @return type Response */ - public function create() { + public function create() + { try { return view('themes.default1.admin.helpdesk.agent.groups.create'); } catch (Exception $e) { @@ -65,44 +71,55 @@ class GroupController extends Controller { /** * Store a newly created resource in storage. - * @param type Groups $group + * + * @param type Groups $group * @param type GroupRequest $request + * * @return type Response */ - public function store(Groups $group, GroupRequest $request) { + public function store(Groups $group, GroupRequest $request) + { try { /* Check Whether function success or not */ $group->fill($request->input())->save(); + return redirect('groups')->with('success', 'Group Created Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('groups')->with('fails', 'Groups can not Create' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('groups')->with('fails', 'Groups can not Create'.'
  • '.$e->errorInfo[2].'
  • '); } } /** * Show the form for editing the specified resource. - * @param type int $id + * + * @param type int $id * @param type Groups $group + * * @return type Response */ - public function edit($id, Groups $group) { + public function edit($id, Groups $group) + { try { $groups = $group->whereId($id)->first(); + return view('themes.default1.admin.helpdesk.agent.groups.edit', compact('groups')); } catch (Exception $e) { - return redirect('groups')->with('fails', 'Groups can not Create' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('groups')->with('fails', 'Groups can not Create'.'
  • '.$e->errorInfo[2].'
  • '); } } /** * Update the specified resource in storage. - * @param type int $id - * @param type Groups $group + * + * @param type int $id + * @param type Groups $group * @param type Request $request + * * @return type Response */ - public function update($id, Groups $group, Request $request) { + public function update($id, Groups $group, Request $request) + { $var = $group->whereId($id)->first(); //Updating Status $status = $request->Input('group_status'); @@ -153,22 +170,26 @@ class GroupController extends Controller { return redirect('groups')->with('success', 'Group Updated Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('groups')->with('fails', 'Groups can not Create' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('groups')->with('fails', 'Groups can not Create'.'
  • '.$e->errorInfo[2].'
  • '); } } /** * Remove the specified resource from storage. - * @param type int $id - * @param type Groups $group + * + * @param type int $id + * @param type Groups $group * @param type Group_assign_department $group_assign_department + * * @return type Response */ - public function destroy($id, Groups $group, Group_assign_department $group_assign_department) { + public function destroy($id, Groups $group, Group_assign_department $group_assign_department) + { $users = User::where('assign_group', '=', $id)->first(); if ($users) { $user = '
  • There are agents assigned to this group. Please unassign them from this group to delete
  • '; - return redirect('groups')->with('fails', 'Group cannot Delete ' . $user); + + return redirect('groups')->with('fails', 'Group cannot Delete '.$user); } $group_assign_department->where('group_id', $id)->delete(); $groups = $group->whereId($id)->first(); @@ -179,8 +200,7 @@ class GroupController extends Controller { return redirect('groups')->with('success', 'Group Deleted Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('groups')->with('fails', 'Groups cannot Create' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('groups')->with('fails', 'Groups cannot Create'.'
  • '.$e->errorInfo[2].'
  • '); } } - } diff --git a/app/Http/Controllers/Admin/helpdesk/HelptopicController.php b/app/Http/Controllers/Admin/helpdesk/HelptopicController.php index c223b8965..31f3d825d 100644 --- a/app/Http/Controllers/Admin/helpdesk/HelptopicController.php +++ b/app/Http/Controllers/Admin/helpdesk/HelptopicController.php @@ -13,39 +13,43 @@ use App\Model\helpdesk\Agent\Department; use App\Model\helpdesk\Form\Forms; use App\Model\helpdesk\Manage\Help_topic; use App\Model\helpdesk\Manage\Sla_plan; -use App\Model\helpdesk\Ticket\Ticket_Priority; use App\Model\helpdesk\Settings\Ticket; +use App\Model\helpdesk\Ticket\Ticket_Priority; use App\User; // classes use DB; use Exception; /** - * HelptopicController + * HelptopicController. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class HelptopicController extends Controller { - +class HelptopicController extends Controller +{ /** * Create a new controller instance. + * * @return type vodi */ - public function __construct() { + public function __construct() + { $this->middleware('auth'); $this->middleware('roles'); } /** * Display a listing of the resource. + * * @param type Help_topic $topic + * * @return type Response */ - public function index(Help_topic $topic) { + public function index(Help_topic $topic) + { try { $topics = $topic->get(); + return view('themes.default1.admin.helpdesk.manage.helptopic.index', compact('topics')); } catch (Exception $e) { return view('404'); @@ -54,12 +58,14 @@ class HelptopicController extends Controller { /** * Show the form for creating a new resource. - * @param type Priority $priority + * + * @param type Priority $priority * @param type Department $department * @param type Help_topic $topic - * @param type Form_name $form - * @param type Agents $agent - * @param type Sla_plan $sla + * @param type Form_name $form + * @param type Agents $agent + * @param type Sla_plan $sla + * * @return type Response */ /* @@ -72,7 +78,8 @@ class HelptopicController extends Controller { | 5.Forms Model ================================================ */ - public function create(Ticket_Priority $priority, Department $department, Help_topic $topic, Forms $form, User $agent, Sla_plan $sla) { + public function create(Ticket_Priority $priority, Department $department, Help_topic $topic, Forms $form, User $agent, Sla_plan $sla) + { try { $departments = $department->get(); $topics = $topic->get(); @@ -80,6 +87,7 @@ class HelptopicController extends Controller { $agents = $agent->where('role', '=', 'agent')->get(); $slas = $sla->get(); $priority = $priority->get(); + return view('themes.default1.admin.helpdesk.manage.helptopic.create', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas')); } catch (Exception $e) { return view('404'); @@ -88,11 +96,14 @@ class HelptopicController extends Controller { /** * Store a newly created resource in storage. - * @param type Help_topic $topic + * + * @param type Help_topic $topic * @param type HelptopicRequest $request + * * @return type Response */ - public function store(Help_topic $topic, HelptopicRequest $request) { + public function store(Help_topic $topic, HelptopicRequest $request) + { try { if ($request->custom_form) { $custom_form = $request->custom_form; @@ -111,22 +122,25 @@ class HelptopicController extends Controller { return redirect('helptopic')->with('success', 'Helptopic Created Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('helptopic')->with('fails', 'Helptopic can not Create' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('helptopic')->with('fails', 'Helptopic can not Create'.'
  • '.$e->errorInfo[2].'
  • '); } } /** * Show the form for editing the specified resource. - * @param type $id - * @param type Priority $priority + * + * @param type $id + * @param type Priority $priority * @param type Department $department * @param type Help_topic $topic - * @param type Form_name $form - * @param type Agents $agent - * @param type Sla_plan $sla + * @param type Form_name $form + * @param type Agents $agent + * @param type Sla_plan $sla + * * @return type Response */ - public function edit($id, Ticket_Priority $priority, Department $department, Help_topic $topic, Forms $form, Sla_plan $sla) { + public function edit($id, Ticket_Priority $priority, Department $department, Help_topic $topic, Forms $form, Sla_plan $sla) + { try { $agents = User::where('role', '=', 'agent')->get(); $departments = $department->get(); @@ -134,20 +148,24 @@ class HelptopicController extends Controller { $forms = $form->get(); $slas = $sla->get(); $priority = $priority->get(); + return view('themes.default1.admin.helpdesk.manage.helptopic.edit', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas')); } catch (Exception $e) { - return redirect('helptopic')->with('fails', '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('helptopic')->with('fails', '
  • '.$e->errorInfo[2].'
  • '); } } /** * Update the specified resource in storage. - * @param type $id - * @param type Help_topic $topic + * + * @param type $id + * @param type Help_topic $topic * @param type HelptopicUpdate $request + * * @return type Response */ - public function update($id, Help_topic $topic, HelptopicUpdate $request) { + public function update($id, Help_topic $topic, HelptopicUpdate $request) + { // dd($request); try { $topics = $topic->whereId($id)->first(); @@ -170,61 +188,62 @@ class HelptopicController extends Controller { return redirect('helptopic')->with('success', 'Helptopic Updated Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('helptopic')->with('fails', 'Helptopic can not Update' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('helptopic')->with('fails', 'Helptopic can not Update'.'
  • '.$e->errorInfo[2].'
  • '); } } /** * Remove the specified resource from storage. - * @param type int $id + * + * @param type int $id * @param type Help_topic $topic + * * @return type Response */ - public function destroy($id, Help_topic $topic, Ticket $ticket_setting) { + public function destroy($id, Help_topic $topic, Ticket $ticket_setting) + { $ticket_settings = $ticket_setting->where('id', '=', '1')->first(); if ($ticket_settings->help_topic == $id) { return redirect('departments')->with('fails', 'You cannot delete default department'); } else { - $tickets = DB::table('tickets')->where('help_topic_id', '=', $id)->update(['help_topic_id' => $ticket_settings->help_topic]); if ($tickets > 0) { if ($tickets > 1) { - $text_tickets = "Tickets"; + $text_tickets = 'Tickets'; } else { - $text_tickets = "Ticket"; + $text_tickets = 'Ticket'; } - $ticket = '
  • ' . $tickets . ' ' . $text_tickets . ' have been moved to default Help Topic
  • '; + $ticket = '
  • '.$tickets.' '.$text_tickets.' have been moved to default Help Topic
  • '; } else { - $ticket = ""; + $ticket = ''; } $emails = DB::table('emails')->where('help_topic', '=', $id)->update(['help_topic' => $ticket_settings->help_topic]); if ($emails > 0) { if ($emails > 1) { - $text_emails = "Emails"; + $text_emails = 'Emails'; } else { - $text_emails = "Email"; + $text_emails = 'Email'; } - $email = '
  • ' . $emails . ' System ' . $text_emails . ' have been moved to default Help Topic
  • '; + $email = '
  • '.$emails.' System '.$text_emails.' have been moved to default Help Topic
  • '; } else { - $email = ""; + $email = ''; } - $message = $ticket . $email; + $message = $ticket.$email; $topics = $topic->whereId($id)->first(); /* Check whether function success or not */ try { $topics->delete(); /* redirect to Index page with Success Message */ - return redirect('helptopic')->with('success', 'Helptopic Deleted Successfully' . $message); + return redirect('helptopic')->with('success', 'Helptopic Deleted Successfully'.$message); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('helptopic')->with('fails', 'Helptopic can not Delete' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('helptopic')->with('fails', 'Helptopic can not Delete'.'
  • '.$e->errorInfo[2].'
  • '); } } } - } diff --git a/app/Http/Controllers/Admin/helpdesk/HomeController.php b/app/Http/Controllers/Admin/helpdesk/HomeController.php index 7a2744c8d..c9e942bb4 100644 --- a/app/Http/Controllers/Admin/helpdesk/HomeController.php +++ b/app/Http/Controllers/Admin/helpdesk/HomeController.php @@ -10,17 +10,17 @@ namespace App\Http\Controllers\Admin\helpdesk; * are authenticated. Of course, you are free to change or remove the * controller as you wish. It is just here to get your app started! * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class HomeController extends Controller { - +class HomeController extends Controller +{ /** * Create a new controller instance. + * * @return void */ - public function __construct() { + public function __construct() + { $this->middleware('auth'); } @@ -29,8 +29,8 @@ class HomeController extends Controller { * * @return Response */ - public function index() { + public function index() + { return view('themes/default1/admin/dashboard'); } - } diff --git a/app/Http/Controllers/Admin/helpdesk/LanguageController.php b/app/Http/Controllers/Admin/helpdesk/LanguageController.php index c66c06027..5bf526f4d 100644 --- a/app/Http/Controllers/Admin/helpdesk/LanguageController.php +++ b/app/Http/Controllers/Admin/helpdesk/LanguageController.php @@ -3,55 +3,55 @@ namespace App\Http\Controllers\Admin\helpdesk; // controllers -use App\Http\Controllers\Controller; +use App; // requests -use App\Http\Requests; -use Illuminate\Http\Request; +use App\Http\Controllers\Controller; //supports +use App\Http\Requests; +use Cache; +use Config; +//classes +use File; +use Illuminate\Support\Collection; use Illuminate\Support\Facades\Redirect; use Illuminate\Support\Facades\Session; -use Illuminate\Support\Collection; -//classes use Input; -use Config; -use Validator; -use Zipper; -use App; use Lang; -use Cache; -use File; -use Exception; +use Validator; /** - * SlaController + * SlaController. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class LanguageController extends Controller { - +class LanguageController extends Controller +{ /** * Create a new controller instance. + * * @return type void */ - public function __construct() { + public function __construct() + { $this->middleware('auth'); $this->middleware('roles'); } /** - * Switch language at runtime + * Switch language at runtime. + * * @param type "" $lang + * * @return type response */ - public function switchLanguage($lang) { + public function switchLanguage($lang) + { //if(Cache::has('language')) //{ // return Cache::get('language'); //} else return 'false'; // Cache::put('language',$) - $path = base_path('resources/lang'); // Path to check available language packages + $path = base_path('resources/lang'); // Path to check available language packages if (array_key_exists($lang, Config::get('languages')) && in_array($lang, scandir($path))) { // dd(array_key_exists($lang, Config::get('languages'))); // app()->setLocale($lang); @@ -60,55 +60,63 @@ class LanguageController extends Controller { // dd(Cache::get('language')); // dd() } else { - return Redirect::back()->with('fails', Lang::get("lang.language-error")); + return Redirect::back()->with('fails', Lang::get('lang.language-error')); } + return Redirect::back(); } /** - * Shows language page + * Shows language page. + * * @return type response */ - public function index() { + public function index() + { return view('themes.default1.admin.helpdesk.language.index'); } /** - * Shows Language upload form + * Shows Language upload form. + * * @return type response */ - public function getForm() { + public function getForm() + { return view('themes.default1.admin.helpdesk.language.create'); } /** - * Provide language datatable to language page - * @return type + * Provide language datatable to language page. + * + * @return type */ - public function getLanguages() { - $path = base_path('resources/lang'); + public function getLanguages() + { + $path = base_path('resources/lang'); $values = scandir($path); //Extracts names of directories present in lang directory - $values = array_slice($values, 2); // skips array element $value[0] = '.' & $value[1] = '..' + $values = array_slice($values, 2); // skips array element $value[0] = '.' & $value[1] = '..' return \Datatable::collection(new Collection($values)) - ->addColumn('language', function($model) { - return Config::get('languages.' . $model); + ->addColumn('language', function ($model) { + return Config::get('languages.'.$model); }) - ->addColumn('id', function($model) { + ->addColumn('id', function ($model) { return $model; }) - ->addColumn('status', function($model) { + ->addColumn('status', function ($model) { if (Lang::getLocale() === $model) { - return "" . Lang::trans("lang.active") . ""; - } else - return "" . Lang::trans("lang.inactive") . ""; - }) - ->addColumn('Action', function($model) { - if (Lang::getLocale() === $model) { - return " - " . Lang::trans("lang.delete") . ""; + return "".Lang::trans('lang.active').''; } else { - return " - " . Lang::trans("lang.delete") . ""; + return "".Lang::trans('lang.inactive').''; + } + }) + ->addColumn('Action', function ($model) { + if (Lang::getLocale() === $model) { + return " + ".Lang::trans('lang.delete').''; + } else { + return " + ".Lang::trans('lang.delete').''; } }) ->searchColumns('language', 'id') @@ -116,23 +124,25 @@ class LanguageController extends Controller { } /** - * handle language file uploading - * @return response + * handle language file uploading. + * + * @return response */ - public function postForm() { + public function postForm() + { // getting all of the post data - $file = array( - 'File' => Input::file('File'), + $file = [ + 'File' => Input::file('File'), 'language-name' => Input::input('language-name'), - 'iso-code' => Input::input('iso-code') - ); + 'iso-code' => Input::input('iso-code'), + ]; // setting up rules - $rules = array( - 'File' => 'required|mimes:zip|max:30000', + $rules = [ + 'File' => 'required|mimes:zip|max:30000', 'language-name' => 'required', - 'iso-code' => 'required|max:2' - ); // and for max size + 'iso-code' => 'required|max:2', + ]; // and for max size // doing the validation, passing post data, rules and the messages $validator = Validator::make($file, $rules); if ($validator->fails()) { @@ -141,18 +151,19 @@ class LanguageController extends Controller { return Redirect::back()->withInput()->withErrors($validator); } else { - //Checking if package already exists or not in lang folder - $path = base_path('resources/lang'); + $path = base_path('resources/lang'); if (in_array(strtolower(Input::get('iso-code')), scandir($path))) { //sending back with error message Session::flash('fails', Lang::get('lang.package_exist')); - Session::flash('link', "change-language/" . strtolower(Input::get('iso-code'))); + Session::flash('link', 'change-language/'.strtolower(Input::get('iso-code'))); + return Redirect::back()->withInput(); - } elseif (!array_key_exists(strtolower(Input::get('iso-code')), Config::get('languages'))) {//Checking Valid ISO code form Languages.php + } elseif (!array_key_exists(strtolower(Input::get('iso-code')), Config::get('languages'))) {//Checking Valid ISO code form Languages.php //sending back with error message Session::flash('fails', Lang::get('lang.iso-code-error')); + return Redirect::back()->withInput(); } else { @@ -160,11 +171,11 @@ class LanguageController extends Controller { if (Input::file('File')->isValid()) { $name = Input::file('File')->getClientOriginalName(); //uploaded file's original name $destinationPath = '../public/uploads/'; // defining uploading path - $extractpath = '../resources/lang/' . strtolower(Input::get('iso-code')); //defining extracting path + $extractpath = '../resources/lang/'.strtolower(Input::get('iso-code')); //defining extracting path mkdir($extractpath); //creating directroy for extracting uploadd file //mkdir($destinationPath); Input::file('File')->move($destinationPath, $name); // uploading file to given path - \Zipper::make($destinationPath . '/' . $name)->extractTo($extractpath); //extracting file to give path + \Zipper::make($destinationPath.'/'.$name)->extractTo($extractpath); //extracting file to give path //check if Zip extract foldercontains any subfolder $directories = File::directories($extractpath); //$directories = glob($extractpath. '/*' , GLOB_ONLYDIR); @@ -174,18 +185,21 @@ class LanguageController extends Controller { if ($success) { //sending back with error message Session::flash('fails', Lang::get('lang.zipp-error')); - Session::flash('link2', "http://www.ladybirdweb.com/support/show/how-to-translate-faveo-into-multiple-languages"); + Session::flash('link2', 'http://www.ladybirdweb.com/support/show/how-to-translate-faveo-into-multiple-languages'); + return Redirect::back()->withInput(); } } else { // sending back with success message - Session::flash('success', Lang::get("lang.upload-success")); - Session::flash('link', "change-language/" . strtolower(Input::get('iso-code'))); + Session::flash('success', Lang::get('lang.upload-success')); + Session::flash('link', 'change-language/'.strtolower(Input::get('iso-code'))); + return Redirect::route('LanguageController'); } } else { // sending back with error message. - Session::flash('fails', Lang::get("lang.file-error")); + Session::flash('fails', Lang::get('lang.file-error')); + return Redirect::route('form'); } } @@ -193,36 +207,43 @@ class LanguageController extends Controller { } /** - * allow user to download language template file + * allow user to download language template file. + * * @return type */ - Public function download() { + public function download() + { return response()->download('../public/downloads/en.zip'); } /** - * This function is used to delete languages - * @param type $lang + * This function is used to delete languages. + * + * @param type $lang + * * @return type response */ - public function deleteLanguage($lang) { + public function deleteLanguage($lang) + { if ($lang !== App::getLocale()) { - $deletePath = base_path('resources/lang') . $lang; //define file path to delete + $deletePath = base_path('resources/lang').$lang; //define file path to delete $success = File::deleteDirectory($deletePath); //remove extracted folder and it's subfolder from lang if ($success) { //sending back with success message Session::flash('success', Lang::get('lang.delete-success')); + return Redirect::back(); } else { //sending back with error message Session::flash('fails', Lang::get('lang.lang-doesnot-exist')); + return Redirect::back(); } } else { //sending back with error message Session::flash('fails', Lang::get('lang.active-lang-error')); + return redirect('languages'); } } - } diff --git a/app/Http/Controllers/Admin/helpdesk/ProfileController.php b/app/Http/Controllers/Admin/helpdesk/ProfileController.php index cb34fb0eb..9be3cbdf6 100644 --- a/app/Http/Controllers/Admin/helpdesk/ProfileController.php +++ b/app/Http/Controllers/Admin/helpdesk/ProfileController.php @@ -11,33 +11,35 @@ use App\Http\Requests\ProfileRequest; use App\User; // classes use Auth; +use Exception; use Hash; use Input; -use Exception; /** - * ProfileController + * ProfileController. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class ProfileController extends Controller { - +class ProfileController extends Controller +{ /** * Create a new controller instance. + * * @return type void */ - public function __construct() { + public function __construct() + { $this->middleware('auth'); $this->middleware('roles'); } /** - * Get profile page + * Get profile page. + * * @return type Response */ - public function getProfile() { + public function getProfile() + { try { $user = Auth::user(); if ($user) { @@ -51,10 +53,12 @@ class ProfileController extends Controller { } /** - * Get profile Edit page + * Get profile Edit page. + * * @return type Response */ - public function getProfileedit() { + public function getProfileedit() + { try { $user = Auth::user(); if ($user) { @@ -68,12 +72,15 @@ class ProfileController extends Controller { } /** - * Post profile page - * @param type int $id + * Post profile page. + * + * @param type int $id * @param type ProfileRequest $request + * * @return type Response */ - public function postProfile($id, ProfileRequest $request) { + public function postProfile($id, ProfileRequest $request) + { $user = Auth::user(); $user->gender = $request->input('gender'); $user->save(); @@ -92,12 +99,13 @@ class ProfileController extends Controller { //$extension = Input::file('profile_pic')->getClientOriginalExtension(); $name = Input::file('profile_pic')->getClientOriginalName(); $destinationPath = 'lb-faveo/profilepic'; - $fileName = rand(0000, 9999) . '.' . $name; + $fileName = rand(0000, 9999).'.'.$name; //echo $fileName; Input::file('profile_pic')->move($destinationPath, $fileName); $user->profile_pic = $fileName; } else { $user->fill($request->except('profile_pic', 'gender'))->save(); + return redirect('guest')->with('success', 'Profile Updated sucessfully'); } if ($user->fill($request->except('profile_pic'))->save()) { @@ -106,22 +114,25 @@ class ProfileController extends Controller { } /** - * Post Profile password page - * @param type int $id - * @param type User $user + * Post Profile password page. + * + * @param type int $id + * @param type User $user * @param type ProfilePassword $request + * * @return type Response */ - public function postProfilePassword($id, User $user, ProfilePassword $request) { + public function postProfilePassword($id, User $user, ProfilePassword $request) + { $user = Auth::user(); //echo $user->password; if (Hash::check($request->input('old_password'), $user->getAuthPassword())) { $user->password = Hash::make($request->input('new_password')); $user->save(); + return redirect('guest')->with('success', 'Password Updated sucessfully'); } else { return redirect('guest')->with('fails', 'Password was not Updated'); } } - } diff --git a/app/Http/Controllers/Admin/helpdesk/SettingsController.php b/app/Http/Controllers/Admin/helpdesk/SettingsController.php index 1c9b1c49f..674d27f78 100644 --- a/app/Http/Controllers/Admin/helpdesk/SettingsController.php +++ b/app/Http/Controllers/Admin/helpdesk/SettingsController.php @@ -21,51 +21,55 @@ use App\Model\helpdesk\Settings\Email; use App\Model\helpdesk\Settings\Responder; use App\Model\helpdesk\Settings\System; use App\Model\helpdesk\Settings\Ticket; +use App\Model\helpdesk\Ticket\Ticket_Priority; use App\Model\helpdesk\Utility\Date_format; use App\Model\helpdesk\Utility\Date_time_format; -use App\Model\helpdesk\Ticket\Ticket_Priority; -use App\Model\helpdesk\Utility\Timezones; use App\Model\helpdesk\Utility\Time_format; +use App\Model\helpdesk\Utility\Timezones; // classes +use Exception; use Illuminate\Http\Request; use Input; -use Exception; /** - * SettingsController + * SettingsController. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class SettingsController extends Controller { - +class SettingsController extends Controller +{ /** * Create a new controller instance. + * * @return void */ - public function __construct() { + public function __construct() + { // $this->smtp(); $this->middleware('auth'); $this->middleware('roles'); } /** - * Main Settings Page + * Main Settings Page. + * * @return type view */ - public function settings() { + public function settings() + { return view('themes.default1.admin.helpdesk.setting'); } /** * @param int $id - * @return Response * @param $compant instance of company table * * get the form for company setting page + * + * @return Response */ - public function getcompany(Company $company) { + public function getcompany(Company $company) + { try { /* fetch the values of company from company table */ $companys = $company->whereId('1')->first(); @@ -78,18 +82,21 @@ class SettingsController extends Controller { /** * Update the specified resource in storage. - * @param type int $id - * @param type Company $company - * @param type CompanyRequest $request + * + * @param type int $id + * @param type Company $company + * @param type CompanyRequest $request + * * @return Response */ - public function postcompany($id, Company $company, CompanyRequest $request) { + public function postcompany($id, Company $company, CompanyRequest $request) + { /* fetch the values of company request */ $companys = $company->whereId('1')->first(); if (Input::file('logo')) { $name = Input::file('logo')->getClientOriginalName(); $destinationPath = 'lb-faveo/media/company/'; - $fileName = rand(0000, 9999) . '.' . $name; + $fileName = rand(0000, 9999).'.'.$name; Input::file('logo')->move($destinationPath, $fileName); $companys->logo = $fileName; } @@ -103,21 +110,24 @@ class SettingsController extends Controller { return redirect('getcompany')->with('success', 'Company Updated Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('getcompany')->with('fails', 'Company can not Updated' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('getcompany')->with('fails', 'Company can not Updated'.'
  • '.$e->errorInfo[2].'
  • '); } } /** - * get the form for System setting page - * @param type System $system - * @param type Department $department - * @param type Timezones $timezone - * @param type Date_format $date + * get the form for System setting page. + * + * @param type System $system + * @param type Department $department + * @param type Timezones $timezone + * @param type Date_format $date * @param type Date_time_format $date_time - * @param type Time_format $time + * @param type Time_format $time + * * @return type Response */ - public function getsystem(System $system, Department $department, Timezones $timezone, Date_format $date, Date_time_format $date_time, Time_format $time) { + public function getsystem(System $system, Department $department, Timezones $timezone, Date_format $date, Date_time_format $date_time, Time_format $time) + { try { /* fetch the values of system from system table */ $systems = $system->whereId('1')->first(); @@ -134,12 +144,15 @@ class SettingsController extends Controller { /** * Update the specified resource in storage. - * @param type int $id - * @param type System $system + * + * @param type int $id + * @param type System $system * @param type SystemRequest $request + * * @return type Response */ - public function postsystem($id, System $system, SystemRequest $request) { + public function postsystem($id, System $system, SystemRequest $request) + { try { // dd($request); /* fetch the values of system request */ @@ -151,19 +164,22 @@ class SettingsController extends Controller { return redirect('getsystem')->with('success', 'System Updated Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('getsystem')->with('fails', 'System can not Updated' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('getsystem')->with('fails', 'System can not Updated'.'
  • '.$e->errorInfo[2].'
  • '); } } /** - * get the form for Ticket setting page - * @param type Ticket $ticket - * @param type Sla_plan $sla + * get the form for Ticket setting page. + * + * @param type Ticket $ticket + * @param type Sla_plan $sla * @param type Help_topic $topic - * @param type Priority $priority + * @param type Priority $priority + * * @return type Response */ - public function getticket(Ticket $ticket, Sla_plan $sla, Help_topic $topic, Ticket_Priority $priority) { + public function getticket(Ticket $ticket, Sla_plan $sla, Help_topic $topic, Ticket_Priority $priority) + { try { /* fetch the values of ticket from ticket table */ $tickets = $ticket->whereId('1')->first(); @@ -180,12 +196,15 @@ class SettingsController extends Controller { /** * Update the specified resource in storage. - * @param type int $id - * @param type Ticket $ticket + * + * @param type int $id + * @param type Ticket $ticket * @param type Request $request + * * @return type Response */ - public function postticket($id, Ticket $ticket, Request $request) { + public function postticket($id, Ticket $ticket, Request $request) + { try { /* fetch the values of ticket request */ $tickets = $ticket->whereId('1')->first(); @@ -206,18 +225,21 @@ class SettingsController extends Controller { return redirect('getticket')->with('success', 'Ticket Updated Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('getticket')->with('fails', 'Ticket can not Updated' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('getticket')->with('fails', 'Ticket can not Updated'.'
  • '.$e->errorInfo[2].'
  • '); } } /** - * get the form for Email setting page - * @param type Email $email + * get the form for Email setting page. + * + * @param type Email $email * @param type Template $template - * @param type Emails $email1 + * @param type Emails $email1 + * * @return type Response */ - public function getemail(Email $email, Template $template, Emails $email1) { + public function getemail(Email $email, Template $template, Emails $email1) + { try { /* fetch the values of email from Email table */ $emails = $email->whereId('1')->first(); @@ -234,12 +256,15 @@ class SettingsController extends Controller { /** * Update the specified resource in storage. - * @param type int $id - * @param type Email $email + * + * @param type int $id + * @param type Email $email * @param type EmailRequest $request + * * @return type Response */ - public function postemail($id, Email $email, EmailRequest $request) { + public function postemail($id, Email $email, EmailRequest $request) + { try { /* fetch the values of email request */ $emails = $email->whereId('1')->first(); @@ -258,20 +283,22 @@ class SettingsController extends Controller { return redirect('getemail')->with('success', 'Email Updated Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('getemail')->with('fails', 'Email can not Updated' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('getemail')->with('fails', 'Email can not Updated'.'
  • '.$e->errorInfo[2].'
  • '); } } /** - * get the form for Access setting page + * get the form for Access setting page. + * * @param type Access $access + * * @return type Response */ // public function getaccess(Access $access) { // try { // /* fetch the values of access from access table */ // $accesses = $access->whereId('1')->first(); -// // Direct to Access Settings Page +// // Direct to Access Settings Page // return view('themes.default1.admin.helpdesk.settings.access', compact('accesses')); // } catch (Exception $e) { // return view('404'); @@ -280,8 +307,10 @@ class SettingsController extends Controller { /** * Update the specified resource in storage. - * @param type Access $access + * + * @param type Access $access * @param type Request $request + * * @return type Response */ // public function postaccess(Access $access, Request $request) { @@ -310,11 +339,14 @@ class SettingsController extends Controller { // } /** - * get the form for Responder setting page + * get the form for Responder setting page. + * * @param type Responder $responder + * * @return type Response */ - public function getresponder(Responder $responder) { + public function getresponder(Responder $responder) + { try { /* fetch the values of responder from responder table */ $responders = $responder->whereId('1')->first(); @@ -327,11 +359,14 @@ class SettingsController extends Controller { /** * Update the specified resource in storage. + * * @param type Responder $responder - * @param type Request $request + * @param type Request $request + * * @return type */ - public function postresponder(Responder $responder, Request $request) { + public function postresponder(Responder $responder, Request $request) + { try { /* fetch the values of responder request */ $responders = $responder->whereId('1')->first(); @@ -348,16 +383,19 @@ class SettingsController extends Controller { return redirect('getresponder')->with('success', 'Responder Updated Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('getresponder')->with('fails', 'Responder can not Updated' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('getresponder')->with('fails', 'Responder can not Updated'.'
  • '.$e->errorInfo[2].'
  • '); } } /** - * get the form for Alert setting page + * get the form for Alert setting page. + * * @param type Alert $alert + * * @return type Response */ - public function getalert(Alert $alert) { + public function getalert(Alert $alert) + { try { /* fetch the values of alert from alert table */ $alerts = $alert->whereId('1')->first(); @@ -370,12 +408,15 @@ class SettingsController extends Controller { /** * Update the specified resource in storage. - * @param type $id - * @param type Alert $alert + * + * @param type $id + * @param type Alert $alert * @param type Request $request + * * @return type Response */ - public function postalert($id, Alert $alert, Request $request) { + public function postalert($id, Alert $alert, Request $request) + { try { /* fetch the values of alert request */ $alerts = $alert->whereId('1')->first(); @@ -430,38 +471,46 @@ class SettingsController extends Controller { return redirect('getalert')->with('success', 'Alert Updated Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('getalert')->with('fails', 'Alert can not Updated' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('getalert')->with('fails', 'Alert can not Updated'.'
  • '.$e->errorInfo[2].'
  • '); } } /** - * To display the list of ratings in the system + * To display the list of ratings in the system. + * * @return type View */ - public function RatingSettings() { + public function RatingSettings() + { $ratings = DB::table('settings_ratings')->get(); + return view('themes.default1.admin.helpdesk.settings.ratings', compact('ratings')); } /** - * To store rating data + * To store rating data. + * * @return type Redirect */ - public function PostRatingSettings($slug) { + public function PostRatingSettings($slug) + { $name = Input::get('rating_name'); $publish = Input::get('publish'); $modify = Input::get('modify'); - DB::table('settings_ratings')->whereSlug($slug)->update(array('rating_name' => $name, 'publish' => $publish, 'modify' => $modify)); + DB::table('settings_ratings')->whereSlug($slug)->update(['rating_name' => $name, 'publish' => $publish, 'modify' => $modify]); + return redirect()->back()->with('success', 'Successfully updated'); } /** - * To delete a type of rating + * To delete a type of rating. + * * @return type Redirect */ - public function RatingDelete($slug) { + public function RatingDelete($slug) + { DB::table('settings_ratings')->whereSlug($slug)->delete(); + return redirect()->back()->with('success', 'Successfully Deleted'); } - } diff --git a/app/Http/Controllers/Admin/helpdesk/SlaController.php b/app/Http/Controllers/Admin/helpdesk/SlaController.php index 2dd8c69c5..7dee75a9c 100644 --- a/app/Http/Controllers/Admin/helpdesk/SlaController.php +++ b/app/Http/Controllers/Admin/helpdesk/SlaController.php @@ -15,29 +15,32 @@ use DB; use Exception; /** - * SlaController + * SlaController. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class SlaController extends Controller { - +class SlaController extends Controller +{ /** * Create a new controller instance. + * * @return type void */ - public function __construct() { + public function __construct() + { $this->middleware('auth'); $this->middleware('roles'); } /** * Display a listing of the resource. + * * @param type Sla_plan $sla + * * @return type Response */ - public function index(Sla_plan $sla) { + public function index(Sla_plan $sla) + { try { /* Declare a Variable $slas to store all Values From Sla_plan Table */ $slas = $sla->get(); @@ -50,9 +53,11 @@ class SlaController extends Controller { /** * Show the form for creating a new resource. + * * @return type Response */ - public function create() { + public function create() + { try { /* Direct to Create Page */ return view('themes.default1.admin.helpdesk.manage.sla.create'); @@ -63,11 +68,14 @@ class SlaController extends Controller { /** * Store a newly created resource in storage. - * @param type Sla_plan $sla + * + * @param type Sla_plan $sla * @param type SlaRequest $request + * * @return type Response */ - public function store(Sla_plan $sla, SlaRequest $request) { + public function store(Sla_plan $sla, SlaRequest $request) + { try { /* Fill the request values to Sla_plan Table */ /* Check whether function success or not */ @@ -76,21 +84,25 @@ class SlaController extends Controller { return redirect('sla')->with('success', 'SLA Plan Created Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('sla')->with('fails', 'SLA Plan can not Create' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('sla')->with('fails', 'SLA Plan can not Create'.'
  • '.$e->errorInfo[2].'
  • '); } } /** * Show the form for editing the specified resource. - * @param type int $id + * + * @param type int $id * @param type Sla_plan $sla + * * @return type Response */ - public function edit($id, Sla_plan $sla) { + public function edit($id, Sla_plan $sla) + { try { /* Direct to edit page along values of perticular field using Id */ $slas = $sla->whereId($id)->first(); $slas->get(); + return view('themes.default1.admin.helpdesk.manage.sla.edit', compact('slas')); } catch (Exception $e) { return redirect()->back()->with('fails', $e->errorInfo[2]); @@ -99,12 +111,15 @@ class SlaController extends Controller { /** * Update the specified resource in storage. - * @param type int $id - * @param type Sla_plan $sla + * + * @param type int $id + * @param type Sla_plan $sla * @param type SlaUpdate $request + * * @return type Response */ - public function update($id, Sla_plan $sla, SlaUpdate $request) { + public function update($id, Sla_plan $sla, SlaUpdate $request) + { try { /* Fill values to selected field using Id except Check box */ $slas = $sla->whereId($id)->first(); @@ -119,17 +134,20 @@ class SlaController extends Controller { return redirect('sla')->with('success', 'SLA Plan Updated Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('sla')->with('fails', 'SLA Plan can not Update' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('sla')->with('fails', 'SLA Plan can not Update'.'
  • '.$e->errorInfo[2].'
  • '); } } /** * Remove the specified resource from storage. - * @param type int $id + * + * @param type int $id * @param type Sla_plan $sla + * * @return type Response */ - public function destroy($id, Sla_plan $sla) { + public function destroy($id, Sla_plan $sla) + { $default_sla = Ticket::where('id', '=', '1')->first(); if ($default_sla->sla == $id) { return redirect('departments')->with('fails', 'You cannot delete default department'); @@ -137,49 +155,48 @@ class SlaController extends Controller { $tickets = DB::table('tickets')->where('sla', '=', $id)->update(['sla' => $default_sla->sla]); if ($tickets > 0) { if ($tickets > 1) { - $text_tickets = "Tickets"; + $text_tickets = 'Tickets'; } else { - $text_tickets = "Ticket"; + $text_tickets = 'Ticket'; } - $ticket = '
  • ' . $tickets . ' ' . $text_tickets . ' have been moved to default SLA
  • '; + $ticket = '
  • '.$tickets.' '.$text_tickets.' have been moved to default SLA
  • '; } else { - $ticket = ""; + $ticket = ''; } $dept = DB::table('department')->where('sla', '=', $id)->update(['sla' => $default_sla->sla]); if ($dept > 0) { if ($dept > 1) { - $text_dept = "Emails"; + $text_dept = 'Emails'; } else { - $text_dept = "Email"; + $text_dept = 'Email'; } $dept = '
  • Associated department have been moved to default SLA
  • '; } else { - $dept = ""; + $dept = ''; } $topic = DB::table('help_topic')->where('sla_plan', '=', $id)->update(['sla_plan' => $default_sla->sla]); if ($topic > 0) { if ($topic > 1) { - $text_topic = "Emails"; + $text_topic = 'Emails'; } else { - $text_topic = "Email"; + $text_topic = 'Email'; } $topic = '
  • Associated Help Topic have been moved to default SLA
  • '; } else { - $topic = ""; + $topic = ''; } - $message = $ticket . $dept . $topic; + $message = $ticket.$dept.$topic; /* Delete a perticular field from the database by delete() using Id */ $slas = $sla->whereId($id)->first(); /* Check whether function success or not */ try { $slas->delete(); /* redirect to Index page with Success Message */ - return redirect('sla')->with('success', 'SLA Plan Deleted Successfully' . $message); + return redirect('sla')->with('success', 'SLA Plan Deleted Successfully'.$message); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('sla')->with('fails', 'SLA Plan can not Delete' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('sla')->with('fails', 'SLA Plan can not Delete'.'
  • '.$e->errorInfo[2].'
  • '); } } } - } diff --git a/app/Http/Controllers/Admin/helpdesk/TeamController.php b/app/Http/Controllers/Admin/helpdesk/TeamController.php index 396c996d7..0af3a5d77 100644 --- a/app/Http/Controllers/Admin/helpdesk/TeamController.php +++ b/app/Http/Controllers/Admin/helpdesk/TeamController.php @@ -16,35 +16,39 @@ use DB; use Exception; /** - * TeamController + * TeamController. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class TeamController extends Controller { - +class TeamController extends Controller +{ /** * Create a new controller instance. + * * @return type void */ - public function __construct() { + public function __construct() + { $this->middleware('auth'); $this->middleware('roles'); } /** - * get Index page - * @param type Teams $team + * get Index page. + * + * @param type Teams $team * @param type Assign_team_agent $assign_team_agent + * * @return type Response */ - public function index(Teams $team, Assign_team_agent $assign_team_agent) { + public function index(Teams $team, Assign_team_agent $assign_team_agent) + { try { $teams = $team->get(); /* find out the Number of Members in the Team */ $id = $teams->lists('id'); $assign_team_agent = $assign_team_agent->get(); + return view('themes.default1.admin.helpdesk.agent.teams.index', compact('assign_team_agent', 'teams')); } catch (Exception $e) { return redirect()->back()->with('fails', $e->errorInfo[2]); @@ -53,12 +57,16 @@ class TeamController extends Controller { /** * Show the form for creating a new resource. + * * @param type User $user + * * @return type Response */ - public function create(User $user) { + public function create(User $user) + { try { $user = $user->get(); + return view('themes.default1.admin.helpdesk.agent.teams.create', compact('user')); } catch (Exception $e) { return redirect()->back()->with('fails', $e->errorInfo[2]); @@ -67,12 +75,14 @@ class TeamController extends Controller { /** * Store a newly created resource in storage. - * @param type Teams $team + * + * @param type Teams $team * @param type TeamRequest $request + * * @return type Response */ - public function store(Teams $team, TeamRequest $request) { - + public function store(Teams $team, TeamRequest $request) + { if ($request->team_lead) { $team_lead = $request->team_lead; } else { @@ -86,24 +96,28 @@ class TeamController extends Controller { return redirect('teams')->with('success', 'Teams Created Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('teams')->with('fails', 'Teams can not Create' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('teams')->with('fails', 'Teams can not Create'.'
  • '.$e->errorInfo[2].'
  • '); } } /** * Show the form for editing the specified resource. - * @param type $id - * @param type User $user + * + * @param type $id + * @param type User $user * @param type Assign_team_agent $assign_team_agent - * @param type Teams $team + * @param type Teams $team + * * @return type Response */ - public function edit($id, User $user, Assign_team_agent $assign_team_agent, Teams $team) { + public function edit($id, User $user, Assign_team_agent $assign_team_agent, Teams $team) + { try { $user = $user->whereId($id)->first(); $teams = $team->whereId($id)->first(); $agent_team = $assign_team_agent->where('team_id', $id)->get(); $agent_id = $agent_team->lists('agent_id', 'agent_id'); + return view('themes.default1.admin.helpdesk.agent.teams.edit', compact('agent_id', 'user', 'teams', 'allagents')); } catch (Exception $e) { return redirect()->back()->with('fails', $e->errorInfo[2]); @@ -112,13 +126,15 @@ class TeamController extends Controller { /** * Update the specified resource in storage. - * @param type int $id - * @param type Teams $team + * + * @param type int $id + * @param type Teams $team * @param type TeamUpdate $request + * * @return type Response */ - public function update($id, Teams $team, TeamUpdate $request) { - + public function update($id, Teams $team, TeamUpdate $request) + { $teams = $team->whereId($id)->first(); //updating check box if ($request->team_lead) { @@ -140,18 +156,21 @@ class TeamController extends Controller { return redirect('teams')->with('success', 'Teams Updated Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('teams')->with('fails', 'Teams can not Update' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('teams')->with('fails', 'Teams can not Update'.'
  • '.$e->errorInfo[2].'
  • '); } } /** * Remove the specified resource from storage. - * @param type int $id - * @param type Teams $team + * + * @param type int $id + * @param type Teams $team * @param type Assign_team_agent $assign_team_agent + * * @return type Response */ - public function destroy($id, Teams $team, Assign_team_agent $assign_team_agent) { + public function destroy($id, Teams $team, Assign_team_agent $assign_team_agent) + { try { $assign_team_agent->where('team_id', $id)->delete(); $teams = $team->whereId($id)->first(); @@ -162,8 +181,7 @@ class TeamController extends Controller { return redirect('teams')->with('success', 'Teams Deleted Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ - return redirect('teams')->with('fails', 'Teams can not Delete' . '
  • ' . $e->errorInfo[2] . '
  • '); + return redirect('teams')->with('fails', 'Teams can not Delete'.'
  • '.$e->errorInfo[2].'
  • '); } } - } diff --git a/app/Http/Controllers/Admin/helpdesk/TemplateController.php b/app/Http/Controllers/Admin/helpdesk/TemplateController.php index 9e55e240d..02c639377 100644 --- a/app/Http/Controllers/Admin/helpdesk/TemplateController.php +++ b/app/Http/Controllers/Admin/helpdesk/TemplateController.php @@ -3,9 +3,9 @@ namespace App\Http\Controllers\Admin\helpdesk; // controllers -use App\Http\Controllers\Controller; -use App\Http\Controllers\Common\SettingsController; use App\Http\Controllers\Common\PhpMailController; +use App\Http\Controllers\Common\SettingsController; +use App\Http\Controllers\Controller; // requests use App\Http\Requests\helpdesk\TemplateRequest; use App\Http\Requests\helpdesk\TemplateUdate; @@ -14,25 +14,25 @@ use App\Model\helpdesk\Email\Emails; use App\Model\helpdesk\Email\Template; use App\Model\helpdesk\Utility\Languages; // classes -use Illuminate\Http\Request; -use Mail; use Exception; +use Illuminate\Http\Request; use Input; +use Mail; /** - * TemplateController + * TemplateController. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class TemplateController extends Controller { - +class TemplateController extends Controller +{ /** * Create a new controller instance. + * * @return type void */ - public function __construct(PhpMailController $PhpMailController) { + public function __construct(PhpMailController $PhpMailController) + { $this->PhpMailController = $PhpMailController; SettingsController::smtp(); $this->middleware('auth'); @@ -41,12 +41,16 @@ class TemplateController extends Controller { /** * Display a listing of the resource. + * * @param type Template $template + * * @return type Response */ - public function index(Template $template) { + public function index(Template $template) + { try { $templates = $template->get(); + return view('themes.default1.admin.helpdesk.emails.template.index', compact('templates')); } catch (Exception $e) { return view('404'); @@ -55,14 +59,18 @@ class TemplateController extends Controller { /** * Show the form for creating a new resource. + * * @param type Languages $language - * @param type Template $template + * @param type Template $template + * * @return type Response */ - public function create(Languages $language, Template $template) { + public function create(Languages $language, Template $template) + { try { $templates = $template->get(); $languages = $language->get(); + return view('themes.default1.admin.helpdesk.emails.template.create', compact('languages', 'templates')); } catch (Exception $e) { return view('404'); @@ -71,11 +79,14 @@ class TemplateController extends Controller { /** * Store a newly created resource in storage. - * @param type Template $template + * + * @param type Template $template * @param type TemplateRequest $request + * * @return type Response */ - public function store(Template $template, TemplateRequest $request) { + public function store(Template $template, TemplateRequest $request) + { try { /* Check whether function success or not */ if ($template->fill($request->input())->save() == true) { @@ -93,49 +104,60 @@ class TemplateController extends Controller { /** * Display the specified resource. - * @param int $id + * + * @param int $id + * * @return Response */ - public function show($id) { + public function show($id) + { // } /** * Show the form for editing the specified resource. - * @param type $id - * @param type Template $template + * + * @param type $id + * @param type Template $template * @param type Languages $language + * * @return type Response */ - public function listdirectories() { + public function listdirectories() + { $path = '../resources/views/emails/'; $directories = scandir($path); $directory = str_replace('/', '-', $path); + return view('themes.default1.admin.helpdesk.emails.template.listdirectories', compact('directories', 'directory')); } - public function listtemplates($template, $path) { + public function listtemplates($template, $path) + { $paths = str_replace('-', '/', $path); - $directory2 = $paths . $template; + $directory2 = $paths.$template; $templates = scandir($directory2); - $directory = str_replace('/', '-', $directory2 . '/'); + $directory = str_replace('/', '-', $directory2.'/'); + return view('themes.default1.admin.helpdesk.emails.template.listtemplates', compact('templates', 'directory')); } - public function readtemplate($template, $path) { + public function readtemplate($template, $path) + { $directory = str_replace('-', '/', $path); - $handle = fopen($directory . $template, "r"); - $contents = fread($handle, filesize($directory . $template)); + $handle = fopen($directory.$template, 'r'); + $contents = fread($handle, filesize($directory.$template)); fclose($handle); return view('themes.default1.admin.helpdesk.emails.template.readtemplates', compact('contents', 'template', 'path')); } - public function createtemplate() { + public function createtemplate() + { $directory = '../resources/views/emails/'; $fname = Input::get('folder_name'); - $filename = $directory . $fname; + $filename = $directory.$fname; // images folder creation using php // $mydir = dirname( __FILE__ )."/html/images"; @@ -147,32 +169,37 @@ class TemplateController extends Controller { if (!file_exists($filename)) { mkdir($filename, 0777); } - $files = array_filter(scandir($directory . 'default')); + $files = array_filter(scandir($directory.'default')); foreach ($files as $file) { - if ($file === '.' or $file === '..') + if ($file === '.' or $file === '..') { continue; + } if (!is_dir($file)) { // $file_to_go = str_replace("code/resources/views/emails/",'code/resources/views/emails/'.$fname,$file); - $destination = $directory . $fname . '/'; + $destination = $directory.$fname.'/'; - copy($directory . 'default/' . $file, $destination . $file); + copy($directory.'default/'.$file, $destination.$file); } } + return \Redirect::back()->with('success', 'Successfully copied'); } - public function writetemplate($template, $path) { + public function writetemplate($template, $path) + { $directory = str_replace('-', '/', $path); $b = Input::get('templatedata'); - file_put_contents($directory . $template, print_r($b, true)); + file_put_contents($directory.$template, print_r($b, true)); + return \Redirect::back()->with('success', 'Successfully updated'); } - public function deletetemplate($template, $path) { + public function deletetemplate($template, $path) + { $directory = str_replace('-', '/', $path); - $dir = $directory . $template; + $dir = $directory.$template; $status = \DB::table('settings_email')->first(); if ($template == 'default' or $template == $status->template) { return \Redirect::back()->with('fails', 'You cannot delete a default or active directory!'); @@ -180,26 +207,31 @@ class TemplateController extends Controller { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { - if ($object != "." && $object != "..") { - unlink($dir . "/" . $object); + if ($object != '.' && $object != '..') { + unlink($dir.'/'.$object); } } rmdir($dir); } else { rmdir($dir); } + return \Redirect::back()->with('success', 'Successfully Deleted'); } - public function activateset($setname) { - \DB::table('settings_email')->update(array('template' => $setname)); + public function activateset($setname) + { + \DB::table('settings_email')->update(['template' => $setname]); + return \Redirect::back()->with('success', 'You have Successfully Activated this Set'); } - public function edit($id, Template $template, Languages $language) { + public function edit($id, Template $template, Languages $language) + { try { $templates = $template->whereId($id)->first(); $languages = $language->get(); + return view('themes.default1.admin.helpdesk.emails.template.edit', compact('templates', 'languages')); } catch (Exception $e) { return view('404'); @@ -208,12 +240,15 @@ class TemplateController extends Controller { /** * Update the specified resource in storage. - * @param type int $id - * @param type Template $template + * + * @param type int $id + * @param type Template $template * @param type TemplateUdate $request + * * @return type Response */ - public function update($id, Template $template, TemplateUdate $request) { + public function update($id, Template $template, TemplateUdate $request) + { try { //TODO validation $templates = $template->whereId($id)->first(); @@ -233,11 +268,14 @@ class TemplateController extends Controller { /** * Remove the specified resource from storage. - * @param type int $id + * + * @param type int $id * @param type Template $template + * * @return type Response */ - public function destroy($id, Template $template) { + public function destroy($id, Template $template) + { try { $templates = $template->whereId($id)->first(); /* Check whether function success or not */ @@ -256,12 +294,16 @@ class TemplateController extends Controller { /** * Form for Email connection checking. + * * @param type Emails $email + * * @return type Response */ - public function formDiagno(Emails $email) { + public function formDiagno(Emails $email) + { try { $emails = $email->get(); + return view('themes.default1.admin.helpdesk.emails.template.formDiagno', compact('emails')); } catch (Exception $e) { return view('404'); @@ -269,11 +311,14 @@ class TemplateController extends Controller { } /** - * function to send emails + * function to send emails. + * * @param type Request $request + * * @return type */ - public function postDiagno(Request $request) { + public function postDiagno(Request $request) + { $email = $request->input('to'); if ($email == null) { return redirect('getdiagno')->with('fails', 'Please provide E-mail address !'); @@ -283,5 +328,4 @@ class TemplateController extends Controller { return redirect('getdiagno')->with('success', 'Please check your mail. An E-mail has been sent to your E-mail address'); } - } diff --git a/app/Http/Controllers/Admin/helpdesk/ThreadController.php b/app/Http/Controllers/Admin/helpdesk/ThreadController.php index f9653d36e..9306834be 100644 --- a/app/Http/Controllers/Admin/helpdesk/ThreadController.php +++ b/app/Http/Controllers/Admin/helpdesk/ThreadController.php @@ -11,21 +11,22 @@ use App\Model\helpdesk\Ticket_thread; use Exception; /** - * ThreadController + * ThreadController. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class ThreadController extends Controller { - +class ThreadController extends Controller +{ /** - * get the values from ticket_thread Table and direct to view page + * get the values from ticket_thread Table and direct to view page. + * * @param type Ticket_thread $thread - * @param type Priority $priority - * @return type Response + * @param type Priority $priority + * + * @return type Response */ - public function getTickets(Ticket_thread $thread, Priority $priority) { + public function getTickets(Ticket_thread $thread, Priority $priority) + { try { /* get the values of Ticket_thread from Ticket_thread Table */ $threads = $thread->get(); @@ -37,5 +38,4 @@ class ThreadController extends Controller { return view('404'); } } - } diff --git a/app/Http/Controllers/Agent/helpdesk/CannedController.php b/app/Http/Controllers/Agent/helpdesk/CannedController.php index 1b61bdeb6..771a426a5 100644 --- a/app/Http/Controllers/Agent/helpdesk/CannedController.php +++ b/app/Http/Controllers/Agent/helpdesk/CannedController.php @@ -14,25 +14,25 @@ use App\User; use Exception; /** - * CannedController + * CannedController. * * This controller is for all the functionalities of Canned response for Agents in the Agent Panel * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class CannedController extends Controller { - +class CannedController extends Controller +{ /** * Create a new controller instance. * constructor to check * 1. authentication * 2. user roles - * 3. roles must be agent + * 3. roles must be agent. + * * @return void */ - public function __construct() { + public function __construct() + { // checking authentication $this->middleware('auth'); // checking if role is agent @@ -41,27 +41,34 @@ class CannedController extends Controller { /** * Display a listing of the Canned Responses. + * * @return type View */ - public function index() { + public function index() + { return view('themes.default1.agent.helpdesk.canned.index'); } /** - * Show the form for creating a new Canned Response + * Show the form for creating a new Canned Response. + * * @return type View */ - public function create() { + public function create() + { return view('themes.default1.agent.helpdesk.canned.create'); } /** * Store a newly created Canned Response. - * @param type CannedRequest $request - * @param type Canned $canned + * + * @param type CannedRequest $request + * @param type Canned $canned + * * @return type Redirect */ - public function store(CannedRequest $request, Canned $canned) { + public function store(CannedRequest $request, Canned $canned) + { // fetching all the requested inputs $canned->user_id = \Auth::user()->id; $canned->title = $request->input('title'); @@ -69,6 +76,7 @@ class CannedController extends Controller { try { // saving inputs $canned->save(); + return redirect()->route('canned.list')->with('success', 'Added Successfully'); } catch (Exception $e) { return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]); @@ -77,24 +85,31 @@ class CannedController extends Controller { /** * Show the form for editing the Canned Response. - * @param type $id - * @param type Canned $canned + * + * @param type $id + * @param type Canned $canned + * * @return type View */ - public function edit($id, Canned $canned) { + public function edit($id, Canned $canned) + { // fetching requested canned response $canned = $canned->where('user_id', '=', \Auth::user()->id)->where('id', '=', $id)->first(); + return view('themes.default1.agent.helpdesk.canned.edit', compact('canned')); } /** * Update the Canned Response in database. - * @param type $id - * @param type CannedUpdateRequest $request - * @param type Canned $canned + * + * @param type $id + * @param type CannedUpdateRequest $request + * @param type Canned $canned + * * @return type Redirect */ - public function update($id, CannedUpdateRequest $request, Canned $canned) { + public function update($id, CannedUpdateRequest $request, Canned $canned) + { /* select the field where id = $id(request Id) */ $canned = $canned->where('id', '=', $id)->where('user_id', '=', \Auth::user()->id)->first(); // fetching all the requested inputs @@ -104,6 +119,7 @@ class CannedController extends Controller { try { // saving inputs $canned->save(); + return redirect()->route('canned.list')->with('success', 'Updated Successfully'); } catch (Exception $e) { return redirect()->route('canned.list')->with('fails', $e->errorInfo[2]); @@ -112,11 +128,14 @@ class CannedController extends Controller { /** * Delete the Canned Response from storage. - * @param type $id - * @param type Canned $canned + * + * @param type $id + * @param type Canned $canned + * * @return type Redirect */ - public function destroy($id, Canned $canned) { + public function destroy($id, Canned $canned) + { /* select the field where id = $id(request Id) */ $canned = $canned->whereId($id)->first(); /* delete the selected field */ @@ -133,20 +152,22 @@ class CannedController extends Controller { /** * Fetch Canned Response in the ticket detail page. - * @param type $id + * + * @param type $id + * * @return type json */ - public function get_canned($id) { + public function get_canned($id) + { // checking for the canned response with requested value - if ($id != "zzz") { + if ($id != 'zzz') { // fetching canned response $canned = Canned::where('id', '=', $id)->where('user_id', '=', \Auth::user()->id)->first(); $msg = $canned->message; } else { - $msg = ""; + $msg = ''; } // returning the canned response in JSON format return \Response::json($msg); } - } diff --git a/app/Http/Controllers/Agent/helpdesk/DashboardController.php b/app/Http/Controllers/Agent/helpdesk/DashboardController.php index cf7a4dda2..4a09419d2 100644 --- a/app/Http/Controllers/Agent/helpdesk/DashboardController.php +++ b/app/Http/Controllers/Agent/helpdesk/DashboardController.php @@ -5,35 +5,32 @@ namespace App\Http\Controllers\Agent\helpdesk; // controllers use App\Http\Controllers\Controller; // models -use App\Model\helpdesk\Settings\Company; -use App\Model\helpdesk\Ticket\Ticket_Collaborator; -use App\Model\helpdesk\Email\Emails; use App\User; // classes -use DB; -use View; use Auth; +use DB; use Exception; +use View; /** * DashboardController - * This controlleris used to fetch dashboard in the agent panel + * This controlleris used to fetch dashboard in the agent panel. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class DashboardController extends Controller { - +class DashboardController extends Controller +{ /** * Create a new controller instance. * constructor to check * 1. authentication * 2. user roles - * 3. roles must be agent + * 3. roles must be agent. + * * @return void */ - public function __construct() { + public function __construct() + { // checking for authentication $this->middleware('auth'); // checking if the role is agent @@ -41,12 +38,14 @@ class DashboardController extends Controller { } /** - * Get the dashboard page + * Get the dashboard page. + * * @return type view */ - public function index() { + public function index() + { // if(Auth::user()->role == "user"){ - // return \Redirect::route('home'); + // return \Redirect::route('home'); // } try { return View::make('themes.default1.agent.helpdesk.dashboard.dashboard'); @@ -56,10 +55,12 @@ class DashboardController extends Controller { } /** - * Fetching dashboard graph data to implement graph + * Fetching dashboard graph data to implement graph. + * * @return type Json */ - public function ChartData($date111 = "", $date122 = "") { + public function ChartData($date111 = '', $date122 = '') + { $date11 = strtotime($date122); $date12 = strtotime($date111); if ($date11 && $date12) { @@ -67,29 +68,29 @@ class DashboardController extends Controller { $date1 = $date11; } else { // generating current date - $date2 = strtotime(Date('Y-m-d')); - $date3 = Date('Y-m-d'); + $date2 = strtotime(date('Y-m-d')); + $date3 = date('Y-m-d'); $format = 'Y-m-d'; // generating a date range of 1 month - $date1 = strtotime(Date($format, strtotime('-1 month' . $date3))); + $date1 = strtotime(date($format, strtotime('-1 month'.$date3))); } - $return = ""; - $last = ""; + $return = ''; + $last = ''; for ($i = $date1; $i <= $date2; $i = $i + 86400) { $thisDate = date('Y-m-d', $i); - $created = \DB::table('tickets')->select('created_at')->where('created_at', 'LIKE', '%' . $thisDate . '%')->count(); - $closed = \DB::table('tickets')->select('closed_at')->where('closed_at', 'LIKE', '%' . $thisDate . '%')->count(); - $reopened = \DB::table('tickets')->select('reopened_at')->where('reopened_at', 'LIKE', '%' . $thisDate . '%')->count(); + $created = \DB::table('tickets')->select('created_at')->where('created_at', 'LIKE', '%'.$thisDate.'%')->count(); + $closed = \DB::table('tickets')->select('closed_at')->where('closed_at', 'LIKE', '%'.$thisDate.'%')->count(); + $reopened = \DB::table('tickets')->select('reopened_at')->where('reopened_at', 'LIKE', '%'.$thisDate.'%')->count(); $value = ['date' => $thisDate, 'open' => $created, 'closed' => $closed, 'reopened' => $reopened]; $array = array_map('htmlentities', $value); $json = html_entity_decode(json_encode($array)); - $return .= $json . ','; + $return .= $json.','; } $last = rtrim($return, ','); - return '[' . $last . ']'; + return '['.$last.']'; // $ticketlist = DB::table('tickets') // ->select(DB::raw('MONTH(updated_at) as month'),DB::raw('SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) as closed'),DB::raw('SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) as reopened'),DB::raw('SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) as open'),DB::raw('SUM(CASE WHEN status = 5 THEN 1 ELSE 0 END) as deleted'), @@ -99,5 +100,4 @@ class DashboardController extends Controller { // ->get(); // return $ticketlist; } - } diff --git a/app/Http/Controllers/Agent/helpdesk/MailController.php b/app/Http/Controllers/Agent/helpdesk/MailController.php index 1cb90eedd..d0901da4c 100644 --- a/app/Http/Controllers/Agent/helpdesk/MailController.php +++ b/app/Http/Controllers/Agent/helpdesk/MailController.php @@ -3,57 +3,50 @@ namespace App\Http\Controllers\Agent\helpdesk; // controllers -use App\Http\Controllers\Controller; -use App\Http\Controllers\Agent\helpdesk\TicketController; +use App; // models -use App\User; +use App\Http\Controllers\Controller; use App\Model\helpdesk\Email\Emails; +use App\Model\helpdesk\Manage\Help_topic; use App\Model\helpdesk\Settings\Email; -use App\Model\helpdesk\Ticket\Ticket_attachments; -use App\Model\helpdesk\Ticket\Ticket_Thread; use App\Model\helpdesk\Settings\System; use App\Model\helpdesk\Settings\Ticket; -use App\Model\helpdesk\Manage\Help_topic; -use App\Model\helpdesk\Utility\MailboxProtocol; +use App\Model\helpdesk\Ticket\Ticket_attachments; use App\Model\helpdesk\Ticket\Ticket_source; -use App\Model\helpdesk\Ticket\Ticket_Priority; +use App\Model\helpdesk\Ticket\Ticket_Thread; use App\Model\helpdesk\Ticket\Tickets; // classes -use PhpImap\Mailbox as ImapMailbox; -use PhpImap\IncomingMail; -use PhpImap\IncomingMailAttachment; -use \ForceUTF8\Encoding; -use App; -use DB; +use App\Model\helpdesk\Utility\MailboxProtocol; use Crypt; -use Schedule; use File; -use Artisan; -use Exception; +use ForceUTF8\Encoding; +use PhpImap\Mailbox as ImapMailbox; /** - * MailController + * MailController. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class MailController extends Controller { - +class MailController extends Controller +{ /** * constructor * Create a new controller instance. + * * @param type TicketController $TicketController */ - public function __construct(TicketController $TicketController) { + public function __construct(TicketController $TicketController) + { $this->TicketController = $TicketController; } /** - * Reademails + * Reademails. + * * @return type */ - public function readmails(Emails $emails, Email $settings_email, System $system, Ticket $ticket) { + public function readmails(Emails $emails, Email $settings_email, System $system, Ticket $ticket) + { // $path_url = $system->first()->url; if ($settings_email->first()->email_fetching == 1) { if ($settings_email->first()->all_emails == 1) { @@ -86,11 +79,11 @@ class MailController extends Controller { $protocol = $e_mail->mailbox_protocol; $get_mailboxprotocol = MailboxProtocol::where('id', '=', $protocol)->first(); $protocol = $get_mailboxprotocol->value; - $imap_config = '{' . $host . ':' . $port . $protocol . '}INBOX'; + $imap_config = '{'.$host.':'.$port.$protocol.'}INBOX'; $password = Crypt::decrypt($e_mail->password); $mailbox = new ImapMailbox($imap_config, $e_mail->email_address, $password, __DIR__); - $mails = array(); - $mailsIds = $mailbox->searchMailBox('SINCE ' . date('d-M-Y', strtotime("-1 day"))); + $mails = []; + $mailsIds = $mailbox->searchMailBox('SINCE '.date('d-M-Y', strtotime('-1 day'))); if (!$mailsIds) { die('Mailbox is empty'); } @@ -112,15 +105,15 @@ class MailController extends Controller { } $date = $mail->date; $datetime = $overview[0]->date; - $date_time = explode(" ", $datetime); - $date = $date_time[1] . "-" . $date_time[2] . "-" . $date_time[3] . " " . $date_time[4]; + $date_time = explode(' ', $datetime); + $date = $date_time[1].'-'.$date_time[2].'-'.$date_time[3].' '.$date_time[4]; $date = date('Y-m-d H:i:s', strtotime($date)); // dd($date); if (isset($mail->subject)) { $subject = $mail->subject; } else { - $subject = "No Subject"; + $subject = 'No Subject'; } // dd($subject); @@ -128,7 +121,7 @@ class MailController extends Controller { $fromaddress = $mail->fromAddress; $ticket_source = Ticket_source::where('name', '=', 'email')->first(); $source = $ticket_source->id; - $phone = ""; + $phone = ''; $assign = $get_helptopic->auto_assign; $form_data = null; @@ -141,7 +134,7 @@ class MailController extends Controller { $thread_id = $thread_id; foreach ($mail->getAttachments() as $attachment) { - $support = "support"; + $support = 'support'; // echo $_SERVER['DOCUMENT_ROOT']; $dir_img_paths = __DIR__; $dir_img_path = explode('/code', $dir_img_paths); @@ -150,7 +143,7 @@ class MailController extends Controller { // var_dump($attachment->filePath); // dd($filepath); // $path = $dir_img_path[0]."/code/public/".$filepath[1]; - $path = public_path() . $filepath[1]; + $path = public_path().$filepath[1]; // dd($path); $filesize = filesize($path); $file_data = file_get_contents($path); @@ -159,28 +152,28 @@ class MailController extends Controller { $string = str_replace('-', '', $attachment->name); $filename = explode('src', $attachment->filePath); $filename = str_replace('\\', '', $filename); - $body = str_replace("cid:" . $imageid, $filepath[1], $body); + $body = str_replace('cid:'.$imageid, $filepath[1], $body); $pos = strpos($body, $filepath[1]); if ($pos == false) { if ($settings_email->first()->attachment == 1) { - $upload = new Ticket_attachments; + $upload = new Ticket_attachments(); $upload->file = $file_data; $upload->thread_id = $thread_id; $upload->name = $filepath[1]; $upload->type = $ext; $upload->size = $filesize; - $upload->poster = "ATTACHMENT"; + $upload->poster = 'ATTACHMENT'; $upload->save(); } } else { - $upload = new Ticket_attachments; + $upload = new Ticket_attachments(); $upload->file = $file_data; $upload->thread_id = $thread_id; $upload->name = $filepath[1]; $upload->type = $ext; $upload->size = $filesize; - $upload->poster = "INLINE"; + $upload->poster = 'INLINE'; $upload->save(); } unlink($path); @@ -198,35 +191,45 @@ class MailController extends Controller { } /** - * separate reply - * @param type $body + * separate reply. + * + * @param type $body + * * @return type string */ - public function separate_reply($body) { + public function separate_reply($body) + { $body2 = explode('---Reply above this line---', $body); $body3 = $body2[0]; + return $body3; } /** - * Decode Imap text + * Decode Imap text. + * * @param type $str + * * @return type string */ - public function decode_imap_text($str) { + public function decode_imap_text($str) + { $result = ''; $decode_header = imap_mime_header_decode($str); - foreach ($decode_header AS $obj) { + foreach ($decode_header as $obj) { $result .= htmlspecialchars(rtrim($obj->text, "\t")); } + return $result; } /** - * fetch_attachments + * fetch_attachments. + * * @return type */ - public function fetch_attachments() { + public function fetch_attachments() + { $uploads = Upload::all(); foreach ($uploads as $attachment) { $image = @imagecreatefromstring($attachment->file); @@ -234,24 +237,26 @@ class MailController extends Controller { imagejpeg($image, null, 80); $data = ob_get_contents(); ob_end_clean(); - $var = ''; - echo '
    ' . $var . ''; + $var = ''; + echo '
    '.$var.''; } } /** - * function to load data - * @param type $id + * function to load data. + * + * @param type $id + * * @return type file */ - public function get_data($id) { + public function get_data($id) + { $attachments = App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->get(); foreach ($attachments as $attachment) { - header('Content-type: application/' . $attachment->type . ''); - header('Content-Disposition: inline; filename=' . $attachment->name . ''); + header('Content-type: application/'.$attachment->type.''); + header('Content-Disposition: inline; filename='.$attachment->name.''); header('Content-Transfer-Encoding: binary'); echo $attachment->file; } } - } diff --git a/app/Http/Controllers/Agent/helpdesk/NotificationController.php b/app/Http/Controllers/Agent/helpdesk/NotificationController.php index 278c1ac94..37aea1162 100644 --- a/app/Http/Controllers/Agent/helpdesk/NotificationController.php +++ b/app/Http/Controllers/Agent/helpdesk/NotificationController.php @@ -5,38 +5,35 @@ namespace App\Http\Controllers\Agent\helpdesk; // controllers use App\Http\Controllers\Controller; // Model -use App\User; -use App\Model\helpdesk\Settings\Company; -use App\Model\helpdesk\Agent\Teams; use App\Model\helpdesk\Agent\Department; -use App\Model\helpdesk\Utility\Log_notification; +use App\Model\helpdesk\Agent\Teams; +use App\Model\helpdesk\Settings\Company; use App\Model\helpdesk\settings\Email; +use App\Model\helpdesk\Utility\Log_notification; +use App\User; // classes -use Exception; /** * NotificationController - * This controller is used to send daily notifications + * This controller is used to send daily notifications. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class NotificationController extends Controller { - +class NotificationController extends Controller +{ /** - * This function is for sending daily report/notification about the system + * This function is for sending daily report/notification about the system. * */ - public function send_notification() { + public function send_notification() + { //fetching email settings $email = Email::where('id', '=', '1')->first(); // checking if the daily notification is enabled or not if ($email->notification_cron == 1) { // checking if current date is equal to the last entered daily notification log $notification = Log_notification::where('log', '=', 'NOT-1')->orderBy('id', 'DESC')->first(); - $date = explode(" ", $notification->created_at); - if (Date('Y-m-d') == $date[0]) { - + $date = explode(' ', $notification->created_at); + if (date('Y-m-d') == $date[0]) { } else { // creating a daily notification log Log_notification::create(['log' => 'NOT-1']); @@ -54,28 +51,33 @@ class NotificationController extends Controller { } /** - * Admin Notification/Report + * Admin Notification/Report. + * * @param company + * * @return mail * */ - public function send_notification_to_admin($company) { + public function send_notification_to_admin($company) + { // get all admin users $users = User::where('role', '=', 'admin')->get(); foreach ($users as $user) { // Send notification details to admin $email = $user->email; - $user_name = $user->first_name . " " . $user->last_name; - \Mail::send('emails.notifications.admin', ['company' => $company, 'name' => $user_name], function ($message)use ($email, $user_name, $company) { - $message->to($email, $user_name)->subject($company . ' Daily Report '); + $user_name = $user->first_name.' '.$user->last_name; + \Mail::send('emails.notifications.admin', ['company' => $company, 'name' => $user_name], function ($message) use ($email, $user_name, $company) { + $message->to($email, $user_name)->subject($company.' Daily Report '); }); } } /** - * Department Manager Notification/Report + * Department Manager Notification/Report. + * * @return mail * */ - public function send_notification_to_manager($company) { + public function send_notification_to_manager($company) + { // get all department managers $depts = Department::all(); foreach ($depts as $dept) { @@ -85,9 +87,9 @@ class NotificationController extends Controller { foreach ($users as $user) { // Send notification details to manager of a department $email = $user->email; - $user_name = $user->first_name . " " . $user->last_name; - \Mail::send('emails.notifications.manager', ['company' => $company, 'name' => $user_name, 'dept_id' => $dept->id, 'dept_name' => $dept->name], function ($message)use ($email, $user_name, $company, $dept_name) { - $message->to($email, $user_name)->subject($company . ' Daily Report for department manager of ' . $dept_name . ' department.'); + $user_name = $user->first_name.' '.$user->last_name; + \Mail::send('emails.notifications.manager', ['company' => $company, 'name' => $user_name, 'dept_id' => $dept->id, 'dept_name' => $dept->name], function ($message) use ($email, $user_name, $company, $dept_name) { + $message->to($email, $user_name)->subject($company.' Daily Report for department manager of '.$dept_name.' department.'); }); } } @@ -95,10 +97,12 @@ class NotificationController extends Controller { } /** - * Team Lead Notification/Report + * Team Lead Notification/Report. + * * @return mail * */ - public function send_notification_to_team_lead($company) { + public function send_notification_to_team_lead($company) + { // get all Team leads $teams = Teams::all(); foreach ($teams as $team) { @@ -108,9 +112,9 @@ class NotificationController extends Controller { foreach ($users as $user) { // Send notification details to team lead $email = $user->email; - $user_name = $user->first_name . " " . $user->last_name; - \Mail::send('emails.notifications.lead', ['company' => $company, 'name' => $user_name, 'team_id' => $team->id], function ($message)use ($email, $user_name, $company, $team_name) { - $message->to($email, $user_name)->subject($company . ' Daily Report for Team Lead of team ' . $team_name); + $user_name = $user->first_name.' '.$user->last_name; + \Mail::send('emails.notifications.lead', ['company' => $company, 'name' => $user_name, 'team_id' => $team->id], function ($message) use ($email, $user_name, $company, $team_name) { + $message->to($email, $user_name)->subject($company.' Daily Report for Team Lead of team '.$team_name); }); } } @@ -118,35 +122,40 @@ class NotificationController extends Controller { } /** - * Agent Notification/Report + * Agent Notification/Report. + * * @return mail * */ - public function send_notification_to_agent($company) { + public function send_notification_to_agent($company) + { // get all agents users $users = User::where('role', '=', 'agent')->get(); foreach ($users as $user) { // Send notification details to all the agents $email = $user->email; - $user_name = $user->first_name . " " . $user->last_name; - \Mail::send('emails.notifications.agent', ['company' => $company, 'name' => $user_name, 'user_id' => 1], function ($message)use ($email, $user_name, $company) { - $message->to($email, $user_name)->subject($company . ' Daily Report for Agents'); + $user_name = $user->first_name.' '.$user->last_name; + \Mail::send('emails.notifications.agent', ['company' => $company, 'name' => $user_name, 'user_id' => 1], function ($message) use ($email, $user_name, $company) { + $message->to($email, $user_name)->subject($company.' Daily Report for Agents'); }); } } /** - * Fetching company name + * Fetching company name. + * * @return type variable */ - public function company() { + public function company() + { // fetching comapny model $company = Company::Where('id', '=', '1')->first(); // fetching company name if ($company->company_name == null) { - $company = "Support Center"; + $company = 'Support Center'; } else { $company = $company->company_name; } + return $company; } diff --git a/app/Http/Controllers/Agent/helpdesk/OrganizationController.php b/app/Http/Controllers/Agent/helpdesk/OrganizationController.php index a2d4d71e9..bfb5a1c98 100644 --- a/app/Http/Controllers/Agent/helpdesk/OrganizationController.php +++ b/app/Http/Controllers/Agent/helpdesk/OrganizationController.php @@ -6,13 +6,11 @@ namespace App\Http\Controllers\Agent\helpdesk; use App\Http\Controllers\Controller; // requests use App\Http\Requests\helpdesk\OrganizationRequest; - /* include organization model */ use App\Http\Requests\helpdesk\OrganizationUpdate; // models /* Define OrganizationRequest to validate the create form */ use App\Model\helpdesk\Agent_panel\Organization; - /* Define OrganizationUpdate to validate the create form */ use App\Model\helpdesk\Agent_panel\User_org; // classes @@ -22,21 +20,21 @@ use Exception; * OrganizationController * This controller is used to CRUD organization detail. * - * @package Controllers - * @subpackage Controller * @author Ladybird */ -class OrganizationController extends Controller { - +class OrganizationController extends Controller +{ /** * Create a new controller instance. * constructor to check * 1. authentication * 2. user roles - * 3. roles must be agent + * 3. roles must be agent. + * * @return void */ - public function __construct() { + public function __construct() + { // checking for authentication $this->middleware('auth'); // checking if the role is agent @@ -45,10 +43,13 @@ class OrganizationController extends Controller { /** * Display a listing of the resource. + * * @param type Organization $org + * * @return type Response */ - public function index() { + public function index() + { try { /* get all values of table organization */ return view('themes.default1.agent.helpdesk.organization.index'); @@ -58,10 +59,12 @@ class OrganizationController extends Controller { } /** - * This function is used to display the list of Organizations + * This function is used to display the list of Organizations. + * * @return datatable */ - public function org_list() { + public function org_list() + { // chumper datable package call to display Advance datatable return \Datatable::collection(Organization::all()) /* searchable name */ @@ -73,28 +76,31 @@ class OrganizationController extends Controller { // return $model->name; if (strlen($model->name) > 20) { $orgname = substr($model->name, 0, 25); - $orgname = substr($orgname, 0, strrpos($orgname, ' ')) . ' ...'; + $orgname = substr($orgname, 0, strrpos($orgname, ' ')).' ...'; } else { $orgname = $model->name; } + return $orgname; }) /* column website */ ->addColumn('website', function ($model) { $website = $model->website; + return $website; }) /* column phone number */ ->addColumn('phone', function ($model) { $phone = $model->phone; + return $phone; }) /* column action buttons */ ->addColumn('Actions', function ($model) { - // displaying action buttons + // displaying action buttons // modal popup to delete data - return ' ' . \Lang::get('lang.edit') . ' ' . \Lang::get('lang.view') . ' -