Merge branch 'auto-update' of https://gitlab.com/mohit.panjvani/crater-web into auto-update

This commit is contained in:
Aman upadhyay
2019-11-15 13:59:26 +05:30
6 changed files with 24 additions and 19 deletions

View File

@@ -306,8 +306,6 @@ class EstimatesController extends Controller
public function sendEstimate(Request $request) public function sendEstimate(Request $request)
{ {
$estimate = Estimate::findOrFail($request->id); $estimate = Estimate::findOrFail($request->id);
$estimate->status = Estimate::STATUS_SENT;
$estimate->save();
$data['estimate'] = $estimate->toArray(); $data['estimate'] = $estimate->toArray();
$userId = $data['estimate']['user_id']; $userId = $data['estimate']['user_id'];
@@ -330,6 +328,11 @@ class EstimatesController extends Controller
]); ]);
} }
if ($estimate->status == Estimate::STATUS_DRAFT) {
$estimate->status = Estimate::STATUS_SENT;
$estimate->save();
}
\Mail::to($email)->send(new EstimatePdf($data, $notificationEmail)); \Mail::to($email)->send(new EstimatePdf($data, $notificationEmail));
return response()->json([ return response()->json([

View File

@@ -371,12 +371,6 @@ class InvoicesController extends Controller
{ {
$invoice = Invoice::findOrFail($request->id); $invoice = Invoice::findOrFail($request->id);
if ($invoice->status == Invoice::STATUS_DRAFT) {
$invoice->status = Invoice::STATUS_SENT;
$invoice->sent = true;
$invoice->save();
}
$data['invoice'] = $invoice->toArray(); $data['invoice'] = $invoice->toArray();
$userId = $data['invoice']['user_id']; $userId = $data['invoice']['user_id'];
$data['user'] = User::find($userId)->toArray(); $data['user'] = User::find($userId)->toArray();
@@ -398,6 +392,12 @@ class InvoicesController extends Controller
]); ]);
} }
if ($invoice->status == Invoice::STATUS_DRAFT) {
$invoice->status = Invoice::STATUS_SENT;
$invoice->sent = true;
$invoice->save();
}
\Mail::to($email)->send(new invoicePdf($data, $notificationEmail)); \Mail::to($email)->send(new invoicePdf($data, $notificationEmail));
return response()->json([ return response()->json([

View File

@@ -12,7 +12,7 @@ class UpdateController extends Controller
{ {
set_time_limit(600); // 10 minutes set_time_limit(600); // 10 minutes
$json = Updater::update($request->installed, $request->version); $json = Updater::update($request->installed, $request->version, $request->isMinor);
return response()->json($json); return response()->json($json);
} }

View File

@@ -15,9 +15,9 @@ class Listener
protected function check($event) protected function check($event)
{ {
// Do not apply to the same or newer versions // Do not apply to the same or newer versions
// if (version_compare($event->old, static::VERSION, '>=')) { if (version_compare($event->old, static::VERSION, '>=')) {
// return false; return false;
// } }
return true; return true;
} }

View File

@@ -21,12 +21,12 @@ class Version101 extends Listener
*/ */
public function handle(UpdateFinished $event) public function handle(UpdateFinished $event)
{ {
// if (!$this->check($event)) { if (!$this->check($event)) {
// return; return;
// } }
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]); Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
Setting::getSetting('version', self::VERSION); Setting::setSetting('version', self::VERSION);
} }
} }

View File

@@ -13,12 +13,12 @@ class Updater
{ {
use SiteApi; use SiteApi;
public static function update($installed, $version) public static function update($installed, $version, $isMinor)
{ {
$data = null; $data = null;
$path = null; $path = null;
$url = '/download/'.$version; $url = '/download/'.$version.'?type=update';
$response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true]); $response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true]);
@@ -78,7 +78,9 @@ class Updater
File::deleteDirectory($temp_path2); File::deleteDirectory($temp_path2);
try { try {
event(new UpdateFinished($installed, $version)); if (!$isMinor) {
event(new UpdateFinished($installed, $version));
}
return [ return [
'success' => true, 'success' => true,