Applied fixes from StyleCI
This commit is contained in:

committed by
StyleCI Bot

parent
be5df5334f
commit
d637c2b23f
@@ -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 <info@ladybirdweb.com>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user