Applied fixes from StyleCI
This commit is contained in:

committed by
StyleCI Bot

parent
be5df5334f
commit
d637c2b23f
@@ -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