auto-update
This commit is contained in:
34
app/Console/Commands/Sync.php
Normal file
34
app/Console/Commands/Sync.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Http\Controllers\Update\SyncFaveoToLatestVersion;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class Sync extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'database:sync';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Migration and Database seeder';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
(new SyncFaveoToLatestVersion())->sync();
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Installer\helpdesk;
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// requests
|
||||
use App\Http\Controllers\Update\SyncFaveoToLatestVersion;
|
||||
use App\Http\Requests\helpdesk\InstallerRequest;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
// models
|
||||
@@ -435,6 +436,7 @@ class InstallController extends Controller
|
||||
$ENV['DB_DATABASE'] = '"'.$database.'"';
|
||||
$ENV['DB_USERNAME'] = '"'.$dbusername.'"';
|
||||
$ENV['DB_PASSWORD'] = '"'.$dbpassword.'"';
|
||||
$ENV['DB_ENGINE'] = 'InnoDB';
|
||||
$ENV['MAIL_MAILER'] = 'smtp';
|
||||
$ENV['MAIL_HOST'] = 'mailtrap.io';
|
||||
$ENV['MAIL_PORT'] = '2525';
|
||||
@@ -490,29 +492,23 @@ class InstallController extends Controller
|
||||
|
||||
public function migrate()
|
||||
{
|
||||
$db_install_method = '';
|
||||
|
||||
try {
|
||||
$tableNames = \Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
|
||||
$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 {
|
||||
(new SyncFaveoToLatestVersion())->sync();
|
||||
if (Cache::get('dummy_data_installation')) {
|
||||
$path = base_path().DIRECTORY_SEPARATOR.'DB'.DIRECTORY_SEPARATOR.'dummy-data.sql';
|
||||
DB::unprepared(file_get_contents($path));
|
||||
$db_install_method = 'dump';
|
||||
}
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
dd($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];
|
||||
$result = ['success' => 'Database has been setup successfully.'];
|
||||
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
|
64
app/Http/Controllers/Update/SyncFaveoToLatestVersion.php
Normal file
64
app/Http/Controllers/Update/SyncFaveoToLatestVersion.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Update;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SyncFaveoToLatestVersion extends Controller
|
||||
{
|
||||
public function sync()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
ini_set('max_execution_time', '-1');
|
||||
set_time_limit(0);
|
||||
|
||||
$latestVersion = $this->getPhpComaptibleVersion(Config::get('app.version'));
|
||||
$olderVersion = $this->getOlderVersion();
|
||||
|
||||
if (version_compare($latestVersion, $olderVersion) == 1) {
|
||||
$this->updateToLatestVersion($olderVersion);
|
||||
}
|
||||
System::first()->update(['version' => Config::get('app.version')]);
|
||||
}
|
||||
|
||||
private function updateToLatestVersion($olderVersion)
|
||||
{
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
|
||||
$seederPath = base_path('database'.DIRECTORY_SEPARATOR.'seeders');
|
||||
|
||||
if(file_exists($seederPath)){
|
||||
$seederVersions = scandir($seederPath);
|
||||
|
||||
natsort($seederVersions);
|
||||
$formattedOlderVersion = $olderVersion;
|
||||
foreach ($seederVersions as $version) {
|
||||
if(version_compare($this->getPhpComaptibleVersion($version), $formattedOlderVersion) == 1){
|
||||
Artisan::call('db:seed',['--class' => "Database\Seeders\\$version\DatabaseSeeder", '--force' => true]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getOlderVersion()
|
||||
{
|
||||
if (!isInstall()) {
|
||||
return '0.0.0';
|
||||
}
|
||||
|
||||
$version = System::value('version') ?: '0.0.0';
|
||||
return $this->getPhpComaptibleVersion($version);
|
||||
}
|
||||
|
||||
private function getPhpComaptibleVersion($version)
|
||||
{
|
||||
return preg_replace('#v\.|v#', '', str_replace('_', '.', $version));
|
||||
}
|
||||
}
|
@@ -13,6 +13,6 @@ class System extends BaseModel
|
||||
protected $fillable = [
|
||||
|
||||
'id', 'status', 'url', 'name', 'department', 'page_size', 'log_level', 'purge_log', 'name_format',
|
||||
'time_farmat', 'date_format', 'date_time_format', 'day_date_time', 'time_zone', 'content', 'api_key', 'api_enable', 'api_key_mandatory',
|
||||
'time_farmat', 'date_format', 'date_time_format', 'day_date_time', 'time_zone', 'content', 'api_key', 'api_enable', 'api_key_mandatory', 'version'
|
||||
];
|
||||
}
|
||||
|
@@ -2,8 +2,10 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Model\helpdesk\Settings\System;
|
||||
use App\Model\Update\BarNotification;
|
||||
use Illuminate\Queue\Events\JobFailed;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Laravel\Dusk\DuskServiceProvider;
|
||||
|
@@ -35,7 +35,7 @@ return [
|
||||
| This tells about aplication current version.
|
||||
|
|
||||
*/
|
||||
'version' => 'Community 1.11.1',
|
||||
'version' => parse_ini_file(storage_path('faveoconfig.ini'), false, INI_SCANNER_RAW)['APP_VERSION'],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
@@ -44,7 +44,7 @@ return [
|
||||
| This Applocation name is used for installation and update checking
|
||||
|
|
||||
*/
|
||||
'name' => 'Faveo Helpdesk Community',
|
||||
'name' => parse_ini_file(storage_path('faveoconfig.ini'), false, INI_SCANNER_RAW)['APP_NAME'],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application URL
|
||||
|
@@ -11,7 +11,7 @@ return new class() extends Migration {
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('date_time_format', function (Blueprint $table) {
|
||||
\Illuminate\Support\Facades\Schema::create('date_time_format', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('format');
|
||||
});
|
||||
|
@@ -10,12 +10,8 @@ return new class() extends Migration {
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$current_version1 = \Config::get('app.version');
|
||||
$current_version2 = explode(' ', $current_version1);
|
||||
$current_version = $current_version2[1];
|
||||
$settings_system = DB::table('settings_system')->where('id', '=', '1')->first();
|
||||
if ($settings_system != null) {
|
||||
DB::table('settings_system')->insert(['version' => $current_version]);
|
||||
DB::table('common_settings')
|
||||
->insert(
|
||||
['option_name' => 'enable_rtl', 'option_value' => ''],
|
||||
|
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AlterColumnTypeSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->modifyStringType(Schema::getAllTables());
|
||||
}
|
||||
|
||||
private function modifyStringType($tables)
|
||||
{
|
||||
foreach ($tables as $table) {
|
||||
$tableName = (array)$table;
|
||||
$tableName = reset($tableName);
|
||||
|
||||
$columns = Schema::getColumnListing($tableName);
|
||||
|
||||
foreach ($columns as $column) {
|
||||
if (Schema::getColumnType($tableName, $column) == 'string') {
|
||||
Schema::table($tableName, function ($table) use($column) {
|
||||
$table->string($column)->nullable()->change();
|
||||
});
|
||||
} elseif (Schema::getColumnType($tableName, $column) == 'boolean') {
|
||||
Schema::table($tableName, function ($table) use($column) {
|
||||
$table->boolean($column)->default(0)->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\v_2_0_0;
|
||||
|
||||
use App\Model\Common\Template;
|
||||
use App\Model\Common\TemplateSet;
|
||||
@@ -37,6 +37,7 @@ use App\Model\helpdesk\Workflow\WorkflowClose;
|
||||
use App\Model\kb\Settings;
|
||||
// Knowledge base
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
@@ -47,8 +48,26 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$tables = Schema::getAllTables();
|
||||
|
||||
(new AlterColumnTypeSeeder())->run();
|
||||
foreach ($tables as $table) {
|
||||
$tableName = (array)$table;
|
||||
$tableName = reset($tableName);
|
||||
|
||||
$columns = Schema::getColumnListing($tableName);
|
||||
|
||||
foreach ($columns as $column) {
|
||||
if (Schema::getColumnType($tableName, $column) == 'string') {
|
||||
Schema::table($tableName, function ($table) use($column) {
|
||||
$table->string($column)->nullable()->change();
|
||||
});
|
||||
} elseif (Schema::getColumnType($tableName, $column) == 'boolean') {
|
||||
Schema::table($tableName, function ($table) use($column) {
|
||||
$table->boolean($column)->default(0)->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Date time format */
|
||||
$date_time_formats = [
|
||||
'd/m/Y H:i:s',
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\v_2_0_0;
|
||||
|
||||
use App\Model\MailJob\MailService;
|
||||
use App\Model\MailJob\QueueService;
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\v_2_0_0;
|
||||
|
||||
use App\Model\helpdesk\Ticket\Ticket_source;
|
||||
use Illuminate\Database\Seeder;
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\v_2_0_0;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Database\Seeder;
|
@@ -32,7 +32,7 @@ class="nav-link active"
|
||||
<!-- content -->
|
||||
@section('content')
|
||||
<!-- open a form -->
|
||||
{!! Form::open(['action'=>'Agent\helpdesk\OrganizationController@store','method'=>'post']) !!}
|
||||
{!! Form::open(['route' => 'organizations.store','method'=>'post']) !!}
|
||||
|
||||
@if(Session::has('errors'))
|
||||
<?php //dd($errors); ?>
|
||||
|
@@ -41,12 +41,24 @@ foreach($segments as $seg){
|
||||
},
|
||||
"aaSorting": sort,
|
||||
"columnDefs": [
|
||||
{ "searchable": false, "targets": [6,7] },
|
||||
{"defaultContent": "-",
|
||||
"targets": "_all"},
|
||||
{ "searchable": true, "targets": [6,7] },
|
||||
{ "visible": last, "targets": 6 },
|
||||
{"visible": create, "targets":7},
|
||||
],
|
||||
"columns":[
|
||||
{data: "check_box"},
|
||||
{data: "ticket_number"},
|
||||
{data: "ticket_number"},
|
||||
{data: "ticket_number"},
|
||||
{data: "ticket_number"},
|
||||
{data: "ticket_number"},
|
||||
{data: "ticket_number"},
|
||||
{data: "ticket_number"},
|
||||
],
|
||||
"fnCreatedRow": function (nRow, aData, iDataIndex) {
|
||||
var str = aData[3];
|
||||
var str = aData['ticket_number'];
|
||||
if (str.search("#000") == -1) {
|
||||
$("td", nRow).css({"background-color": "#F3F3F3", "font-weight": "600", "border-bottom": "solid 0.5px #ddd", "border-right": "solid 0.5px #F3F3F3"});
|
||||
$("td", nRow).mouseenter(function () {
|
||||
|
2
storage/faveoconfig.ini
Normal file
2
storage/faveoconfig.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
APP_NAME=Faveo Helpdesk Community
|
||||
APP_VERSION=v2.0.0
|
Reference in New Issue
Block a user