mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 19:51:09 -04:00
add auto update feature
This commit is contained in:
31
app/Listeners/Updates/Listener.php
Normal file
31
app/Listeners/Updates/Listener.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Laraspace\Listeners\Updates;
|
||||
|
||||
class Listener
|
||||
{
|
||||
const ALIAS = '';
|
||||
|
||||
const VERSION = '';
|
||||
|
||||
/**
|
||||
* Check if should listen.
|
||||
*
|
||||
* @param $event
|
||||
* @return boolean
|
||||
*/
|
||||
protected function check($event)
|
||||
{
|
||||
// Apply only to the specified alias
|
||||
if ($event->alias != static::ALIAS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Do not apply to the same or newer versions
|
||||
if (version_compare($event->old, static::VERSION, '>=')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
28
app/Listeners/Updates/V10/Version101.php
Normal file
28
app/Listeners/Updates/V10/Version101.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Laraspace\Listeners\Updates\V10;
|
||||
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Laraspace\Listeners\Updates\Listener;
|
||||
use Laraspace\Events\UpdateFinished;
|
||||
|
||||
class Version101 extends Listener
|
||||
{
|
||||
const ALIAS = 'core';
|
||||
|
||||
const VERSION = '1.0.1';
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param object $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(UpdateFinished $event)
|
||||
{
|
||||
if (!$this->check($event)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user