Applied fixes from StyleCI
This commit is contained in:

committed by
StyleCI Bot

parent
be5df5334f
commit
d637c2b23f
@@ -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 <info@ladybirdweb.com>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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 <info@ladybirdweb.com>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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 <info@ladybirdweb.com>
|
||||
*/
|
||||
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 = '<a href="" target="_blank"><img src="data:image/jpg;base64,' . base64_encode($data) . '"/></a>';
|
||||
echo '<br/><span class="mailbox-attachment-icon has-img">' . $var . '</span>';
|
||||
$var = '<a href="" target="_blank"><img src="data:image/jpg;base64,'.base64_encode($data).'"/></a>';
|
||||
echo '<br/><span class="mailbox-attachment-icon has-img">'.$var.'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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 <info@ladybirdweb.com>
|
||||
*/
|
||||
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 '<span data-toggle="modal" data-target="#deletearticle' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span> <a href="' . route('organizations.edit', $model->id) . '" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href="' . route('organizations.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
|
||||
<div class="modal fade" id="deletearticle' . $model->id . '">
|
||||
return '<span data-toggle="modal" data-target="#deletearticle'.$model->id.'"><a href="#" ><button class="btn btn-danger btn-xs"></a> '.\Lang::get('lang.delete').' </button></span> <a href="'.route('organizations.edit', $model->id).'" class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a> <a href="'.route('organizations.show', $model->id).'" class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>
|
||||
<div class="modal fade" id="deletearticle'.$model->id.'">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@@ -102,11 +108,11 @@ class OrganizationController extends Controller {
|
||||
<h4 class="modal-title">Are You Sure ?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
' . $model->user_name . '
|
||||
'.$model->user_name.'
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
|
||||
<a href="' . route('org.delete', $model->id) . '"><button class="btn btn-danger">delete</button></a>
|
||||
<a href="'.route('org.delete', $model->id).'"><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
@@ -117,9 +123,11 @@ class OrganizationController extends Controller {
|
||||
|
||||
/**
|
||||
* Show the form for creating a new organization.
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function create() {
|
||||
public function create()
|
||||
{
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.organization.create');
|
||||
} catch (Exception $e) {
|
||||
@@ -129,11 +137,14 @@ class OrganizationController extends Controller {
|
||||
|
||||
/**
|
||||
* Store a newly created organization in storage.
|
||||
* @param type Organization $org
|
||||
*
|
||||
* @param type Organization $org
|
||||
* @param type OrganizationRequest $request
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function store(Organization $org, OrganizationRequest $request) {
|
||||
public function store(Organization $org, OrganizationRequest $request)
|
||||
{
|
||||
try {
|
||||
/* Insert the all input request to organization table */
|
||||
/* Check whether function success or not */
|
||||
@@ -152,11 +163,14 @@ class OrganizationController extends Controller {
|
||||
|
||||
/**
|
||||
* Display the specified organization.
|
||||
* @param type $id
|
||||
*
|
||||
* @param type $id
|
||||
* @param type Organization $org
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function show($id, Organization $org) {
|
||||
public function show($id, Organization $org)
|
||||
{
|
||||
try {
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
@@ -169,11 +183,14 @@ class OrganizationController extends Controller {
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified organization.
|
||||
* @param type $id
|
||||
*
|
||||
* @param type $id
|
||||
* @param type Organization $org
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function edit($id, Organization $org) {
|
||||
public function edit($id, Organization $org)
|
||||
{
|
||||
try {
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
@@ -186,12 +203,15 @@ class OrganizationController extends Controller {
|
||||
|
||||
/**
|
||||
* Update the specified organization in storage.
|
||||
* @param type $id
|
||||
* @param type Organization $org
|
||||
*
|
||||
* @param type $id
|
||||
* @param type Organization $org
|
||||
* @param type OrganizationUpdate $request
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function update($id, Organization $org, OrganizationUpdate $request) {
|
||||
public function update($id, Organization $org, OrganizationUpdate $request)
|
||||
{
|
||||
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
@@ -213,10 +233,13 @@ class OrganizationController extends Controller {
|
||||
|
||||
/**
|
||||
* Delete a specified organization from storage.
|
||||
*
|
||||
* @param type int $id
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function destroy($id, Organization $org, User_org $user_org) {
|
||||
public function destroy($id, Organization $org, User_org $user_org)
|
||||
{
|
||||
|
||||
/* select the field by id */
|
||||
$orgs = $org->whereId($id)->first();
|
||||
@@ -237,11 +260,14 @@ class OrganizationController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Soring an organization head
|
||||
* @param type $id
|
||||
* Soring an organization head.
|
||||
*
|
||||
* @param type $id
|
||||
*
|
||||
* @return type boolean
|
||||
*/
|
||||
public function Head_Org($id) {
|
||||
public function Head_Org($id)
|
||||
{
|
||||
// get the user to make organization head
|
||||
$head_user = \Input::get('user');
|
||||
// get an instance of the selected organization
|
||||
@@ -249,7 +275,7 @@ class OrganizationController extends Controller {
|
||||
$org_head->head = $head_user;
|
||||
// save the user to organization head
|
||||
$org_head->save();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -3,56 +3,39 @@
|
||||
namespace App\Http\Controllers\Agent\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Http\Controllers\Common\SettingsController;
|
||||
use App\Http\Controllers\Common\SettingsController;use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\CreateTicketRequest;
|
||||
use App\Http\Requests\helpdesk\TicketRequest;
|
||||
use App\Http\Requests\helpdesk\TicketEditRequest;
|
||||
// models
|
||||
use App\Model\helpdesk\Email\Banlist;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Ticket\Ticket_attachments;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Collaborator;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\helpdesk\Settings\Alert;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Status;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\User;
|
||||
// classes
|
||||
use Auth;
|
||||
use Hash;
|
||||
use Input;
|
||||
use Mail;
|
||||
use PDF;
|
||||
|
||||
/**
|
||||
* TicketController2
|
||||
* TicketController2.
|
||||
*
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class Ticket2Controller extends Controller {
|
||||
|
||||
class Ticket2Controller extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
SettingsController::smtp();
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Inbox ticket list page
|
||||
* Show the Inbox ticket list page.
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function deptopen($id) {
|
||||
public function deptopen($id)
|
||||
{
|
||||
$dept = Department::where('name', '=', $id)->first();
|
||||
if (Auth::user()->role == 'agent') {
|
||||
if (Auth::user()->dept_id == $dept->id) {
|
||||
@@ -66,10 +49,12 @@ class Ticket2Controller extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Inbox ticket list page
|
||||
* Show the Inbox ticket list page.
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function deptclose($id) {
|
||||
public function deptclose($id)
|
||||
{
|
||||
$dept = Department::where('name', '=', $id)->first();
|
||||
if (Auth::user()->role == 'agent') {
|
||||
if (Auth::user()->dept_id == $dept->id) {
|
||||
@@ -83,10 +68,12 @@ class Ticket2Controller extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Inbox ticket list page
|
||||
* Show the Inbox ticket list page.
|
||||
*
|
||||
* @return type response
|
||||
*/
|
||||
public function deptinprogress($id) {
|
||||
public function deptinprogress($id)
|
||||
{
|
||||
$dept = Department::where('name', '=', $id)->first();
|
||||
if (Auth::user()->role == 'agent') {
|
||||
if (Auth::user()->dept_id == $dept->id) {
|
||||
@@ -98,5 +85,4 @@ class Ticket2Controller extends Controller {
|
||||
return view('themes.default1.agent.helpdesk.dept-ticket.inprogress', compact('id'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -19,30 +19,30 @@ use App\Model\helpdesk\Agent_panel\User_org;
|
||||
use App\User;
|
||||
// classes
|
||||
use Auth;
|
||||
use Exception;
|
||||
use Hash;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* UserController
|
||||
* This controller is used to CRUD an User details, and proile management of an agent
|
||||
* This controller is used to CRUD an User details, and proile management of an agent.
|
||||
*
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class UserController extends Controller {
|
||||
|
||||
class UserController 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
|
||||
@@ -51,10 +51,13 @@ class UserController extends Controller {
|
||||
|
||||
/**
|
||||
* Display all list of the users.
|
||||
*
|
||||
* @param type User $user
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
/* get all values in Sys_user */
|
||||
return view('themes.default1.agent.helpdesk.user.index');
|
||||
@@ -64,10 +67,12 @@ class UserController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to display the list of users using chumper datatables
|
||||
* This function is used to display the list of users using chumper datatables.
|
||||
*
|
||||
* @return datatable
|
||||
*/
|
||||
public function user_list() {
|
||||
public function user_list()
|
||||
{
|
||||
// displaying list of users with chumper datatables
|
||||
return \Datatable::collection(User::where('role', '!=', 'admin')->where('role', '!=', 'agent')->get())
|
||||
/* searchable column username */
|
||||
@@ -78,28 +83,31 @@ class UserController extends Controller {
|
||||
->addColumn('user_name', function ($model) {
|
||||
if (strlen($model->user_name) > 20) {
|
||||
$username = substr($model->user_name, 0, 30);
|
||||
$username = substr($username, 0, strrpos($username, ' ')) . ' ...';
|
||||
$username = substr($username, 0, strrpos($username, ' ')).' ...';
|
||||
} else {
|
||||
$username = $model->user_name;
|
||||
}
|
||||
|
||||
return $username;
|
||||
})
|
||||
/* column email */
|
||||
->addColumn('email', function ($model) {
|
||||
$email = $model->email;
|
||||
|
||||
return $email;
|
||||
})
|
||||
/* column phone */
|
||||
->addColumn('phone', function ($model) {
|
||||
$phone = "";
|
||||
$phone = '';
|
||||
if ($model->phone_number) {
|
||||
$phone = $model->ext . ' ' . $model->phone_number;
|
||||
$phone = $model->ext.' '.$model->phone_number;
|
||||
}
|
||||
$mobile = "";
|
||||
$mobile = '';
|
||||
if ($model->mobile) {
|
||||
$mobile = $model->mobile;
|
||||
}
|
||||
$phone = $phone . " " . $mobile;
|
||||
$phone = $phone.' '.$mobile;
|
||||
|
||||
return $phone;
|
||||
})
|
||||
/* column account status */
|
||||
@@ -110,6 +118,7 @@ class UserController extends Controller {
|
||||
} else {
|
||||
$stat = '<button class="btn btn-danger btn-xs">Inactive</button>';
|
||||
}
|
||||
|
||||
return $stat;
|
||||
})
|
||||
/* column ban status */
|
||||
@@ -120,25 +129,29 @@ class UserController extends Controller {
|
||||
} else {
|
||||
$stat = '<button class="btn btn-success btn-xs">Active</button>';
|
||||
}
|
||||
|
||||
return $stat;
|
||||
})
|
||||
/* column last login date */
|
||||
->addColumn('lastlogin', function ($model) {
|
||||
$t = $model->updated_at;
|
||||
|
||||
return TicketController::usertimezone($t);
|
||||
})
|
||||
/* column actions */
|
||||
->addColumn('Actions', function ($model) {
|
||||
return '<a href="' . route('user.edit', $model->id) . '" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>';
|
||||
return '<a href="'.route('user.edit', $model->id).'" class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a> <a href="'.route('user.show', $model->id).'" class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>';
|
||||
})
|
||||
->make();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new users.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function create() {
|
||||
public function create()
|
||||
{
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.user.create');
|
||||
} catch (Exception $e) {
|
||||
@@ -148,11 +161,14 @@ class UserController extends Controller {
|
||||
|
||||
/**
|
||||
* Store a newly created users in storage.
|
||||
* @param type User $user
|
||||
*
|
||||
* @param type User $user
|
||||
* @param type Sys_userRequest $request
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function store(User $user, Sys_userRequest $request) {
|
||||
public function store(User $user, Sys_userRequest $request)
|
||||
{
|
||||
/* insert the input request to sys_user table */
|
||||
/* Check whether function success or not */
|
||||
$user->email = $request->input('email');
|
||||
@@ -175,14 +191,18 @@ class UserController extends Controller {
|
||||
|
||||
/**
|
||||
* Display the specified users.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function show($id, User $user) {
|
||||
public function show($id, User $user)
|
||||
{
|
||||
try {
|
||||
/* select the field where id = $id(request Id) */
|
||||
$users = $user->whereId($id)->first();
|
||||
|
||||
return view('themes.default1.agent.helpdesk.user.show', compact('users'));
|
||||
} catch (Exception $e) {
|
||||
return view('404');
|
||||
@@ -191,14 +211,18 @@ class UserController extends Controller {
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param type int $id
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function edit($id, User $user) {
|
||||
public function edit($id, User $user)
|
||||
{
|
||||
try {
|
||||
/* select the field where id = $id(request Id) */
|
||||
$users = $user->whereId($id)->first();
|
||||
|
||||
return view('themes.default1.agent.helpdesk.user.edit', compact('users'));
|
||||
} catch (Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->errorInfo[2]);
|
||||
@@ -207,12 +231,15 @@ class UserController extends Controller {
|
||||
|
||||
/**
|
||||
* Update the specified user in storage.
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type User $user
|
||||
* @param type Sys_userUpdate $request
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function update($id, User $user, Sys_userUpdate $request) {
|
||||
public function update($id, User $user, Sys_userUpdate $request)
|
||||
{
|
||||
|
||||
/* select the field where id = $id(request Id) */
|
||||
$users = $user->whereId($id)->first();
|
||||
@@ -229,10 +256,12 @@ class UserController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* get agent profile page
|
||||
* get agent profile page.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function getProfile() {
|
||||
public function getProfile()
|
||||
{
|
||||
$user = Auth::user();
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.user.profile', compact('user'));
|
||||
@@ -242,10 +271,12 @@ class UserController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* get profile edit page
|
||||
* get profile edit page.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function getProfileedit() {
|
||||
public function getProfileedit()
|
||||
{
|
||||
$user = Auth::user();
|
||||
try {
|
||||
return view('themes.default1.agent.helpdesk.user.profile-edit', compact('user'));
|
||||
@@ -255,12 +286,15 @@ class UserController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* post profile edit
|
||||
* @param type int $id
|
||||
* post profile edit.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type ProfileRequest $request
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function postProfileedit(ProfileRequest $request) {
|
||||
public function postProfileedit(ProfileRequest $request)
|
||||
{
|
||||
// geet authenticated user details
|
||||
$user = Auth::user();
|
||||
$user->gender = $request->input('gender');
|
||||
@@ -284,7 +318,7 @@ class UserController extends Controller {
|
||||
// fetching upload destination path
|
||||
$destinationPath = 'lb-faveo/media/profilepic';
|
||||
// adding a random value to profile picture filename
|
||||
$fileName = rand(0000, 9999) . '.' . $name;
|
||||
$fileName = rand(0000, 9999).'.'.$name;
|
||||
// moving the picture to a destination folder
|
||||
Input::file('profile_pic')->move($destinationPath, $fileName);
|
||||
// saving filename to database
|
||||
@@ -292,6 +326,7 @@ class UserController extends Controller {
|
||||
} else {
|
||||
try {
|
||||
$user->fill($request->except('profile_pic', 'gender'))->save();
|
||||
|
||||
return Redirect::route('profile')->with('success', 'Profile Updated sucessfully');
|
||||
} catch (Exception $e) {
|
||||
return Redirect::route('profile')->with('success', $e->errorInfo[2]);
|
||||
@@ -303,19 +338,23 @@ class UserController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Post profile password
|
||||
* @param type int $id
|
||||
* Post profile password.
|
||||
*
|
||||
* @param type int $id
|
||||
* @param type ProfilePassword $request
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function postProfilePassword($id, ProfilePassword $request) {
|
||||
// get authenticated user
|
||||
public function postProfilePassword($id, ProfilePassword $request)
|
||||
{
|
||||
// get authenticated user
|
||||
$user = Auth::user();
|
||||
// checking if the old password matches the new password
|
||||
if (Hash::check($request->input('old_password'), $user->getAuthPassword())) {
|
||||
$user->password = Hash::make($request->input('new_password'));
|
||||
try {
|
||||
$user->save();
|
||||
|
||||
return redirect('profile-edit')->with('success1', 'Password Updated sucessfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect('profile-edit')->with('fails', $e->errorInfo[2]);
|
||||
@@ -326,25 +365,32 @@ class UserController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigning an user to an organization
|
||||
* @param type $id
|
||||
* Assigning an user to an organization.
|
||||
*
|
||||
* @param type $id
|
||||
*
|
||||
* @return type boolean
|
||||
*/
|
||||
public function UserAssignOrg($id) {
|
||||
public function UserAssignOrg($id)
|
||||
{
|
||||
$org = Input::get('org');
|
||||
$user_org = new User_org;
|
||||
$user_org = new User_org();
|
||||
$user_org->org_id = $org;
|
||||
$user_org->user_id = $id;
|
||||
$user_org->save();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* creating an organization in user profile page via modal popup
|
||||
* @param type $id
|
||||
* creating an organization in user profile page via modal popup.
|
||||
*
|
||||
* @param type $id
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function User_Create_Org($id) {
|
||||
public function User_Create_Org($id)
|
||||
{
|
||||
// checking if the entered value for website is available in database
|
||||
if (Input::get('website') != null) {
|
||||
// checking website
|
||||
@@ -356,14 +402,14 @@ class UserController extends Controller {
|
||||
$check2 = Organization::where('name', '=', Input::get('name'))->first();
|
||||
// if any of the fields is not available then return false
|
||||
if (\Input::get('name') == null) {
|
||||
return "Name is required";
|
||||
return 'Name is required';
|
||||
} elseif ($check2 != null) {
|
||||
return "Name should be Unique";
|
||||
return 'Name should be Unique';
|
||||
} elseif ($check != null) {
|
||||
return "Website should be Unique";
|
||||
return 'Website should be Unique';
|
||||
} else {
|
||||
// storing organization details and assigning the current user to that organization
|
||||
$org = new Organization;
|
||||
$org = new Organization();
|
||||
$org->name = Input::get('name');
|
||||
$org->phone = Input::get('phone');
|
||||
$org->website = Input::get('website');
|
||||
@@ -371,7 +417,7 @@ class UserController extends Controller {
|
||||
$org->internal_notes = Input::get('internal');
|
||||
$org->save();
|
||||
|
||||
$user_org = new User_org;
|
||||
$user_org = new User_org();
|
||||
$user_org->org_id = $org->id;
|
||||
$user_org->user_id = $id;
|
||||
$user_org->save();
|
||||
@@ -379,5 +425,4 @@ class UserController extends Controller {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -3,47 +3,46 @@
|
||||
namespace App\Http\Controllers\Agent\kb;
|
||||
|
||||
// Controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Agent\kb\SettingsController;
|
||||
use App\Http\Controllers\Client\kb\UserController;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
// Requests
|
||||
use App\Http\Requests\kb\ArticleRequest;
|
||||
use App\Http\Requests\kb\ArticleUpdate;
|
||||
// Models
|
||||
use App\Model\kb\Article;
|
||||
use App\Model\kb\Category;
|
||||
use App\Model\kb\Comment;
|
||||
use App\Model\kb\Relationship;
|
||||
use App\Model\kb\Settings;
|
||||
use App\Model\kb\Comment;
|
||||
// Classes
|
||||
use Auth;
|
||||
use Chumper\Datatable\Table;
|
||||
use Datatable;
|
||||
use DB;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Redirect;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* ArticleController
|
||||
* This controller is used to CRUD Articles
|
||||
* This controller is used to CRUD Articles.
|
||||
*
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class ArticleController extends Controller {
|
||||
|
||||
class ArticleController 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 roles
|
||||
@@ -51,16 +50,19 @@ class ArticleController extends Controller {
|
||||
SettingsController::language();
|
||||
}
|
||||
|
||||
public function test() {
|
||||
public function test()
|
||||
{
|
||||
//$table = $this->setDatatable();
|
||||
return view('themes.default1.agent.kb.article.test');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetching all the list of articles in a chumper datatable format
|
||||
* Fetching all the list of articles in a chumper datatable format.
|
||||
*
|
||||
* @return type void
|
||||
*/
|
||||
public function getData() {
|
||||
public function getData()
|
||||
{
|
||||
// returns chumper datatable
|
||||
return Datatable::collection(Article::All())
|
||||
/* searcable column name */
|
||||
@@ -74,13 +76,14 @@ class ArticleController extends Controller {
|
||||
/* add column Created */
|
||||
->addColumn('Created', function ($model) {
|
||||
$t = $model->created_at;
|
||||
|
||||
return TicketController::usertimezone($t);
|
||||
})
|
||||
/* add column action */
|
||||
->addColumn('Actions', function ($model) {
|
||||
/* here are all the action buttons and modal popup to delete articles with confirmations */
|
||||
return '<span data-toggle="modal" data-target="#deletearticle' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span> <a href=article/' . $model->id . '/edit class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href=show/' . $model->slug . ' class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
|
||||
<div class="modal fade" id="deletearticle' . $model->id . '">
|
||||
return '<span data-toggle="modal" data-target="#deletearticle'.$model->id.'"><a href="#" ><button class="btn btn-danger btn-xs"></a> '.\Lang::get('lang.delete').' </button></span> <a href=article/'.$model->id.'/edit class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a> <a href=show/'.$model->slug.' class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>
|
||||
<div class="modal fade" id="deletearticle'.$model->id.'">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@@ -88,11 +91,11 @@ class ArticleController extends Controller {
|
||||
<h4 class="modal-title">Are You Sure ?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
' . $model->name . '
|
||||
'.$model->name.'
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
|
||||
<a href="article/delete/' . $model->slug . '"><button class="btn btn-danger">delete</button></a>
|
||||
<a href="article/delete/'.$model->slug.'"><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
@@ -102,10 +105,12 @@ class ArticleController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* List of Articles
|
||||
* List of Articles.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
/* show article list */
|
||||
try {
|
||||
return view('themes.default1.agent.kb.article.index');
|
||||
@@ -115,11 +120,14 @@ class ArticleController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creating a Article
|
||||
* Creating a Article.
|
||||
*
|
||||
* @param type Category $category
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function create(Category $category) {
|
||||
public function create(Category $category)
|
||||
{
|
||||
/* get the attributes of the category */
|
||||
$category = $category->lists('id', 'name');
|
||||
/* get the create page */
|
||||
@@ -131,17 +139,20 @@ class ArticleController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the values to the article
|
||||
* @param type Article $article
|
||||
* Insert the values to the article.
|
||||
*
|
||||
* @param type Article $article
|
||||
* @param type ArticleRequest $request
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function store(Article $article, ArticleRequest $request) {
|
||||
public function store(Article $article, ArticleRequest $request)
|
||||
{
|
||||
// requesting the values to store article data
|
||||
$publishTime = $request->input('year') . '-' . $request->input('month') . '-' . $request->input('day') . ' ' . $request->input('hour') . ':' . $request->input('minute') . ':00';
|
||||
$publishTime = $request->input('year').'-'.$request->input('month').'-'.$request->input('day').' '.$request->input('hour').':'.$request->input('minute').':00';
|
||||
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, "-");
|
||||
$slug = str_slug($sl, '-');
|
||||
$article->slug = $slug;
|
||||
$article->publish_time = $publishTime;
|
||||
$article->fill($request->except('created_at', 'slug'))->save();
|
||||
@@ -155,21 +166,25 @@ class ArticleController extends Controller {
|
||||
/* insert the values to the article table */
|
||||
try {
|
||||
$article->fill($request->except('slug'))->save();
|
||||
|
||||
return redirect('article')->with('success', 'Article Inserted Successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect('article')->with('fails', 'Article Not Inserted' . '<li>' . $e->errorInfo[2] . '</li>');
|
||||
return redirect('article')->with('fails', 'Article Not Inserted'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit an Article by id
|
||||
* @param type Integer $id
|
||||
* @param type Article $article
|
||||
* Edit an Article by id.
|
||||
*
|
||||
* @param type Integer $id
|
||||
* @param type Article $article
|
||||
* @param type Relationship $relation
|
||||
* @param type Category $category
|
||||
* @param type Category $category
|
||||
*
|
||||
* @return view
|
||||
*/
|
||||
public function edit($slug, Article $article, Relationship $relation, Category $category) {
|
||||
public function edit($slug, Article $article, Relationship $relation, Category $category)
|
||||
{
|
||||
$aid = $article->where('id', $slug)->first();
|
||||
$id = $aid->id;
|
||||
/* define the selected fields */
|
||||
@@ -188,20 +203,23 @@ class ArticleController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an Artile by id
|
||||
* @param type Integer $id
|
||||
* @param type Article $article
|
||||
* @param type Relationship $relation
|
||||
* Update an Artile by id.
|
||||
*
|
||||
* @param type Integer $id
|
||||
* @param type Article $article
|
||||
* @param type Relationship $relation
|
||||
* @param type ArticleRequest $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update($slug, Article $article, Relationship $relation, ArticleUpdate $request) {
|
||||
public function update($slug, Article $article, Relationship $relation, ArticleUpdate $request)
|
||||
{
|
||||
$aid = $article->where('id', $slug)->first();
|
||||
$publishTime = $request->input('year') . '-' . $request->input('month') . '-' . $request->input('day') . ' ' . $request->input('hour') . ':' . $request->input('minute') . ':00';
|
||||
$publishTime = $request->input('year').'-'.$request->input('month').'-'.$request->input('day').' '.$request->input('hour').':'.$request->input('minute').':00';
|
||||
|
||||
$id = $aid->id;
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, "-");
|
||||
$slug = str_slug($sl, '-');
|
||||
// dd($slug);
|
||||
|
||||
$article->slug = $slug;
|
||||
@@ -221,26 +239,31 @@ class ArticleController extends Controller {
|
||||
$article->slug = $slug;
|
||||
$article->publish_time = $publishTime;
|
||||
$article->save();
|
||||
|
||||
return redirect('article')->with('success', 'Article Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect('article')->with('fails', 'Article Not Updated' . '<li>' . $e->errorInfo[2] . '</li>');
|
||||
return redirect('article')->with('fails', 'Article Not Updated'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an Agent by id
|
||||
* @param type $id
|
||||
* Delete an Agent by id.
|
||||
*
|
||||
* @param type $id
|
||||
* @param type Article $article
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy($slug, Article $article, Relationship $relation, Comment $comment) {
|
||||
public function destroy($slug, Article $article, Relationship $relation, Comment $comment)
|
||||
{
|
||||
/* delete the selected article from the table */
|
||||
$article = $article->where('slug', $slug)->first(); //get the selected article via id
|
||||
$id = $article->id;
|
||||
$comments = $comment->where('article_id', $id)->get();
|
||||
if ($comments) {
|
||||
foreach ($comments as $comment)
|
||||
foreach ($comments as $comment) {
|
||||
$comment->delete();
|
||||
}
|
||||
}
|
||||
// deleting relationship
|
||||
$relation = $relation->where('article_id', $id)->first();
|
||||
@@ -260,11 +283,14 @@ class ArticleController extends Controller {
|
||||
|
||||
/**
|
||||
* user time zone
|
||||
* fetching timezone
|
||||
* fetching timezone.
|
||||
*
|
||||
* @param type $utc
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
static function usertimezone($utc) {
|
||||
public static function usertimezone($utc)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$tz = $user->timezone;
|
||||
$set = Settings::whereId('1')->first();
|
||||
@@ -275,5 +301,4 @@ class ArticleController extends Controller {
|
||||
$date = date($format, strtotime($utc) + $offset);
|
||||
echo $date;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -3,11 +3,8 @@
|
||||
namespace App\Http\Controllers\Agent\kb;
|
||||
|
||||
// Controllers
|
||||
use App\Http\Controllers\client\kb\UserController;
|
||||
use App\Http\Controllers\admin\kb\ArticleController;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Agent\kb\SettingsController;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// Requests
|
||||
use App\Http\Requests\kb\CategoryRequest;
|
||||
use App\Http\Requests\kb\CategoryUpdate;
|
||||
@@ -16,28 +13,28 @@ use App\Model\kb\Category;
|
||||
use App\Model\kb\Relationship;
|
||||
// Classes
|
||||
use Datatable;
|
||||
use Redirect;
|
||||
use Exception;
|
||||
use Redirect;
|
||||
|
||||
/**
|
||||
* CategoryController
|
||||
* This controller is used to CRUD category
|
||||
* This controller is used to CRUD category.
|
||||
*
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class CategoryController extends Controller {
|
||||
|
||||
class CategoryController 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 roles
|
||||
@@ -46,11 +43,14 @@ class CategoryController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Indexing all Category
|
||||
* Indexing all Category.
|
||||
*
|
||||
* @param type Category $category
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
/* get the view of index of the catogorys with all attributes
|
||||
of category model */
|
||||
try {
|
||||
@@ -61,10 +61,12 @@ class CategoryController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* fetching category list in chumper datatables
|
||||
* fetching category list in chumper datatables.
|
||||
*
|
||||
* @return type chumper datatable
|
||||
*/
|
||||
public function getData() {
|
||||
public function getData()
|
||||
{
|
||||
/* fetching chumper datatables */
|
||||
return Datatable::collection(Category::All())
|
||||
/* search column name */
|
||||
@@ -78,13 +80,14 @@ class CategoryController extends Controller {
|
||||
/* add column Created */
|
||||
->addColumn('Created', function ($model) {
|
||||
$t = $model->created_at;
|
||||
|
||||
return TicketController::usertimezone($t);
|
||||
})
|
||||
/* add column Actions */
|
||||
/* there are action buttons and modal popup to delete a data column */
|
||||
->addColumn('Actions', function ($model) {
|
||||
return '<span data-toggle="modal" data-target="#deletecategory' . $model->slug . '"><a href="#" ><button class="btn btn-danger btn-xs"></a>' . \Lang::get("lang.delete") . '</button></span> <a href=category/' . $model->id . '/edit class="btn btn-warning btn-xs">' . \Lang::get("lang.edit") . '</a> <a href=article-list class="btn btn-primary btn-xs">' . \Lang::get("lang.view") . '</a>
|
||||
<div class="modal fade" id="deletecategory' . $model->slug . '">
|
||||
return '<span data-toggle="modal" data-target="#deletecategory'.$model->slug.'"><a href="#" ><button class="btn btn-danger btn-xs"></a>'.\Lang::get('lang.delete').'</button></span> <a href=category/'.$model->id.'/edit class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a> <a href=article-list class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>
|
||||
<div class="modal fade" id="deletecategory'.$model->slug.'">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@@ -92,11 +95,11 @@ class CategoryController extends Controller {
|
||||
<h4 class="modal-title">Are You Sure ?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
' . $model->name . '
|
||||
'.$model->name.'
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
|
||||
<a href="category/delete/' . $model->id . '"><button class="btn btn-danger">delete</button></a>
|
||||
<a href="category/delete/'.$model->id.'"><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -106,11 +109,14 @@ class CategoryController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Category
|
||||
* Create a Category.
|
||||
*
|
||||
* @param type Category $category
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function create(Category $category) {
|
||||
public function create(Category $category)
|
||||
{
|
||||
/* Get the all attributes in the category model */
|
||||
$category = $category->get();
|
||||
/* get the view page to create new category with all attributes
|
||||
@@ -123,32 +129,39 @@ class CategoryController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* To store the selected category
|
||||
* @param type Category $category
|
||||
* @param type CategoryRequest $request
|
||||
* To store the selected category.
|
||||
*
|
||||
* @param type Category $category
|
||||
* @param type CategoryRequest $request
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function store(Category $category, CategoryRequest $request) {
|
||||
public function store(Category $category, CategoryRequest $request)
|
||||
{
|
||||
/* Get the whole request from the form and insert into table via model */
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, "-");
|
||||
$slug = str_slug($sl, '-');
|
||||
$category->slug = $slug;
|
||||
// send success message to index page
|
||||
try {
|
||||
$category->fill($request->except('slug'))->save();
|
||||
|
||||
return Redirect::back()->with('success', 'Category Inserted Successfully');
|
||||
} catch (Exception $e) {
|
||||
return Redirect::back()->with('fails', 'Category Not Inserted' . '<li>' . $e->errorInfo[2] . '</li>');
|
||||
return Redirect::back()->with('fails', 'Category Not Inserted'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified category.
|
||||
* @param type $slug
|
||||
* @param type Category $category
|
||||
*
|
||||
* @param type $slug
|
||||
* @param type Category $category
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function edit($slug, Category $category) {
|
||||
public function edit($slug, Category $category)
|
||||
{
|
||||
// fetch the category
|
||||
$cid = $category->where('id', $slug)->first();
|
||||
$id = $cid->id;
|
||||
@@ -160,17 +173,20 @@ class CategoryController extends Controller {
|
||||
|
||||
/**
|
||||
* Update the specified Category in storage.
|
||||
* @param type $slug
|
||||
* @param type Category $category
|
||||
* @param type CategoryUpdate $request
|
||||
*
|
||||
* @param type $slug
|
||||
* @param type Category $category
|
||||
* @param type CategoryUpdate $request
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function update($slug, Category $category, CategoryUpdate $request) {
|
||||
public function update($slug, Category $category, CategoryUpdate $request)
|
||||
{
|
||||
|
||||
/* Edit the selected category via id */
|
||||
$category = $category->where('id', $slug)->first();
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, "-");
|
||||
$slug = str_slug($sl, '-');
|
||||
// dd($slug);
|
||||
$category->slug = $slug;
|
||||
/* update the values at the table via model according with the request */
|
||||
@@ -179,22 +195,25 @@ class CategoryController extends Controller {
|
||||
$category->fill($request->all())->save();
|
||||
$category->slug = $slug;
|
||||
$category->save();
|
||||
|
||||
return redirect('category')->with('success', 'Category Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
//redirect to index with fails message
|
||||
return redirect('category')->with('fails', 'Category Not Updated' . '<li>' . $e->errorInfo[2] . '</li>');
|
||||
return redirect('category')->with('fails', 'Category Not Updated'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified category from storage.
|
||||
* @param type $id
|
||||
* @param type Category $category
|
||||
* @param type Relationship $relation
|
||||
*
|
||||
* @param type $id
|
||||
* @param type Category $category
|
||||
* @param type Relationship $relation
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function destroy($id, Category $category, Relationship $relation) {
|
||||
|
||||
public function destroy($id, Category $category, Relationship $relation)
|
||||
{
|
||||
$relation = $relation->where('category_id', $id)->first();
|
||||
if ($relation != null) {
|
||||
return Redirect::back()->with('fails', 'Category Not Deleted');
|
||||
@@ -204,11 +223,11 @@ class CategoryController extends Controller {
|
||||
// redirect to index with success message
|
||||
try {
|
||||
$category->delete();
|
||||
|
||||
return Redirect::back()->with('success', 'Category Deleted Successfully');
|
||||
} catch (Exception $e) {
|
||||
return Redirect::back()->with('fails', 'Category Not Deleted' . '<li>' . $e->errorInfo[2] . '</li>');
|
||||
return Redirect::back()->with('fails', 'Category Not Deleted'.'<li>'.$e->errorInfo[2].'</li>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,41 +2,37 @@
|
||||
|
||||
namespace App\Http\Controllers\Agent\kb;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\client\kb\UserController;
|
||||
use App\Http\Controllers\Agent\kb\ArticleController;
|
||||
// controllersuse App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Agent\kb\SettingsController;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
// request
|
||||
use App\Http\Requests\kb\PageRequest;
|
||||
use App\Http\Requests\kb\PageUpdate;
|
||||
use Illuminate\Http\Request;
|
||||
// Model
|
||||
use App\Model\kb\Page;
|
||||
// classes
|
||||
// Model
|
||||
use Datatable;
|
||||
// classes
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* PageController
|
||||
* This controller is used to CRUD Pages
|
||||
* This controller is used to CRUD Pages.
|
||||
*
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class PageController extends Controller {
|
||||
|
||||
class PageController 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(Page $page) {
|
||||
public function __construct(Page $page)
|
||||
{
|
||||
// checking authentication
|
||||
$this->middleware('auth');
|
||||
// checking roles
|
||||
@@ -46,10 +42,12 @@ class PageController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the list of pages
|
||||
* Display the list of pages.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
$pages = $this->page->paginate(3);
|
||||
$pages->setPath('page');
|
||||
try {
|
||||
@@ -60,10 +58,12 @@ class PageController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* fetching pages list in chumper datatables
|
||||
* fetching pages list in chumper datatables.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getData() {
|
||||
public function getData()
|
||||
{
|
||||
/* fetching chumper datatables */
|
||||
return Datatable::collection(Page::All())
|
||||
/* search column name */
|
||||
@@ -77,13 +77,14 @@ class PageController extends Controller {
|
||||
/* add column Created */
|
||||
->addColumn('Created', function ($model) {
|
||||
$t = $model->created_at;
|
||||
|
||||
return TicketController::usertimezone($t);
|
||||
})
|
||||
/* add column Actions */
|
||||
/* there are action buttons and modal popup to delete a data column */
|
||||
->addColumn('Actions', function ($model) {
|
||||
return '<span data-toggle="modal" data-target="#deletepage' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . '</button></span> <a href=page/' . $model->slug . '/edit class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href=pages/' . $model->slug . ' class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
|
||||
<div class="modal fade" id="deletepage' . $model->id . '">
|
||||
return '<span data-toggle="modal" data-target="#deletepage'.$model->id.'"><a href="#" ><button class="btn btn-danger btn-xs"></a> '.\Lang::get('lang.delete').'</button></span> <a href=page/'.$model->slug.'/edit class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a> <a href=pages/'.$model->slug.' class="btn btn-primary btn-xs">'.\Lang::get('lang.view').'</a>
|
||||
<div class="modal fade" id="deletepage'.$model->id.'">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@@ -91,11 +92,11 @@ class PageController extends Controller {
|
||||
<h4 class="modal-title">Are You Sure ?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
' . $model->name . '
|
||||
'.$model->name.'
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
|
||||
<a href="page/delete/' . $model->id . '"><button class="btn btn-danger">delete</button></a>
|
||||
<a href="page/delete/'.$model->id.'"><button class="btn btn-danger">delete</button></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -106,23 +107,29 @@ class PageController extends Controller {
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function create() {
|
||||
public function create()
|
||||
{
|
||||
return view('themes.default1.agent.kb.pages.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* To insert a value to the table Page
|
||||
* To insert a value to the table Page.
|
||||
*
|
||||
* @param type Request $request
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function store(PageRequest $request) {
|
||||
public function store(PageRequest $request)
|
||||
{
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, "-");
|
||||
$slug = str_slug($sl, '-');
|
||||
$this->page->slug = $slug;
|
||||
try {
|
||||
$this->page->fill($request->except('slug'))->save();
|
||||
|
||||
return redirect('page')->with('success', 'Page created successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect('page')->with('fails', $e->errorInfo[2]);
|
||||
@@ -130,13 +137,17 @@ class PageController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* To edit a page
|
||||
* @param type $slug
|
||||
* To edit a page.
|
||||
*
|
||||
* @param type $slug
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function edit($slug) {
|
||||
public function edit($slug)
|
||||
{
|
||||
try {
|
||||
$page = $this->page->where('slug', $slug)->first();
|
||||
|
||||
return view('themes.default1.agent.kb.pages.edit', compact('page'));
|
||||
} catch (Exception $e) {
|
||||
return redirect('page')->with('fails', $e->errorInfo[2]);
|
||||
@@ -144,21 +155,25 @@ class PageController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* To update a page
|
||||
* @param type $slug
|
||||
* @param type PageUpdate $request
|
||||
* To update a page.
|
||||
*
|
||||
* @param type $slug
|
||||
* @param type PageUpdate $request
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function update($slug, PageUpdate $request) {
|
||||
public function update($slug, PageUpdate $request)
|
||||
{
|
||||
// get pages with respect to slug
|
||||
$pages = $this->page->where('slug', $slug)->first();
|
||||
$sl = $request->input('slug');
|
||||
$slug = str_slug($sl, "-");
|
||||
$slug = str_slug($sl, '-');
|
||||
$this->page->slug = $slug;
|
||||
try {
|
||||
$pages->fill($request->all())->save();
|
||||
$pages->slug = $slug;
|
||||
$pages->save();
|
||||
|
||||
return redirect('page')->with('success', 'Your Page Updated Successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect('page')->with('fails', $e->errorInfo[2]);
|
||||
@@ -166,19 +181,22 @@ class PageController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* To Delete a Page
|
||||
* @param type $id
|
||||
* To Delete a Page.
|
||||
*
|
||||
* @param type $id
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function destroy($id) {
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
// get the page to be deleted
|
||||
$page = $this->page->whereId($id)->first();
|
||||
$page->delete();
|
||||
|
||||
return redirect('page')->with('success', 'Page Deleted Successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect('page')->with('fails', $e->errorInfo[2]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,54 +2,45 @@
|
||||
|
||||
namespace App\Http\Controllers\Agent\kb;
|
||||
|
||||
// Controllers
|
||||
use App\Http\Controllers\Agent\kb\ArticleController;
|
||||
use App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
// Controllersuse App\Http\Controllers\Agent\helpdesk\TicketController;
|
||||
use App\Http\Controllers\Controller;
|
||||
// Request
|
||||
use App\Http\Requests\kb\FooterRequest;
|
||||
use App\Http\Requests\kb\ProfilePassword;
|
||||
use App\Http\Requests\kb\ProfileRequest;
|
||||
use App\Http\Requests\kb\SettingsRequests;
|
||||
use App\Http\Requests\kb\SocialRequest;
|
||||
use Illuminate\Http\Request;
|
||||
// Model
|
||||
use App\Model\kb\Comment;
|
||||
use App\Model\kb\Faq;
|
||||
use App\Model\kb\Settings;
|
||||
use App\Model\kb\Side1;
|
||||
use App\Model\kb\Side2;
|
||||
use App\Model\kb\Social;
|
||||
use App\Model\helpdesk\Utility\Timezones;
|
||||
use App\Model\helpdesk\Utility\Date_format;
|
||||
// Classes
|
||||
// Model
|
||||
use App\Model\helpdesk\Utility\Timezones;
|
||||
use App\Model\kb\Comment;
|
||||
use App\Model\kb\Settings;
|
||||
use Auth;
|
||||
// Classes
|
||||
use Config;
|
||||
use Datatable;
|
||||
use Exception;
|
||||
use Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use Image;
|
||||
use Input;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* SettingsController
|
||||
* This controller is used to perform settings in the setting page of knowledgebase
|
||||
* This controller is used to perform settings in the setting page of knowledgebase.
|
||||
*
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class SettingsController extends Controller {
|
||||
|
||||
class SettingsController 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 roles
|
||||
@@ -58,11 +49,12 @@ class SettingsController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* to get the settings page
|
||||
* to get the settings page.
|
||||
*
|
||||
* @return response
|
||||
* @package default
|
||||
*/
|
||||
public function settings(Settings $settings, Timezones $time, Date_format $date) {
|
||||
public function settings(Settings $settings, Timezones $time, Date_format $date)
|
||||
{
|
||||
/* get the setting where the id == 1 */
|
||||
$settings = $settings->whereId('1')->first();
|
||||
$time = $time->get();
|
||||
@@ -73,40 +65,42 @@ class SettingsController extends Controller {
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function postSettings($id, Settings $settings, SettingsRequests $request) {
|
||||
public function postSettings($id, Settings $settings, SettingsRequests $request)
|
||||
{
|
||||
try {
|
||||
/* fetch the values of company request */
|
||||
$settings = $settings->whereId('1')->first();
|
||||
if (Input::file('logo')) {
|
||||
$name = Input::file('logo')->getClientOriginalName();
|
||||
$destinationPath = 'lb-faveo/dist/image';
|
||||
$fileName = rand(0000, 9999) . '.' . $name;
|
||||
$fileName = rand(0000, 9999).'.'.$name;
|
||||
//echo $fileName;
|
||||
Input::file('logo')->move($destinationPath, $fileName);
|
||||
$settings->logo = $fileName;
|
||||
//$thDestinationPath = 'dist/th';
|
||||
Image::make($destinationPath . '/' . $fileName, array(
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
Image::make($destinationPath.'/'.$fileName, [
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'grayscale' => false,
|
||||
))->save('lb-faveo/dist/image/' . $fileName);
|
||||
])->save('lb-faveo/dist/image/'.$fileName);
|
||||
}
|
||||
if (Input::file('background')) {
|
||||
$name = Input::file('background')->getClientOriginalName();
|
||||
$destinationPath = 'lb-faveo/dist/image';
|
||||
$fileName = rand(0000, 9999) . '.' . $name;
|
||||
$fileName = rand(0000, 9999).'.'.$name;
|
||||
echo $fileName;
|
||||
Input::file('background')->move($destinationPath, $fileName);
|
||||
$settings->background = $fileName;
|
||||
//$thDestinationPath = 'dist/th';
|
||||
Image::make($destinationPath . '/' . $fileName, array(
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
Image::make($destinationPath.'/'.$fileName, [
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'grayscale' => false,
|
||||
))->save('lb-faveo/dist/image/' . $fileName);
|
||||
])->save('lb-faveo/dist/image/'.$fileName);
|
||||
}
|
||||
/* Check whether function success or not */
|
||||
if ($settings->fill($request->except('logo', 'background'))->save() == true) {
|
||||
@@ -123,19 +117,24 @@ class SettingsController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* To Moderate the commenting
|
||||
* To Moderate the commenting.
|
||||
*
|
||||
* @param type Comment $comment
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function comment(Comment $comment) {
|
||||
public function comment(Comment $comment)
|
||||
{
|
||||
return view('themes.default1.agent.kb.settings.comment');
|
||||
}
|
||||
|
||||
/**
|
||||
* getdata
|
||||
* @return type
|
||||
* getdata.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getData() {
|
||||
public function getData()
|
||||
{
|
||||
return \Datatable::collection(Comment::All())
|
||||
->searchColumns('name', 'email', 'comment', 'created')
|
||||
->orderColumns('name')
|
||||
@@ -154,67 +153,79 @@ class SettingsController extends Controller {
|
||||
->addColumn('status', function ($model) {
|
||||
$status = $model->status;
|
||||
if ($status == 1) {
|
||||
return '<p style="color:blue"">' . \Lang::get('lang.published');
|
||||
return '<p style="color:blue"">'.\Lang::get('lang.published');
|
||||
} else {
|
||||
return '<p style="color:red"">' . \Lang::get('lang.not_published');
|
||||
return '<p style="color:red"">'.\Lang::get('lang.not_published');
|
||||
}
|
||||
})
|
||||
->addColumn('Created', function ($model) {
|
||||
return TicketController::usertimezone(date($model->created_at));
|
||||
})
|
||||
->addColumn('Actions', function ($model) {
|
||||
return '<a href=comment/delete/' . $model->id . ' class="btn btn-danger btn-xs">' . \Lang::get('lang.delete') . '</a> <a href=published/' . $model->id . ' class="btn btn-warning btn-xs">' . \Lang::get('lang.publish') . '</a>';
|
||||
return '<a href=comment/delete/'.$model->id.' class="btn btn-danger btn-xs">'.\Lang::get('lang.delete').'</a> <a href=published/'.$model->id.' class="btn btn-warning btn-xs">'.\Lang::get('lang.publish').'</a>';
|
||||
})
|
||||
->make();
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin can publish the comment
|
||||
* @param type $id
|
||||
* Admin can publish the comment.
|
||||
*
|
||||
* @param type $id
|
||||
* @param type Comment $comment
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function publish($id, Comment $comment) {
|
||||
public function publish($id, Comment $comment)
|
||||
{
|
||||
$comment = $comment->whereId($id)->first();
|
||||
$comment->status = 1;
|
||||
if ($comment->save()) {
|
||||
return redirect('comment')->with('success', $comment->name . '-' . 'Comment Published');
|
||||
return redirect('comment')->with('success', $comment->name.'-'.'Comment Published');
|
||||
} else {
|
||||
return redirect('comment')->with('fails', 'Can not Process');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete the comment
|
||||
* @param type $id
|
||||
* delete the comment.
|
||||
*
|
||||
* @param type $id
|
||||
* @param type Comment $comment
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function delete($id, Comment $comment) {
|
||||
public function delete($id, Comment $comment)
|
||||
{
|
||||
$comment = $comment->whereId($id)->first();
|
||||
if ($comment->delete()) {
|
||||
return redirect('comment')->with('success', $comment->name . "'s!" . 'Comment Deleted');
|
||||
return redirect('comment')->with('success', $comment->name."'s!".'Comment Deleted');
|
||||
} else {
|
||||
return redirect('comment')->with('fails', 'Can not Process');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get profile page
|
||||
* get profile page.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function getProfile() {
|
||||
public function getProfile()
|
||||
{
|
||||
$time = Timezone::all();
|
||||
$user = Auth::user();
|
||||
|
||||
return view('themes.default1.agent.kb.settings.profile', compact('user', 'time'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Post profile page
|
||||
* @param type ProfileRequest $request
|
||||
* Post profile page.
|
||||
*
|
||||
* @param type ProfileRequest $request
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function postProfile(ProfileRequest $request) {
|
||||
public function postProfile(ProfileRequest $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$user->gender = $request->input('gender');
|
||||
$user->save();
|
||||
@@ -233,12 +244,13 @@ class SettingsController extends Controller {
|
||||
//$extension = Input::file('profile_pic')->getClientOriginalExtension();
|
||||
$name = Input::file('profile_pic')->getClientOriginalName();
|
||||
$destinationPath = 'lb-faveo/dist/img';
|
||||
$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()->back()->with('success1', 'Profile Updated sucessfully');
|
||||
}
|
||||
if ($user->fill($request->except('profile_pic'))->save()) {
|
||||
@@ -249,18 +261,22 @@ class SettingsController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* post profile password
|
||||
* @param type $id
|
||||
* @param type ProfilePassword $request
|
||||
* post profile password.
|
||||
*
|
||||
* @param type $id
|
||||
* @param type ProfilePassword $request
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function postProfilePassword($id, ProfilePassword $request) {
|
||||
public function postProfilePassword($id, 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('profile')->with('success2', 'Password Updated sucessfully');
|
||||
} else {
|
||||
return redirect('profile')->with('fails2', 'Old password Wrong');
|
||||
@@ -268,14 +284,15 @@ class SettingsController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* het locale for language
|
||||
* het locale for language.
|
||||
*
|
||||
* @return type config set
|
||||
*/
|
||||
static function language() {
|
||||
public static function language()
|
||||
{
|
||||
// $set = Settings::whereId(1)->first();
|
||||
// $lang = $set->language;
|
||||
Config::set('app.locale', 'en');
|
||||
Config::get('app');
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user