Installer updates
Added probe.php Added new installer views and controllers Updated AuthController Updated Middlewares Updated Commands for installation process
This commit is contained in:
@@ -17,18 +17,18 @@ class BaseModel extends Model
|
||||
{
|
||||
public function setAttribute($property, $value)
|
||||
{
|
||||
require_once base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier.auto.php');
|
||||
$path = base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier'.DIRECTORY_SEPARATOR.'DefinitionCache'.DIRECTORY_SEPARATOR.'Serializer');
|
||||
if (!File::exists($path)) {
|
||||
File::makeDirectory($path, $mode = 0777, true, true);
|
||||
}
|
||||
$config = \HTMLPurifier_Config::createDefault();
|
||||
$config->set('HTML.Trusted', true);
|
||||
$config->set('Filter.YouTube', true);
|
||||
$purifier = new \HTMLPurifier($config);
|
||||
if ($value != strip_tags($value)) {
|
||||
$value = $purifier->purify($value);
|
||||
}
|
||||
// require_once base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier.auto.php');
|
||||
// $path = base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier'.DIRECTORY_SEPARATOR.'DefinitionCache'.DIRECTORY_SEPARATOR.'Serializer');
|
||||
// if (!File::exists($path)) {
|
||||
// File::makeDirectory($path, $mode = 0777, true, true);
|
||||
// }
|
||||
// $config = \HTMLPurifier_Config::createDefault();
|
||||
// $config->set('HTML.Trusted', true);
|
||||
// $config->set('Filter.YouTube', true);
|
||||
// $purifier = new \HTMLPurifier($config);
|
||||
// if ($value != strip_tags($value)) {
|
||||
// $value = $purifier->purify($value);
|
||||
// }
|
||||
parent::setAttribute($property, $value);
|
||||
}
|
||||
}
|
||||
|
56
app/Console/Commands/DropTables.php
Normal file
56
app/Console/Commands/DropTables.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class DropTables extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'droptables';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Drops all tables';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$colname = 'Tables_in_'.env('DB_DATABASE');
|
||||
|
||||
$droplist = \Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
|
||||
$droplist = implode(',', $droplist);
|
||||
|
||||
DB::beginTransaction();
|
||||
//turn off referential integrity
|
||||
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
|
||||
DB::statement("DROP TABLE $droplist");
|
||||
//turn referential integrity back on
|
||||
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
|
||||
DB::commit();
|
||||
|
||||
$this->comment(PHP_EOL.'If no errors showed up, all tables were dropped'.PHP_EOL);
|
||||
}
|
||||
}
|
103
app/Console/Commands/Install.php
Normal file
103
app/Console/Commands/Install.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Http\Controllers\Installer\helpdesk\InstallController;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class Install extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'install:faveo';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'to install faveo';
|
||||
protected $install;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->install = new InstallController();
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$this->appEnv();
|
||||
if ($this->confirm('Do you want to intall faveo?')) {
|
||||
$default = $this->choice(
|
||||
'Which sql engine would you like to use?', ['mysql']
|
||||
);
|
||||
$host = $this->ask('Enter your sql host');
|
||||
$database = $this->ask('Enter your database name');
|
||||
$dbusername = $this->ask('Enter your database username');
|
||||
$dbpassword = $this->ask('Enter your database password (blank if not entered)', false);
|
||||
$port = $this->ask('Enter your sql port (blank if not entered)', false);
|
||||
$this->install->env($default, $host, $port, $database, $dbusername, $dbpassword);
|
||||
$this->info('.env file has created');
|
||||
$this->call('preinsatall:check');
|
||||
$this->alert("please run 'php artisan install:db'");
|
||||
} else {
|
||||
$this->info('We hope, you will try next time');
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function appEnv()
|
||||
{
|
||||
$extensions = [
|
||||
'curl',
|
||||
'ctype',
|
||||
'imap',
|
||||
'mbstring',
|
||||
'mcrypt',
|
||||
'mysql',
|
||||
'openssl',
|
||||
'tokenizer',
|
||||
'zip',
|
||||
'pdo',
|
||||
'mysqli',
|
||||
'bcmath',
|
||||
'iconv',
|
||||
//'ioncube_loader_dar_5.6',
|
||||
];
|
||||
$result = [];
|
||||
foreach ($extensions as $key => $extension) {
|
||||
$result[$key]['extension'] = $extension;
|
||||
if (!extension_loaded($extension)) {
|
||||
$result[$key]['status'] = "Not Loading, Please open '".php_ini_loaded_file()."' and add 'extension = ".$extension;
|
||||
} else {
|
||||
$result[$key]['status'] = 'Loading';
|
||||
}
|
||||
}
|
||||
$result['php']['extension'] = 'PHP';
|
||||
if (phpversion() === 7.0) {
|
||||
$result['php']['status'] = 'PHP version supports';
|
||||
} else {
|
||||
$result['php']['status'] = "PHP version doesn't supports please upgrade to 7.0";
|
||||
}
|
||||
|
||||
$headers = ['Extension', 'Status'];
|
||||
$this->table($headers, $result);
|
||||
}
|
||||
}
|
89
app/Console/Commands/InstallDB.php
Normal file
89
app/Console/Commands/InstallDB.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Http\Controllers\Installer\helpdesk\InstallController;
|
||||
use DB;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class InstallDB extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'install:db';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'installing database';
|
||||
protected $install;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->install = new InstallController();
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
if ($this->confirm('Do you want to migrate tables now?')) {
|
||||
$env = base_path().DIRECTORY_SEPARATOR.'.env';
|
||||
if (!is_file($env)) {
|
||||
throw new \Exception("Please run 'php artisan install:faveo'");
|
||||
}
|
||||
$dummy_confirm = $this->confirm('Would you like to install dummy data in database to test before going live?');
|
||||
$this->call('key:generate', ['--force' => true]);
|
||||
if (!$dummy_confirm) {
|
||||
$this->call('install:migrate');
|
||||
$this->call('install:seed');
|
||||
} else {
|
||||
$path = base_path().'/DB/dummy-data.sql';
|
||||
DB::unprepared(file_get_contents($path));
|
||||
}
|
||||
$headers = ['user_name', 'email', 'password'];
|
||||
$data = [
|
||||
[
|
||||
'user_name' => 'demo_admin',
|
||||
'email' => '',
|
||||
'password' => 'demopass',
|
||||
],
|
||||
];
|
||||
$this->table($headers, $data);
|
||||
$this->warn('Please update your email and change the password immediately');
|
||||
$this->install->updateInstalEnv();
|
||||
$this->updateAppUrl();
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function updateAppUrl()
|
||||
{
|
||||
$url = $this->ask('Enter your app url (with http/https and www/non www)');
|
||||
if (str_finish($url, '/')) {
|
||||
$url = rtrim($url, '/ ');
|
||||
}
|
||||
$systems = new \App\Model\helpdesk\Settings\System();
|
||||
$system = $systems->first();
|
||||
$system->url = $url;
|
||||
$system->save();
|
||||
$this->info('Thank you! Faveo has been installed successfully');
|
||||
}
|
||||
}
|
47
app/Console/Commands/UpdateEncryption.php
Normal file
47
app/Console/Commands/UpdateEncryption.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class UpdateEncryption extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'encryption';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'This update the encryption value from old to AES-256-CBC';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$emails = \App\Model\helpdesk\Email\Emails::get();
|
||||
|
||||
foreach ($emails as $email) {
|
||||
$email->password = encrypt('password');
|
||||
$email->save();
|
||||
}
|
||||
}
|
||||
}
|
@@ -18,6 +18,10 @@ class Kernel extends ConsoleKernel
|
||||
'App\Console\Commands\SendReport',
|
||||
'App\Console\Commands\CloseWork',
|
||||
'App\Console\Commands\TicketFetch',
|
||||
'App\Console\Commands\UpdateEncryption',
|
||||
\App\Console\Commands\DropTables::class,
|
||||
\App\Console\Commands\Install::class,
|
||||
\App\Console\Commands\InstallDB::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -33,9 +37,11 @@ class Kernel extends ConsoleKernel
|
||||
if ($this->getCurrentQueue() != 'sync') {
|
||||
$schedule->command('queue:listen '.$this->getCurrentQueue().' --sleep 60')->everyMinute();
|
||||
}
|
||||
|
||||
$this->execute($schedule, 'fetching');
|
||||
$this->execute($schedule, 'notification');
|
||||
$this->execute($schedule, 'work');
|
||||
$schedule->command('sla-escalate')->everyThirtyMinutes();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,4 +120,14 @@ class Kernel extends ConsoleKernel
|
||||
|
||||
return $queue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the Closure based commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
|
@@ -43,6 +43,7 @@ class Handler extends ExceptionHandler
|
||||
*/
|
||||
public function report(Exception $e)
|
||||
{
|
||||
dd($e);
|
||||
$debug = \Config::get('app.bugsnag_reporting');
|
||||
$debug = ($debug) ? 'true' : 'false';
|
||||
if ($debug == 'false') {
|
||||
|
@@ -22,7 +22,7 @@ use Auth;
|
||||
use DateTime;
|
||||
use DB;
|
||||
use Hash;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Lang;
|
||||
use Socialite;
|
||||
|
||||
@@ -38,7 +38,6 @@ use Socialite;
|
||||
*/
|
||||
class AuthController extends Controller
|
||||
{
|
||||
use AuthenticatesAndRegistersUsers;
|
||||
/* to redirect after login */
|
||||
|
||||
// if auth is agent
|
||||
@@ -644,4 +643,27 @@ class AuthController extends Controller
|
||||
\Session::set($provider.'redirect', $url);
|
||||
$this->changeRedirect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the user out of the application.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function getLogout(Request $request)
|
||||
{
|
||||
\Event::fire('user.logout', []);
|
||||
$login = new LoginController();
|
||||
|
||||
return $login->logout($request);
|
||||
}
|
||||
|
||||
public function redirectPath()
|
||||
{
|
||||
$auth = Auth::user();
|
||||
if ($auth && $auth->role != 'user') {
|
||||
return 'dashboard';
|
||||
} else {
|
||||
return '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,11 +5,9 @@ namespace App\Http\Controllers\Installer\helpdesk;
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\DatabaseRequest;
|
||||
use App\Http\Requests\helpdesk\InstallerRequest;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
// models
|
||||
use App\Model\helpdesk\Utility\Date_time_format;
|
||||
use App\Model\helpdesk\Utility\Timezones;
|
||||
use App\User;
|
||||
use Artisan;
|
||||
@@ -46,15 +44,10 @@ class InstallController extends Controller
|
||||
*/
|
||||
public function licence()
|
||||
{
|
||||
// checking if the installation is running for the first time or not
|
||||
$directory = base_path();
|
||||
if (file_exists($directory.DIRECTORY_SEPARATOR.'.env')) {
|
||||
return redirect('/auth/login');
|
||||
if (Cache::get('step1') == 'step1') {
|
||||
return View::make('themes/default1/installer/helpdesk/view1');
|
||||
} else {
|
||||
Cache::flush();
|
||||
Artisan::call('config:clear');
|
||||
|
||||
return view('themes/default1/installer/helpdesk/view1');
|
||||
return Redirect::route('prerequisites');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,11 +59,10 @@ class InstallController extends Controller
|
||||
public function licencecheck(Request $request)
|
||||
{
|
||||
// checking if the user have accepted the licence agreement
|
||||
$accept = (Input::has('accept1')) ? true : false;
|
||||
if ($accept == 'accept') {
|
||||
Cache::forever('step1', 'step1');
|
||||
if (Input::has('acceptme')) {
|
||||
Cache::forever('step2', 'step2');
|
||||
|
||||
return Redirect::route('prerequisites');
|
||||
return Redirect::route('configuration');
|
||||
} else {
|
||||
return Redirect::route('licence')->with('fails', 'Failed! first accept the licence agreeement');
|
||||
}
|
||||
@@ -87,10 +79,14 @@ class InstallController extends Controller
|
||||
public function prerequisites(Request $request)
|
||||
{
|
||||
// checking if the installation is running for the first time or not
|
||||
if (Cache::get('step1') == 'step1') {
|
||||
return View::make('themes/default1/installer/helpdesk/view2');
|
||||
$directory = base_path();
|
||||
if (file_exists($directory.DIRECTORY_SEPARATOR.'.env')) {
|
||||
return redirect('/auth/login');
|
||||
} else {
|
||||
return Redirect::route('licence');
|
||||
Cache::flush();
|
||||
Artisan::call('config:clear');
|
||||
|
||||
return view('themes/default1/installer/helpdesk/view2');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,9 +98,9 @@ class InstallController extends Controller
|
||||
*/
|
||||
public function prerequisitescheck(Request $request)
|
||||
{
|
||||
Cache::forever('step2', 'step2');
|
||||
Cache::forever('step1', 'step1');
|
||||
|
||||
return Redirect::route('configuration');
|
||||
return Redirect::route('licence');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,69 +160,25 @@ class InstallController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function configurationcheck(DatabaseRequest $request)
|
||||
public function configurationcheck(Request $request)
|
||||
{
|
||||
Cache::forever('step4', 'step4');
|
||||
|
||||
Session::set('default', $request->input('default'));
|
||||
Session::set('host', $request->input('host'));
|
||||
Session::set('databasename', $request->input('databasename'));
|
||||
Session::set('username', $request->input('username'));
|
||||
Session::set('password', $request->input('password'));
|
||||
Session::set('port', $request->input('port'));
|
||||
Session::put('default', $request->input('default'));
|
||||
Session::put('host', $request->input('host'));
|
||||
Session::put('databasename', $request->input('databasename'));
|
||||
Session::put('username', $request->input('username'));
|
||||
Session::put('password', $request->input('password'));
|
||||
Session::put('port', $request->input('port'));
|
||||
Cache::forever('dummy_data_installation', false);
|
||||
if ($request->has('dummy-data')) {
|
||||
Cache::forget('dummy_data_installation');
|
||||
Cache::forever('dummy_data_installation', true);
|
||||
}
|
||||
|
||||
return Redirect::route('database');
|
||||
}
|
||||
|
||||
/**
|
||||
* postconnection.
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function postconnection(Request $request)
|
||||
{
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
$default = Input::get('default');
|
||||
$host = Input::get('host');
|
||||
$database = Input::get('databasename');
|
||||
$dbusername = Input::get('username');
|
||||
$dbpassword = Input::get('password');
|
||||
$port = Input::get('port');
|
||||
|
||||
$ENV['APP_ENV'] = 'production';
|
||||
$ENV['APP_DEBUG'] = 'false';
|
||||
$ENV['APP_KEY'] = 'SomeRandomString';
|
||||
$ENV['APP_BUGSNAG'] = 'true';
|
||||
$ENV['APP_URL'] = 'http://localhost';
|
||||
$ENV['DB_INSTALL'] = '%0%';
|
||||
$ENV['DB_TYPE'] = $default;
|
||||
$ENV['DB_HOST'] = $host;
|
||||
$ENV['DB_PORT'] = $port;
|
||||
$ENV['DB_DATABASE'] = $database;
|
||||
$ENV['DB_USERNAME'] = $dbusername;
|
||||
$ENV['DB_PASSWORD'] = $dbpassword;
|
||||
$ENV['MAIL_DRIVER'] = 'smtp';
|
||||
$ENV['MAIL_HOST'] = 'mailtrap.io';
|
||||
$ENV['MAIL_PORT'] = '2525';
|
||||
$ENV['MAIL_USERNAME'] = 'null';
|
||||
$ENV['MAIL_PASSWORD'] = 'null';
|
||||
$ENV['CACHE_DRIVER'] = 'file';
|
||||
$ENV['SESSION_DRIVER'] = 'file';
|
||||
$ENV['QUEUE_DRIVER'] = 'sync';
|
||||
|
||||
$config = '';
|
||||
foreach ($ENV as $key => $val) {
|
||||
$config .= "{$key}={$val}\n";
|
||||
}
|
||||
// Write environment file
|
||||
$fp = fopen(base_path().DIRECTORY_SEPARATOR.'example.env', 'w');
|
||||
fwrite($fp, $config);
|
||||
fclose($fp);
|
||||
rename(base_path().DIRECTORY_SEPARATOR.'example.env', base_path().DIRECTORY_SEPARATOR.'.env');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get database
|
||||
* checking prerequisites.
|
||||
@@ -269,28 +221,24 @@ class InstallController extends Controller
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function accountcheck(InstallerRequest $request)
|
||||
public function accountcheck(Request $request)
|
||||
{
|
||||
// checking is the installation was done previously
|
||||
try {
|
||||
$check_for_pre_installation = System::all();
|
||||
if ($check_for_pre_installation) {
|
||||
rename(base_path().DIRECTORY_SEPARATOR.'.env', base_path().DIRECTORY_SEPARATOR.'example.env');
|
||||
Cache::put('fails', 'The data in database already exist. Please provide fresh database', 2);
|
||||
$validator = \Validator::make($request->all(), [
|
||||
'firstname' => 'required|max:20',
|
||||
'Lastname' => 'required|max:20',
|
||||
'email' => 'required|max:50|email',
|
||||
'username' => 'required|max:50|min:3',
|
||||
'password' => 'required|min:6',
|
||||
'confirmpassword' => 'required|same:password',
|
||||
]);
|
||||
|
||||
return redirect()->route('configuration');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
if ($validator->fails()) {
|
||||
return redirect('step5')
|
||||
->withErrors($validator)
|
||||
->withInput();
|
||||
}
|
||||
if ($request->input('dummy-data') == 'on') {
|
||||
$path = base_path().'/DB/dummy-data.sql';
|
||||
DB::unprepared(file_get_contents($path));
|
||||
} else {
|
||||
// migrate database
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
Artisan::call('db:seed', ['--force' => true]);
|
||||
}
|
||||
// create user
|
||||
// checking is the installation was done previously
|
||||
// Set variables fetched from input request
|
||||
$firstname = $request->input('firstname');
|
||||
$lastname = $request->input('Lastname');
|
||||
$email = $request->input('email');
|
||||
@@ -301,46 +249,49 @@ class InstallController extends Controller
|
||||
$timezone = $request->input('timezone');
|
||||
$date = $request->input('date');
|
||||
$datetime = $request->input('datetime');
|
||||
$lang_path = base_path('resources/lang');
|
||||
|
||||
//check user input language package is available or not in the system
|
||||
if (array_key_exists($language, \Config::get('languages')) && in_array($language, scandir($lang_path))) {
|
||||
// do something here
|
||||
} else {
|
||||
return \Redirect::back()->with('fails', 'Invalid language');
|
||||
}
|
||||
|
||||
$changed = UnAuth::changeLanguage($language);
|
||||
if (!$changed) {
|
||||
return \Redirect::back()->with('fails', 'Invalid language');
|
||||
}
|
||||
// checking requested timezone for the admin and system
|
||||
$timezones = Timezones::where('name', '=', $timezone)->first();
|
||||
if ($timezones == null) {
|
||||
return redirect()->back()->with('fails', 'Invalid time-zone');
|
||||
}
|
||||
|
||||
// checking requested date time format for the admin and system
|
||||
$date_time_format = Date_time_format::where('format', '=', $datetime)->first();
|
||||
if ($date_time_format == null) {
|
||||
return redirect()->back()->with('fails', 'invalid date-time format');
|
||||
}
|
||||
|
||||
// Creating minum settings for system
|
||||
$system = new System();
|
||||
$system = System::where('id', '=', 1)->first();
|
||||
$system->status = 1;
|
||||
$system->department = 1;
|
||||
$system->date_time_format = $date_time_format->id;
|
||||
$system->time_zone = $timezones->id;
|
||||
$version = \Config::get('app.version');
|
||||
$version = explode(' ', $version);
|
||||
$version = $version[1];
|
||||
$system->date_time_format = $datetime; //$date_time_format->id;
|
||||
$system->time_zone = $timezone; //$timezones->id;
|
||||
$version = \Config::get('app.tags');
|
||||
// $version = explode(' ', $version);
|
||||
// $version = $version[1];
|
||||
$system->version = $version;
|
||||
$system->save();
|
||||
|
||||
$admin_tzone = 14;
|
||||
$tzone = Timezones::select('id')->where('name', '=', $timezone)->first();
|
||||
if ($tzone) {
|
||||
$admin_tzone = $tzone->id;
|
||||
}
|
||||
// creating an user
|
||||
$user = User::create([
|
||||
$user = User::updateOrCreate(['id' => 1], [
|
||||
'first_name' => $firstname,
|
||||
'last_name' => $lastname,
|
||||
'email' => $email,
|
||||
'user_name' => $username,
|
||||
'password' => Hash::make($password),
|
||||
'assign_group' => 1,
|
||||
//'assign_group' => 1,
|
||||
'primary_dpt' => 1,
|
||||
'active' => 1,
|
||||
'role' => 'admin',
|
||||
]);
|
||||
|
||||
// checking if the user have been created
|
||||
if ($user) {
|
||||
Cache::forever('step6', 'step6');
|
||||
@@ -359,34 +310,20 @@ class InstallController extends Controller
|
||||
{
|
||||
// checking if the installation have been completed or not
|
||||
if (Cache::get('step6') == 'step6') {
|
||||
$value = '1';
|
||||
$install = base_path().DIRECTORY_SEPARATOR.'.env';
|
||||
$datacontent = File::get($install);
|
||||
$datacontent = str_replace('%0%', $value, $datacontent);
|
||||
File::put($install, $datacontent);
|
||||
// setting email settings in route
|
||||
$smtpfilepath = "\App\Http\Controllers\Common\SettingsController::smtp()";
|
||||
|
||||
$link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
|
||||
$pos = strpos($link, 'final');
|
||||
$link = substr($link, 0, $pos);
|
||||
$app_url = base_path().DIRECTORY_SEPARATOR.'.env';
|
||||
$datacontent2 = File::get($app_url);
|
||||
$datacontent2 = str_replace('http://localhost', $link, $datacontent2);
|
||||
File::put($app_url, $datacontent2);
|
||||
$language = Cache::get('language');
|
||||
|
||||
try {
|
||||
Cache::flush();
|
||||
|
||||
Artisan::call('key:generate');
|
||||
\Cache::flush();
|
||||
\Cache::forever('language', $language);
|
||||
$this->updateInstalEnv();
|
||||
|
||||
return View::make('themes/default1/installer/helpdesk/view6');
|
||||
} catch (Exception $e) {
|
||||
return Redirect::route('account')->with('fails', $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
$this->updateInstalEnv();
|
||||
|
||||
return redirect('/auth/login');
|
||||
}
|
||||
}
|
||||
@@ -400,9 +337,11 @@ class InstallController extends Controller
|
||||
public function finalcheck()
|
||||
{
|
||||
try {
|
||||
$this->updateInstalEnv();
|
||||
|
||||
return redirect('/auth/login');
|
||||
} catch (Exception $e) {
|
||||
return redirect('/auth/login');
|
||||
return redirect('/auth/login')->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,10 +353,16 @@ class InstallController extends Controller
|
||||
if ($f1 >= '644') {
|
||||
return Redirect::back();
|
||||
} else {
|
||||
return Redirect::back()->with('fail_to_change', 'We are unable to change file permission on your server please try to change permission manually.');
|
||||
return Redirect::back()->with(
|
||||
'fail_to_change',
|
||||
'We are unable to change file permission on your server please try to change permission manually.'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Redirect::back()->with('fail_to_change', 'We are unable to change file permission on your server please try to change permission manually.');
|
||||
return Redirect::back()->with(
|
||||
'fail_to_change',
|
||||
'We are unable to change file permission on your server please try to change permission manually.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,4 +370,198 @@ class InstallController extends Controller
|
||||
{
|
||||
return view('themes/default1/installer/helpdesk/check-js')->with('url', 'step1');
|
||||
}
|
||||
|
||||
public function createEnv($api = true)
|
||||
{
|
||||
try {
|
||||
if (Input::get('default')) {
|
||||
$default = Input::get('default');
|
||||
} else {
|
||||
$default = Session::get('default');
|
||||
}
|
||||
if (Input::get('host')) {
|
||||
$host = Input::get('host');
|
||||
} else {
|
||||
$host = Session::get('host');
|
||||
}
|
||||
if (Input::get('databasename')) {
|
||||
$database = Input::get('databasename');
|
||||
} else {
|
||||
$database = Session::get('databasename');
|
||||
}
|
||||
if (Input::get('username')) {
|
||||
$dbusername = Input::get('username');
|
||||
} else {
|
||||
$dbusername = Session::get('username');
|
||||
}
|
||||
if (Input::get('password')) {
|
||||
$dbpassword = Input::get('password');
|
||||
} else {
|
||||
$dbpassword = Session::get('password');
|
||||
}
|
||||
if (Input::get('port')) {
|
||||
$port = Input::get('port');
|
||||
} else {
|
||||
$port = Session::get('port');
|
||||
}
|
||||
$this->env($default, $host, $port, $database, $dbusername, $dbpassword);
|
||||
} catch (Exception $ex) {
|
||||
$result = ['error' => $ex->getMessage()];
|
||||
|
||||
return response()->json(compact('result'), 500);
|
||||
}
|
||||
if ($api) {
|
||||
$url = url('preinstall/check');
|
||||
$result = ['success' => 'Environment configuration file has been created successfully', 'next' => 'Running pre migration test', 'api' => $url];
|
||||
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
}
|
||||
|
||||
public function env($default, $host, $port, $database, $dbusername, $dbpassword)
|
||||
{
|
||||
$ENV['APP_DEBUG'] = 'false';
|
||||
$ENV['APP_BUGSNAG'] = 'true';
|
||||
$ENV['APP_URL'] = url('/');
|
||||
$ENV['DB_TYPE'] = $default;
|
||||
$ENV['DB_HOST'] = '"'.$host.'"';
|
||||
$ENV['DB_PORT'] = '"'.$port.'"';
|
||||
$ENV['DB_DATABASE'] = '"'.$database.'"';
|
||||
$ENV['DB_USERNAME'] = '"'.$dbusername.'"';
|
||||
$ENV['DB_PASSWORD'] = '"'.$dbpassword.'"';
|
||||
$ENV['MAIL_DRIVER'] = 'smtp';
|
||||
$ENV['MAIL_HOST'] = 'mailtrap.io';
|
||||
$ENV['MAIL_PORT'] = '2525';
|
||||
$ENV['MAIL_USERNAME'] = 'null';
|
||||
$ENV['MAIL_PASSWORD'] = 'null';
|
||||
$ENV['CACHE_DRIVER'] = 'file';
|
||||
$ENV['SESSION_DRIVER'] = 'file';
|
||||
$ENV['SESSION_COOKIE_NAME'] = 'faveo_'.rand(0, 10000);
|
||||
$ENV['QUEUE_DRIVER'] = 'sync';
|
||||
|
||||
$ENV['FCM_SERVER_KEY'] = 'AIzaSyCyx5OFnsRFUmDLTMbPV50ZMDUGSG-bLw4';
|
||||
$ENV['FCM_SENDER_ID'] = '661051343223';
|
||||
$ENV['REDIS_DATABASE'] = '0';
|
||||
|
||||
$config = '';
|
||||
foreach ($ENV as $key => $val) {
|
||||
$config .= "{$key}={$val}\n";
|
||||
}
|
||||
if (is_file(base_path().DIRECTORY_SEPARATOR.'.env')) {
|
||||
unlink(base_path().DIRECTORY_SEPARATOR.'.env');
|
||||
}
|
||||
if (!is_file(base_path().DIRECTORY_SEPARATOR.'example.env')) {
|
||||
fopen(base_path().DIRECTORY_SEPARATOR.'example.env', 'w');
|
||||
}
|
||||
|
||||
// Write environment file
|
||||
$fp = fopen(base_path().DIRECTORY_SEPARATOR.'example.env', 'w');
|
||||
fwrite($fp, $config);
|
||||
fclose($fp);
|
||||
rename(base_path().DIRECTORY_SEPARATOR.'example.env', base_path().DIRECTORY_SEPARATOR.'.env');
|
||||
}
|
||||
|
||||
public function checkPreInstall()
|
||||
{
|
||||
try {
|
||||
$check_for_pre_installation = System::select('id')->first();
|
||||
if ($check_for_pre_installation) {
|
||||
throw new Exception('This database already has tables and data. Please provide fresh database', 100);
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
if ($ex->getCode() == 100) {
|
||||
Artisan::call('droptables');
|
||||
$this->createEnv(false);
|
||||
}
|
||||
}
|
||||
Artisan::call('key:generate', ['--force' => true]);
|
||||
|
||||
$url = url('migrate');
|
||||
$result = ['success' => 'Pre migration test has run successfully', 'next' => 'Migrating tables in database', 'api' => $url];
|
||||
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
|
||||
public function migrate()
|
||||
{
|
||||
$db_install_method = '';
|
||||
|
||||
try {
|
||||
$tableNames = \Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
|
||||
if (count($tableNames) === 0) {
|
||||
if (!Cache::get('dummy_data_installation')) {
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
$db_install_method = 'migrate';
|
||||
} else {
|
||||
$path = base_path().DIRECTORY_SEPARATOR.'DB'.DIRECTORY_SEPARATOR.'dummy-data.sql';
|
||||
DB::unprepared(file_get_contents($path));
|
||||
$db_install_method = 'dump';
|
||||
}
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
$this->rollBackMigration();
|
||||
$result = ['error' => $ex->getMessage()];
|
||||
|
||||
return response()->json(compact('result'), 500);
|
||||
}
|
||||
$url = ($db_install_method == 'migrate') ? url('seed') : '';
|
||||
$message = ($db_install_method == 'migrate') ? 'Tables have been migrated successfully in database.' : 'Database has been setup successfully.';
|
||||
$result = ['success' => $message, 'next' => 'Seeding pre configurations data', 'api' => $url];
|
||||
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
|
||||
public function rollBackMigration()
|
||||
{
|
||||
try {
|
||||
Artisan::call('migrate:reset', ['--force' => true]);
|
||||
} catch (Exception $ex) {
|
||||
$result = ['error' => $ex->getMessage()];
|
||||
|
||||
return response()->json(compact('result'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function seed(Request $request)
|
||||
{
|
||||
try {
|
||||
if ($request->input('dummy-data') == 'on') {
|
||||
$path = base_path().'/DB/dummy-data.sql';
|
||||
DB::unprepared(DB::raw(file_get_contents($path)));
|
||||
} else {
|
||||
\Schema::disableForeignKeyConstraints();
|
||||
$tableNames = \Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
|
||||
foreach ($tableNames as $name) {
|
||||
//if you don't want to truncate migrations
|
||||
if ($name == 'migrations') {
|
||||
continue;
|
||||
}
|
||||
DB::table($name)->truncate();
|
||||
}
|
||||
Artisan::call('db:seed', ['--force' => true]);
|
||||
}
|
||||
//$this->updateInstalEnv();
|
||||
} catch (Exception $ex) {
|
||||
$result = ['error' => $ex->getMessage()];
|
||||
|
||||
return response()->json(compact('result'), 500);
|
||||
}
|
||||
$result = ['success' => 'Database has been setup successfully.'];
|
||||
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
|
||||
public function updateInstalEnv()
|
||||
{
|
||||
$env = base_path().DIRECTORY_SEPARATOR.'.env';
|
||||
if (is_file($env)) {
|
||||
$txt = 'DB_INSTALL=1';
|
||||
$txt1 = 'APP_ENV=development';
|
||||
file_put_contents($env, $txt.PHP_EOL, FILE_APPEND | LOCK_EX);
|
||||
file_put_contents($env, $txt1, FILE_APPEND | LOCK_EX);
|
||||
} else {
|
||||
throw new Exception('.env not found');
|
||||
}
|
||||
Artisan::call('jwt:secret');
|
||||
}
|
||||
}
|
||||
|
@@ -34,9 +34,11 @@ class Kernel extends HttpKernel
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\App\Http\Middleware\LanguageMiddleware::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
'api' => [
|
||||
'throttle:60,1',
|
||||
'bindings',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -46,19 +48,23 @@ class Kernel extends HttpKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'roles' => \App\Http\Middleware\CheckRole::class,
|
||||
'role.agent' => \App\Http\Middleware\CheckRoleAgent::class,
|
||||
'role.user' => \App\Http\Middleware\CheckRoleUser::class,
|
||||
'api' => \App\Http\Middleware\ApiKey::class,
|
||||
'jwt.auth' => \Tymon\JWTAuth\Middleware\GetUserFromToken::class,
|
||||
'jwt.refresh' => \Tymon\JWTAuth\Middleware\RefreshToken::class,
|
||||
'update' => \App\Http\Middleware\CheckUpdate::class,
|
||||
'board' => \App\Http\Middleware\CheckBoard::class,
|
||||
'install' => \App\Http\Middleware\Install::class,
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'roles' => \App\Http\Middleware\CheckRole::class,
|
||||
'role.agent' => \App\Http\Middleware\CheckRoleAgent::class,
|
||||
'role.user' => \App\Http\Middleware\CheckRoleUser::class,
|
||||
'api' => \App\Http\Middleware\ApiKey::class,
|
||||
'jwt.auth' => \Tymon\JWTAuth\Middleware\GetUserFromToken::class,
|
||||
'jwt.refresh' => \Tymon\JWTAuth\Middleware\RefreshToken::class,
|
||||
'update' => \App\Http\Middleware\CheckUpdate::class,
|
||||
'board' => \App\Http\Middleware\CheckBoard::class,
|
||||
'install' => \App\Http\Middleware\Install::class,
|
||||
'redirect' => \App\Http\Middleware\Redirect::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
'installer' => \App\Http\Middleware\IsInstalled::class,
|
||||
'force.option' => \App\Http\Middleware\TicketViewURL::class,
|
||||
];
|
||||
}
|
||||
|
@@ -25,6 +25,6 @@ class CheckRoleAgent
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
return redirect('dashboard')->with('fails', 'You are not Authorised');
|
||||
return redirect('dashboard')->with('fails', 'You are not Autherised');
|
||||
}
|
||||
}
|
||||
|
32
app/Http/Middleware/IsInstalled.php
Normal file
32
app/Http/Middleware/IsInstalled.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class IsInstalled
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (!isInstall()) {
|
||||
return $next($request);
|
||||
} else {
|
||||
if ($request->isJson()) {
|
||||
$url = url('/');
|
||||
$result = ['fails' => 'already installed', 'api' => $url];
|
||||
|
||||
return response()->json(compact('result'));
|
||||
} else {
|
||||
return redirect('/');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,20 +4,44 @@ namespace App\Http\Middleware;
|
||||
|
||||
use Cache;
|
||||
use Closure;
|
||||
// use Illuminate\Contracts\Routing\Middleware;
|
||||
use Illuminate\Support\Facades\App;
|
||||
// use Illuminate\Contracts\Routing\Middleware;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Session;
|
||||
|
||||
class LanguageMiddleware
|
||||
{
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (Cache::has('language') and array_key_exists(Cache::get('language'), Config::get('languages'))) {
|
||||
App::setLocale(Cache::get('language'));
|
||||
$lang = '';
|
||||
if (\Auth::check()) {
|
||||
if (\Auth::user()->user_language != null) {
|
||||
$lang = \Auth::user()->user_language;
|
||||
} else {
|
||||
$lang = $this->getLangFromSessionOrCache();
|
||||
}
|
||||
} else {
|
||||
$lang = $this->getLangFromSessionOrCache();
|
||||
}
|
||||
|
||||
if ($lang != '' and array_key_exists($lang, Config::get('languages'))) {
|
||||
App::setLocale($lang);
|
||||
} else { // This is optional as Laravel will automatically set the fallback language if there is none specified
|
||||
App::setLocale(Config::get('app.fallback_locale'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
public function getLangFromSessionOrCache()
|
||||
{
|
||||
$lang = '';
|
||||
if (Session::has('language')) {
|
||||
$lang = Session::get('language');
|
||||
} elseif (Cache::has('language')) {
|
||||
$lang = Cache::get('language');
|
||||
}
|
||||
|
||||
return $lang;
|
||||
}
|
||||
}
|
||||
|
49
app/Http/Middleware/Redirect.php
Normal file
49
app/Http/Middleware/Redirect.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class Redirect
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$root = $request->root(); //http://localhost/faveo/Faveo-Helpdesk-Pro-fork/public
|
||||
$url = $this->setAppUrl($request);
|
||||
if ($url == $root) {
|
||||
return $next($request);
|
||||
}
|
||||
$seg = '';
|
||||
$segments = $request->segments();
|
||||
if (count($segments) > 0) {
|
||||
foreach ($segments as $segment) {
|
||||
$seg .= '/'.$segment;
|
||||
}
|
||||
}
|
||||
$url = $url.$seg;
|
||||
|
||||
return redirect($url);
|
||||
}
|
||||
|
||||
public function setAppUrl($request)
|
||||
{
|
||||
$url = $request->root();
|
||||
if (isInstall()) {
|
||||
$schema = new \App\Model\helpdesk\Settings\CommonSettings();
|
||||
$row = $schema->getOptionValue('url', 'app_url', true);
|
||||
if ($row) {
|
||||
$url = $row->option_value;
|
||||
}
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
47
app/Http/Middleware/TicketViewURL.php
Normal file
47
app/Http/Middleware/TicketViewURL.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Input;
|
||||
|
||||
//use Redirect;
|
||||
|
||||
class TicketViewURL
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
// dd(\Input::all(), $request->fullUrl());
|
||||
$request_str = $request->fullUrl();
|
||||
if (preg_match('([^D]=)', $request_str) == 1) {
|
||||
$request_str = str_replace('=', '%5B%5D=', $request_str);
|
||||
$request_str = str_replace('%5B%5D%5B%5D=', '%5B%5D=', $request_str);
|
||||
}
|
||||
if (count(Input::all()) == 0) {
|
||||
return \Redirect::to('tickets?show%5B%5D=inbox&departments%5B%5D=All');
|
||||
} else {
|
||||
if (!array_key_exists('show', Input::all()) && !array_key_exists('departments', Input::all())) {
|
||||
return \Redirect::to($request_str.'&show%5B%5D=inbox&departments%5B%5D=All');
|
||||
} elseif (!array_key_exists('show', Input::all()) && array_key_exists('departments', Input::all())) {
|
||||
return \Redirect::to($request_str.'&show%5B%5D=inbox');
|
||||
} elseif (array_key_exists('show', Input::all()) && !array_key_exists('departments', Input::all())) {
|
||||
return \Redirect::to($request_str.'&departments%5B%5D=All');
|
||||
} else {
|
||||
// do nothing
|
||||
}
|
||||
if (preg_match('([^D]=)', $request->fullUrl()) == 1) {
|
||||
return \Redirect::to($request_str);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
}
|
@@ -13,8 +13,11 @@ class VerifyCsrfToken extends BaseVerifier
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'CheckSerial',
|
||||
'api/v1/*',
|
||||
'chunk/upload',
|
||||
'chunk/upload/public',
|
||||
'media/files/public',
|
||||
'media/files',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@@ -3,7 +3,6 @@
|
||||
namespace App\Http\ViewComposers;
|
||||
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\User;
|
||||
@@ -21,7 +20,6 @@ class AgentLayout
|
||||
protected $users;
|
||||
protected $tickets;
|
||||
protected $department;
|
||||
protected $emails;
|
||||
|
||||
/**
|
||||
* Create a new profile composer.
|
||||
@@ -30,14 +28,13 @@ class AgentLayout
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Company $company, User $users, Tickets $tickets, Department $department, Emails $emails)
|
||||
public function __construct(Company $company, User $users, Tickets $tickets, Department $department)
|
||||
{
|
||||
$this->company = $company;
|
||||
$this->auth = Auth::user();
|
||||
$this->users = $users;
|
||||
$this->tickets = $tickets;
|
||||
$this->department = $department;
|
||||
$this->emails = $emails;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,19 +48,16 @@ class AgentLayout
|
||||
{
|
||||
$notifications = \App\Http\Controllers\Common\NotificationController::getNotifications();
|
||||
$view->with([
|
||||
'company' => $this->company,
|
||||
'notifications' => $notifications,
|
||||
'myticket' => $this->myTicket(),
|
||||
'unassigned' => $this->unassigned(),
|
||||
'followup_ticket' => $this->followupTicket(),
|
||||
'deleted' => $this->deleted(),
|
||||
'closed' => $this->closed(),
|
||||
'tickets' => $this->inbox(),
|
||||
'department' => $this->departments(),
|
||||
'overdues' => $this->overdues(),
|
||||
'due_today' => $this->getDueToday(),
|
||||
'is_mail_conigured' => $this->getEmailConfig(),
|
||||
'ticket_policy' => new \App\Policies\TicketPolicy(),
|
||||
'company' => $this->company,
|
||||
'notifications' => $notifications,
|
||||
'myticket' => $this->myTicket(),
|
||||
'unassigned' => $this->unassigned(),
|
||||
'followup_ticket' => $this->followupTicket(),
|
||||
'deleted' => $this->deleted(),
|
||||
'tickets' => $this->inbox(),
|
||||
'department' => $this->departments(),
|
||||
'overdues' => $this->overdues(),
|
||||
'due_today' => $this->getDueToday(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -104,10 +98,10 @@ class AgentLayout
|
||||
$ticket = $this->tickets();
|
||||
if ($this->auth->role == 'admin') {
|
||||
return $ticket->where('assigned_to', $this->auth->id)
|
||||
->where('status', '1');
|
||||
->where('status', '1');
|
||||
} elseif ($this->auth->role == 'agent') {
|
||||
return $ticket->where('assigned_to', $this->auth->id)
|
||||
->where('status', '1');
|
||||
->where('status', '1');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,13 +110,13 @@ class AgentLayout
|
||||
$ticket = $this->tickets();
|
||||
if ($this->auth->role == 'admin') {
|
||||
return $ticket->where('assigned_to', '=', null)
|
||||
->where('status', '=', '1')
|
||||
->select('id');
|
||||
->where('status', '=', '1')
|
||||
->select('id');
|
||||
} elseif ($this->auth->role == 'agent') {
|
||||
return $ticket->where('assigned_to', '=', null)
|
||||
->where('status', '=', '1')
|
||||
->where('dept_id', '=', $this->auth->primary_dpt)
|
||||
->select('id');
|
||||
->where('status', '=', '1')
|
||||
->where('dept_id', '=', $this->auth->primary_dpt)
|
||||
->select('id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +137,7 @@ class AgentLayout
|
||||
return $ticket->where('status', '5')->select('id');
|
||||
} elseif ($this->auth->role == 'agent') {
|
||||
return $ticket->where('status', '5')->where('dept_id', '=', $this->auth->primary_dpt)
|
||||
->select('id');
|
||||
->select('id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +151,7 @@ class AgentLayout
|
||||
|
||||
return $table->Join('ticket_status', function ($join) {
|
||||
$join->on('ticket_status.id', '=', 'tickets.status')
|
||||
->whereIn('ticket_status.id', [1, 7]);
|
||||
->whereIn('ticket_status.id', [1, 7]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -200,45 +194,4 @@ class AgentLayout
|
||||
->whereRaw('date(duedate) = ?', [date('Y-m-d')]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @category function to fetch closed tickets count
|
||||
*
|
||||
* @param null
|
||||
*
|
||||
* @return builder
|
||||
*/
|
||||
public function closed()
|
||||
{
|
||||
$table = $this->tickets();
|
||||
if (Auth::user()->role == 'agent') {
|
||||
$id = Auth::user()->id;
|
||||
$dept = DepartmentAssignAgents::where('agent_id', '=', $id)->pluck('department_id')->toArray();
|
||||
$table = $table->whereIn('tickets.dept_id', $dept)->orWhere('assigned_to', '=', Auth::user()->id);
|
||||
|
||||
// $id = Auth::user()->primary_dpt;
|
||||
// $table = $table->where('tickets.dept_id', '=', $id)->orWhere('assigned_to', '=', Auth::user()->id);
|
||||
}
|
||||
|
||||
return $table->where('status', 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @category function to check configured mails
|
||||
*
|
||||
* @param null
|
||||
*
|
||||
* @var $emails
|
||||
*
|
||||
* @return bool true/false
|
||||
*/
|
||||
public function getEmailConfig()
|
||||
{
|
||||
$emails = $this->emails->where('sending_status', '=', 1)->where('fetching_status', '=', 1)->count();
|
||||
if ($emails >= 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ class AuthUser
|
||||
'auth_name' => $this->user->name(),
|
||||
'auth_user_active' => $this->user->active,
|
||||
'auth_user_primary_dept'=> $this->user->primary_dept,
|
||||
'auth_user_assign_group'=> '', //$this->user->assign_group,
|
||||
'auth_user_assign_group'=> $this->user->assign_group,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user