update v1.0.5
This commit is contained in:
@@ -1,38 +1,59 @@
|
||||
<?php namespace App\Http\Controllers\Agent\kb;
|
||||
|
||||
// Controllers
|
||||
use App\Http\Controllers\Agent\kb\ArticleController;
|
||||
use 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\DateFormat;
|
||||
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
|
||||
use Auth;
|
||||
use Config;
|
||||
use Datatable;
|
||||
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
|
||||
*
|
||||
* @package Controllers
|
||||
* @subpackage Controller
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class SettingsController extends Controller {
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return Response
|
||||
* Create a new controller instance.
|
||||
* constructor to check
|
||||
* 1. authentication
|
||||
* 2. user roles
|
||||
* 3. roles must be agent
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
// checking authentication
|
||||
$this->middleware('auth');
|
||||
// checking roles
|
||||
$this->middleware('roles');
|
||||
$this->language();
|
||||
}
|
||||
@@ -42,8 +63,7 @@ class SettingsController extends Controller {
|
||||
* @return response
|
||||
* @package default
|
||||
*/
|
||||
public function settings(Settings $settings, Timezones $time, DateFormat $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();
|
||||
@@ -62,19 +82,14 @@ class SettingsController extends Controller {
|
||||
{
|
||||
/* 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;
|
||||
//echo $fileName;
|
||||
|
||||
Input::file('logo')->move($destinationPath, $fileName);
|
||||
|
||||
$settings->logo = $fileName;
|
||||
//$thDestinationPath = 'dist/th';
|
||||
|
||||
Image::make($destinationPath . '/' . $fileName, array(
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
@@ -83,28 +98,21 @@ class SettingsController extends Controller {
|
||||
}
|
||||
if (Input::file('background')) {
|
||||
$name = Input::file('background')->getClientOriginalName();
|
||||
|
||||
$destinationPath = 'lb-faveo/dist/image';
|
||||
$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,
|
||||
'grayscale' => false,
|
||||
))->save('lb-faveo/dist/image/' . $fileName);
|
||||
}
|
||||
|
||||
/* Check whether function success or not */
|
||||
|
||||
if ($settings->fill($request->except('logo', 'background'))->save() == true) {
|
||||
/* redirect to Index page with Success Message */
|
||||
|
||||
return redirect('settings')->with('success', 'Settings Updated Successfully');
|
||||
} else {
|
||||
/* redirect to Index page with Fails Message */
|
||||
@@ -117,49 +125,6 @@ class SettingsController extends Controller {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* to get the faq view page
|
||||
* @return response
|
||||
*/
|
||||
public function Faq(Faq $faq) {
|
||||
/* fetch the values of faq */
|
||||
$faq = $faq->whereId('1')->first();
|
||||
return view('themes.default1.agent.settings.faq', compact('faq'));
|
||||
|
||||
}
|
||||
public function postfaq($id, Faq $faq, Request $request) {
|
||||
$faq = $faq->whereId('1')->first();
|
||||
if ($faq->fill($request->input())->save()) {
|
||||
return redirect('create-faq')->with('success', 'Faq updated Successfully');
|
||||
} else {
|
||||
return redirect('craete-faq')->with('fails', 'Faq not updated');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the create page to insert the values to database
|
||||
* @return type response
|
||||
*/
|
||||
public function CreateSocialLink(Social $social) {
|
||||
$social = $social->whereId('1')->first();
|
||||
return view('themes.default1.agent.kb.settings.social', compact('social'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type Social $social
|
||||
* @param type Request $request
|
||||
* @return type resonse
|
||||
*/
|
||||
public function PostSocial(Social $social, SocialRequest $request) {
|
||||
$social = $social->whereId('1')->first();
|
||||
if ($social->fill($request->input())->save()) {
|
||||
return redirect('social')->with('success', 'Your Social Links Stored');
|
||||
} else {
|
||||
return redirect('social')->with('fails', 'Sorry Can not Performe');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To Moderate the commenting
|
||||
* @param type Comment $comment
|
||||
@@ -237,56 +202,61 @@ class SettingsController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get profile page
|
||||
* @return type view
|
||||
*/
|
||||
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
|
||||
* @return type redirect
|
||||
*/
|
||||
public function postProfile(ProfileRequest $request) {
|
||||
$user = Auth::user();
|
||||
$user->gender = $request->input('gender');
|
||||
$user->save();
|
||||
|
||||
if (is_null($user->profile_pic)) {
|
||||
if ($request->input('gender') == 1) {
|
||||
|
||||
$name = 'avatar5.png';
|
||||
$destinationPath = 'lb-faveo/dist/img';
|
||||
$user->profile_pic = $name;
|
||||
} elseif ($request->input('gender') == 0) {
|
||||
|
||||
$name = 'avatar2.png';
|
||||
$destinationPath = 'lb-faveo/dist/img';
|
||||
$user->profile_pic = $name;
|
||||
}
|
||||
}
|
||||
|
||||
if (Input::file('profile_pic')) {
|
||||
//$extension = Input::file('profile_pic')->getClientOriginalExtension();
|
||||
$name = Input::file('profile_pic')->getClientOriginalName();
|
||||
|
||||
$destinationPath = 'lb-faveo/dist/img';
|
||||
$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()) {
|
||||
return redirect('profile')->with('success1', 'Profile Updated sucessfully');
|
||||
} else {
|
||||
return redirect('profile')->with('fails1', 'Profile Not Updated sucessfully');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* post profile password
|
||||
* @param type $id
|
||||
* @param type ProfilePassword $request
|
||||
* @return type redirect
|
||||
*/
|
||||
public function postProfilePassword($id, ProfilePassword $request) {
|
||||
$user = Auth::user();
|
||||
//echo $user->password;
|
||||
@@ -299,81 +269,12 @@ class SettingsController extends Controller {
|
||||
return redirect('profile')->with('fails2', 'Old password Wrong');
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* To delete the logo
|
||||
* @param type $id
|
||||
* @param type Settings $setting
|
||||
* @return type
|
||||
*/
|
||||
public function deleteLogo($id, Settings $setting) {
|
||||
$setting = $setting->whereId($id)->first();
|
||||
$setting->logo = '';
|
||||
$setting->save();
|
||||
return redirect('settings')->with('success', 'Settings Updated Successfully');
|
||||
|
||||
}
|
||||
|
||||
public function deleteBackground($id, Settings $setting) {
|
||||
$setting = $setting->whereId($id)->first();
|
||||
$setting->background = '';
|
||||
$setting->save();
|
||||
return redirect('settings')->with('success', 'Settings Updated Successfully');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the View of create Side widget page
|
||||
* @param type Side1 $side
|
||||
* @return View
|
||||
* het locale for language
|
||||
* @return type config set
|
||||
*/
|
||||
public function side1(Side1 $side) {
|
||||
$side = $side->where('id', '1')->first();
|
||||
return view('themes.default1.agent.kb.settings.side1', compact('side'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Post function of Side1 Page
|
||||
* @param type $id
|
||||
* @param type Side1 $side
|
||||
* @param type Request $request
|
||||
* @return view
|
||||
*/
|
||||
public function postside1($id, Side1 $side, Request $request) {
|
||||
$side = $side->whereId($id)->first();
|
||||
if ($side->fill($request->input())->save()) {
|
||||
return redirect('side1')->with('success', 'Side Widget 1 Created !');
|
||||
} else {
|
||||
return redirect('side1')->with('fails', 'Whoops ! Something went Wrong ! ');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the View for side widget creat
|
||||
* @param type Side2 $side
|
||||
* @return type
|
||||
*/
|
||||
public function side2(Side2 $side) {
|
||||
$side = $side->where('id', '1')->first();
|
||||
return view('themes.default1.agent.kb.settings.side2', compact('side'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Post functio for side
|
||||
* @param type $id
|
||||
* @param type Side2 $side
|
||||
* @param type Request $request
|
||||
* @return response
|
||||
*/
|
||||
public function postside2($id, Side2 $side, Request $request) {
|
||||
$side = $side->whereId($id)->first();
|
||||
if ($side->fill($request->input())->save()) {
|
||||
return redirect('side2')->with('success', 'Side Widget 2 Created !');
|
||||
} else {
|
||||
return redirect('side2')->with('fails', 'Whoops ! Something went Wrong ! ');
|
||||
}
|
||||
}
|
||||
|
||||
static function language() {
|
||||
// $set = Settings::whereId(1)->first();
|
||||
// $lang = $set->language;
|
||||
|
Reference in New Issue
Block a user