This commit is contained in:
Bozhidar Slaveykov 2024-04-04 13:46:36 +03:00
parent b848376880
commit d1b7078624
3 changed files with 32 additions and 8 deletions

View file

@ -2,6 +2,7 @@
namespace Modules\Microweber\App\Models;
use App\Models\Website;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Modules\Microweber\Database\factories\MicroweberInstallationFactory;
@ -10,13 +11,10 @@ class MicroweberInstallation extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*/
protected $fillable = [];
protected static function newFactory(): MicroweberInstallationFactory
public function website()
{
//return MicroweberInstallationFactory::new();
return $this->hasOne(Website::class, 'id', 'website_id');
}
}

View file

@ -38,9 +38,16 @@ class InstallationResource extends Resource
public static function table(Table $table): Table
{
return $table
->columns([
//
Tables\Columns\TextColumn::make('website.domain')->label('Domain'),
Tables\Columns\TextColumn::make('app_version')->label('Version'),
Tables\Columns\TextColumn::make('installation_type')->label('Type'),
// Tables\Columns\TextColumn::make('installation_path')->label('Path'),
Tables\Columns\TextColumn::make('template')->label('Template'),
// Tables\Columns\TextColumn::make('admin_email')->label('Admin Email'),
])
->filters([
//

View file

@ -6,6 +6,7 @@ use App\Models\Website;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use MicroweberPackages\SharedServerScripts\MicroweberInstallationsScanner;
use Modules\Microweber\App\Models\MicroweberInstallation;
use Modules\Microweber\Filament\Clusters\Microweber\Resources\InstallationResource;
class ListInstallations extends ListRecords
@ -30,7 +31,25 @@ class ListInstallations extends ListRecords
$installations = $scan->scanRecusrive();
if (!empty($installations)) {
foreach ($installations as $installation) {
dd($installation);
$findInstallation = MicroweberInstallation::where('installation_path', $installation['path'])->first();
if (!$findInstallation) {
$findInstallation = new MicroweberInstallation();
$findInstallation->website_id = $website->id;
$findInstallation->installation_path = $installation['path'];
}
$findInstallation->app_version = $installation['version'];
$findInstallation->template = $installation['app_details']['template'];
if ($installation['is_symlink']) {
$findInstallation->installation_type = 'symlink';
} else {
$findInstallation->installation_type = 'standalone';
}
$findInstallation->save();
}
}
}