update
This commit is contained in:
parent
95f1cae4e9
commit
014172d525
17 changed files with 67 additions and 78 deletions
|
@ -7,7 +7,7 @@ use App\ApiClient;
|
|||
use App\Events\HostingAccountIsCreated;
|
||||
use App\FileManagerApi;
|
||||
use App\Models\HostingPlan;
|
||||
use App\Models\WebsiteSslCertificate;
|
||||
use App\Models\DomainSslCertificate;
|
||||
use App\Settings;
|
||||
use App\ShellApi;
|
||||
|
||||
|
@ -26,7 +26,7 @@ class HostingAccountIsCreatedListener
|
|||
*/
|
||||
public function handle(HostingAccountIsCreated $event): void
|
||||
{
|
||||
$findWebsite = \App\Models\Website::where('id', $event->model->id)->first();
|
||||
$findWebsite = \App\Models\Domain::where('id', $event->model->id)->first();
|
||||
if (!$findWebsite) {
|
||||
return;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class HostingAccountIsCreatedListener
|
|||
return;
|
||||
}
|
||||
|
||||
$websiteSslCertificate = new WebsiteSslCertificate();
|
||||
$websiteSslCertificate = new DomainSslCertificate();
|
||||
$websiteSslCertificate->domain = $event->model->domain;
|
||||
$websiteSslCertificate->certificate = $validateCertificates['certificate'];
|
||||
$websiteSslCertificate->private_key = $validateCertificates['private_key'];
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Modules\Microweber\App\Models;
|
||||
|
||||
use App\Models\Website;
|
||||
use App\Models\Domain;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Microweber\Database\factories\MicroweberInstallationFactory;
|
||||
|
@ -14,7 +14,7 @@ class MicroweberInstallation extends Model
|
|||
|
||||
public function website()
|
||||
{
|
||||
return $this->hasOne(Website::class, 'id', 'website_id');
|
||||
return $this->hasOne(Domain::class, 'id', 'website_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Modules\Microweber\Filament\Clusters\Microweber\Resources\InstallationResource\Pages;
|
||||
|
||||
use App\Models\Website;
|
||||
use App\Models\Domain;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use MicroweberPackages\SharedServerScripts\MicroweberInstallationsScanner;
|
||||
|
@ -23,7 +23,7 @@ class ListInstallations extends ListRecords
|
|||
|
||||
public function scanForInstallations()
|
||||
{
|
||||
$findWebsites = Website::all();
|
||||
$findWebsites = Domain::all();
|
||||
foreach ($findWebsites as $website) {
|
||||
|
||||
$scan = new MicroweberInstallationsScanner();
|
||||
|
|
|
@ -23,7 +23,7 @@ class HostingAccountIsCreatedListener
|
|||
*/
|
||||
public function handle(HostingAccountIsCreated $event): void
|
||||
{
|
||||
$findWebsite = \App\Models\Website::where('id', $event->model->id)->first();
|
||||
$findWebsite = \App\Models\Domain::where('id', $event->model->id)->first();
|
||||
if (!$findWebsite) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Website;
|
||||
use App\Models\Domain;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ApachePingWebsitesWithCurl extends Command
|
||||
|
@ -42,7 +42,7 @@ class ApachePingWebsitesWithCurl extends Command
|
|||
}
|
||||
|
||||
// Retrieve all website configurations from the database
|
||||
$websiteConfigs = Website::get();
|
||||
$websiteConfigs = Domain::get();
|
||||
|
||||
foreach ($websiteConfigs as $config) {
|
||||
$domain = $config->domain;
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Filament\Resources;
|
|||
|
||||
use App\Filament\Resources\WebsiteResource\Pages;
|
||||
use App\Filament\Resources\WebsiteResource\RelationManagers;
|
||||
use App\Models\Website;
|
||||
use App\Models\Domain;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
|
@ -16,7 +16,7 @@ use Illuminate\Support\Str;
|
|||
|
||||
class WebsiteResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Website::class;
|
||||
protected static ?string $model = Domain::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-globe-europe-africa';
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Models\Website;
|
||||
use App\Models\Domain;
|
||||
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
|
||||
|
@ -21,7 +21,7 @@ class CustomersCount extends BaseWidget
|
|||
|
||||
|
||||
$customersCount = Customer::count();
|
||||
$websiteCount = Website::count();
|
||||
$websiteCount = Domain::count();
|
||||
|
||||
return [
|
||||
// Stat::make('Total Memory', $serverStats['memory']['total']),
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Models\Website;
|
||||
use App\Models\Domain;
|
||||
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\Website;
|
||||
use App\Models\Domain;
|
||||
use Faker\Provider\Text;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
@ -22,7 +22,7 @@ class Websites extends BaseWidget
|
|||
{
|
||||
return $table
|
||||
->query(
|
||||
Website::query()
|
||||
Domain::query()
|
||||
)
|
||||
->actions([
|
||||
Tables\Actions\Action::make('visit')
|
||||
|
|
|
@ -28,7 +28,7 @@ class ModelWebsiteCreatedListener
|
|||
*/
|
||||
public function handle(ModelWebsiteCreated $event): void
|
||||
{
|
||||
$findWebsite = \App\Models\Website::where('id', $event->model->id)->first();
|
||||
$findWebsite = \App\Models\Domain::where('id', $event->model->id)->first();
|
||||
if (!$findWebsite) {
|
||||
return;
|
||||
}
|
||||
|
|
33
web/app/Models/Domain.php
Normal file
33
web/app/Models/Domain.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Actions\ApacheWebsiteCreate;
|
||||
use App\ShellApi;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Domain extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'domain',
|
||||
'domain_root',
|
||||
'ip',
|
||||
'hosting_subscription_id',
|
||||
];
|
||||
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
// static::created(function ($model) {
|
||||
// event(new \App\Events\ModelWebsiteCreated($model));
|
||||
// });
|
||||
//
|
||||
// static::deleting(function ($model) {
|
||||
// event(new \App\Events\ModelWebsiteDeleting($model));
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@ namespace App\Models;
|
|||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class WebsiteSslCertificate extends Model
|
||||
class DomainSslCertificate extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Actions\ApacheWebsiteCreate;
|
||||
use App\ShellApi;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Website extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'domain',
|
||||
'domain_root',
|
||||
'ip',
|
||||
'customer_id',
|
||||
'is_active',
|
||||
'hosting_plan_id',
|
||||
];
|
||||
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::created(function ($model) {
|
||||
event(new \App\Events\ModelWebsiteCreated($model));
|
||||
});
|
||||
|
||||
static::deleting(function ($model) {
|
||||
event(new \App\Events\ModelWebsiteDeleting($model));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function hostingPlan()
|
||||
{
|
||||
return $this->belongsTo(HostingPlan::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->hasOne(Customer::class, 'id', 'customer_id');
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ namespace App\Policies;
|
|||
|
||||
use App\Models\Customer;
|
||||
use App\Models\User;
|
||||
use App\Models\Website;
|
||||
use App\Models\Domain;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
|
||||
class CustomerPolicy
|
||||
|
@ -62,7 +62,7 @@ class CustomerPolicy
|
|||
*/
|
||||
public function forceDelete(User $user, Customer $customer) : bool
|
||||
{
|
||||
$findWebsites = Website::where('customer_id', $customer->id)->count();
|
||||
$findWebsites = Domain::where('customer_id', $customer->id)->count();
|
||||
if ($findWebsites > 0) {
|
||||
Response::deny('Customer has websites, please delete them first.');
|
||||
return false;
|
||||
|
|
|
@ -11,21 +11,19 @@ return new class extends Migration
|
|||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('websites', function (Blueprint $table) {
|
||||
Schema::create('domains', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->string('domain');
|
||||
$table->string('ip')->nullable();
|
||||
|
||||
$table->string('domain_root')->nullable();
|
||||
$table->string('domain_public')->nullable();
|
||||
$table->string('domain_username')->nullable();
|
||||
$table->string('home_root')->nullable();
|
||||
$table->string('screenshot')->nullable();
|
||||
|
||||
$table->integer('customer_id')->nullable();
|
||||
$table->integer('is_active')->nullable();
|
||||
$table->integer('hosting_subscription_id')->nullable();
|
||||
|
||||
$table->string('screenshot')->nullable();
|
||||
$table->integer('is_secure_with_ssl')->nullable();
|
||||
$table->integer('hosting_plan_id')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
|
@ -36,6 +34,6 @@ return new class extends Migration
|
|||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('websites');
|
||||
Schema::dropIfExists('domains');
|
||||
}
|
||||
};
|
|
@ -11,7 +11,7 @@ return new class extends Migration
|
|||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('website_ssl_certificates', function (Blueprint $table) {
|
||||
Schema::create('domain_ssl_certificates', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->string('domain');
|
||||
|
@ -42,6 +42,6 @@ return new class extends Migration
|
|||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('website_ssl_certificates');
|
||||
Schema::dropIfExists('domain_ssl_certificates');
|
||||
}
|
||||
};
|
|
@ -17,9 +17,11 @@ return new class extends Migration
|
|||
$table->bigInteger('customer_id')->nullable();
|
||||
$table->bigInteger('hosting_plan_id')->nullable();
|
||||
|
||||
$table->string('domain')->nullable();
|
||||
$table->string('username')->nullable();
|
||||
$table->string('password')->nullable();
|
||||
$table->string('main_domain_id')->nullable();
|
||||
|
||||
$table->string('system_username')->nullable();
|
||||
$table->string('system_password')->nullable();
|
||||
|
||||
$table->longText('description')->nullable();
|
||||
|
||||
$table->timestamp('setup_date')->nullable();
|
||||
|
|
Loading…
Reference in a new issue