mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-25 17:10:29 +00:00
update
This commit is contained in:
parent
3fc7ea370a
commit
aad913e5bb
6 changed files with 156 additions and 0 deletions
|
@ -138,6 +138,10 @@ class DatabaseResource extends Resource
|
||||||
->label('Database Server')
|
->label('Database Server')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
|
||||||
|
Tables\Columns\TextColumn::make('hostingSubscription.domain')
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
//
|
//
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Customer\App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Models\HostingSubscriptionBackup;
|
||||||
|
use Modules\Customer\App\Filament\Resources\HostingSubscriptionBackupResource\Pages;
|
||||||
|
use Modules\Customer\App\Filament\Resources\HostingSubscriptionBackupResource\RelationManagers;
|
||||||
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
|
||||||
|
class HostingSubscriptionBackupResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = HostingSubscriptionBackup::class;
|
||||||
|
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
|
protected static ?string $label = 'Backups';
|
||||||
|
|
||||||
|
public static function form(Form $form): Form
|
||||||
|
{
|
||||||
|
return $form
|
||||||
|
->schema([
|
||||||
|
//
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
Tables\Columns\TextColumn::make('backup_type')
|
||||||
|
->state(function (HostingSubscriptionBackup $backup) {
|
||||||
|
return ucfirst($backup->backup_type);
|
||||||
|
}),
|
||||||
|
|
||||||
|
Tables\Columns\BadgeColumn::make('status')
|
||||||
|
->badge(),
|
||||||
|
|
||||||
|
Tables\Columns\TextColumn::make('completed_at')
|
||||||
|
->state(function (HostingSubscriptionBackup $backup) {
|
||||||
|
return $backup->completed_at ? $backup->completed_at : 'N/A';
|
||||||
|
}),
|
||||||
|
|
||||||
|
Tables\Columns\TextColumn::make('size')
|
||||||
|
->state(function (HostingSubscriptionBackup $backup) {
|
||||||
|
return $backup->size ? $backup->size : 'N/A';
|
||||||
|
}),
|
||||||
|
|
||||||
|
Tables\Columns\TextColumn::make('hostingSubscription.domain')
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
//
|
||||||
|
])
|
||||||
|
->actions([
|
||||||
|
Tables\Actions\EditAction::make(),
|
||||||
|
])
|
||||||
|
->bulkActions([
|
||||||
|
Tables\Actions\BulkActionGroup::make([
|
||||||
|
Tables\Actions\DeleteBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => Pages\ListHostingSubscriptionBackups::route('/'),
|
||||||
|
'create' => Pages\CreateHostingSubscriptionBackup::route('/create'),
|
||||||
|
'edit' => Pages\EditHostingSubscriptionBackup::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Customer\App\Filament\Resources\HostingSubscriptionBackupResource\Pages;
|
||||||
|
|
||||||
|
use Modules\Customer\App\Filament\Resources\HostingSubscriptionBackupResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
|
||||||
|
class CreateHostingSubscriptionBackup extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = HostingSubscriptionBackupResource::class;
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Customer\App\Filament\Resources\HostingSubscriptionBackupResource\Pages;
|
||||||
|
|
||||||
|
use Modules\Customer\App\Filament\Resources\HostingSubscriptionBackupResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class EditHostingSubscriptionBackup extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = HostingSubscriptionBackupResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\DeleteAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Customer\App\Filament\Resources\HostingSubscriptionBackupResource\Pages;
|
||||||
|
|
||||||
|
use Modules\Customer\App\Filament\Resources\HostingSubscriptionBackupResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListHostingSubscriptionBackups extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = HostingSubscriptionBackupResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ namespace App\Models;
|
||||||
|
|
||||||
use App\Filament\Enums\BackupStatus;
|
use App\Filament\Enums\BackupStatus;
|
||||||
use App\Helpers;
|
use App\Helpers;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
@ -32,6 +33,16 @@ class HostingSubscriptionBackup extends Model
|
||||||
'status' => BackupStatus::class,
|
'status' => BackupStatus::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected static function booted(): void
|
||||||
|
{
|
||||||
|
static::addGlobalScope('customer', function (Builder $query) {
|
||||||
|
if (auth()->check() && auth()->guard()->name == 'web_customer') {
|
||||||
|
$query->whereHas('hostingSubscription', function ($query) {
|
||||||
|
$query->where('customer_id', auth()->user()->id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
public static function boot()
|
public static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
@ -239,4 +250,9 @@ class HostingSubscriptionBackup extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hostingSubscription()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(HostingSubscription::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue