Skip to content

Commit

Permalink
Plugin show minimum core version
Browse files Browse the repository at this point in the history
  • Loading branch information
Timot Tarjani committed Mar 25, 2024
1 parent 43facb3 commit f174c97
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 3 additions & 5 deletions app/Model/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class Plugin extends Model
use HasImage;
use IsActive;

public $timestamps = false;

protected $fillable = ['id', 'root_dir', 'area', 'permission', 'table_name', 'active'];

private $info = null;
Expand All @@ -33,7 +31,7 @@ public function __construct($root_dir = null)
$eloquent = self::rootDir($root_dir)->first();

if (isset($eloquent)) {
$this->fill($eloquent->attributes);
parent::__construct($eloquent->attributes);
}

isset($this->root_dir) ?: $this->setRootDir($root_dir);
Expand Down Expand Up @@ -199,11 +197,11 @@ public function getRequirements()

public function getRequiredCoreVersion()
{
return isset($this->getInfo('requires')->core) ? $this->getInfo('requires')->core : NULL;
return isset($this->getInfo('requires')->core) ? $this->getInfo('requires')->core : null;
}

public function isCompatibleWithCore()
{
return \Composer\Semver\Comparator::greaterThanOrEqualTo(config('horizontcms.version'), $this->getRequiredCoreVersion());
return \Composer\Semver\Comparator::greaterThanOrEqualTo(ltrim(config('horizontcms.version'), 'v'), ltrim($this->getRequiredCoreVersion(), 'v'));
}
}
10 changes: 8 additions & 2 deletions app/View/plugin/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,21 @@
{{ $current_plugin->getInfo('description') }}
</p>

@if (!$current_plugin->isCompatibleWithCore())
<p class='text-danger m-0 p-0'>
Required core version: {{$current_plugin->getRequiredCoreVersion()}}
</p>
@endif

</div>

<div class='col-md-2 col-sm-4 col-xs-4 text-end'>


@if (!$current_plugin->isInstalled())
@if (!$current_plugin->isInstalled() && $current_plugin->isCompatibleWithCore())
<a id='install' class='btn btn-primary btn-block'
href='{{ config('horizontcms.backend_prefix') }}/plugin/install/{{ $current_plugin->root_dir }}'>Install</a>
@else
@elseif($current_plugin->isInstalled())
@if (!$current_plugin->isActive())
<a class='btn btn-success btn-block'
href='{{ config('horizontcms.backend_prefix') }}/plugin/activate/{{ $current_plugin->root_dir }}'>Activate</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function up()
$table->integer('area')->nullable();
$table->integer('permission')->nullable();
$table->string('tables')->nullable();
$table->timestamps();
$table->integer('active');
});
}
Expand Down

0 comments on commit f174c97

Please sign in to comment.