refactor 310 update listener

This commit is contained in:
Mohit Panjwani
2020-05-13 11:12:33 +05:30
parent d4a1f1a784
commit f64d546672
4 changed files with 38 additions and 19 deletions

View File

@ -10,25 +10,17 @@ use Crater\Events\UpdateFinished;
use Crater\Setting; use Crater\Setting;
use Crater\Currency; use Crater\Currency;
use Schema; use Schema;
use Artisan;
class Version310 extends Listener class Version310 extends Listener
{ {
const VERSION = '3.1.0'; const VERSION = '3.1.0';
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/** /**
* Handle the event. * Handle the event.
* *
* @param object $event * @param UpdateFinished $event
* @return void * @return void
*/ */
public function handle(UpdateFinished $event) public function handle(UpdateFinished $event)
@ -52,12 +44,7 @@ class Version310 extends Listener
] ]
); );
if (!Schema::hasColumn('expenses', 'user_id')) { Artisan::call('migrate', ['--force' => true]);
Schema::table('expenses', function (Blueprint $table) {
$table->integer('user_id')->unsigned()->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
// Update Crater app version // Update Crater app version
Setting::setSetting('version', static::VERSION); Setting::setSetting('version', static::VERSION);

View File

@ -14,7 +14,7 @@ class Updater
{ {
use SiteApi; use SiteApi;
public static function update($installed, $version) public static function update($version)
{ {
$data = null; $data = null;
$path = null; $path = null;
@ -26,7 +26,6 @@ class Updater
$url = 'https://craterapp.com/downloads/file/'.$version.'?type=update'; $url = 'https://craterapp.com/downloads/file/'.$version.'?type=update';
} }
$response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true]); $response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true]);
// Exception // Exception

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUserIdToExpensesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('expenses', function (Blueprint $table) {
$table->integer('user_id')->unsigned()->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('expenses', function (Blueprint $table) {
$table->dropColumn('paid');
});
}
}

View File

@ -88,7 +88,7 @@ Route::get('/expenses/{id}/receipt/{hash}', [
'uses' => 'ExpensesController@downloadReceipt' 'uses' => 'ExpensesController@downloadReceipt'
]); ]);
// Setup for instalation of app // Setup for installation of app
// ---------------------------------------------- // ----------------------------------------------
Route::get('/on-boarding', function () { Route::get('/on-boarding', function () {
return view('app'); return view('app');