mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-21 23:20:24 +00:00
update
This commit is contained in:
parent
080c13b8af
commit
17bf284b30
6 changed files with 203 additions and 2 deletions
129
web/Modules/Email/App/Filament/Resources/EmailBoxResource.php
Normal file
129
web/Modules/Email/App/Filament/Resources/EmailBoxResource.php
Normal file
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Email\App\Filament\Resources;
|
||||
|
||||
use App\Models\Domain;
|
||||
use Modules\Email\App\Filament\Resources\EmailBoxResource\Pages;
|
||||
use Modules\Email\App\Filament\Resources\EmailBoxResource\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;
|
||||
use Modules\Email\App\Models\EmailBox;
|
||||
|
||||
class EmailBoxResource extends Resource
|
||||
{
|
||||
protected static ?string $model = EmailBox::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-inbox-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Email';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
|
||||
Forms\Components\TextInput::make('username')
|
||||
->label('Username')
|
||||
->disabled(function ($record) {
|
||||
return $record->exists;
|
||||
})
|
||||
->columnSpanFull(),
|
||||
|
||||
Forms\Components\Select::make('domain')
|
||||
->label('Domain')
|
||||
->options(Domain::get()->pluck('domain', 'domain')->toArray())
|
||||
->columnSpanFull(),
|
||||
|
||||
Forms\Components\TextInput::make('password')
|
||||
->label('Password')
|
||||
->placeholder('Password for POP3/IMAP')
|
||||
->columnSpanFull(),
|
||||
|
||||
Forms\Components\TextInput::make('name')
|
||||
->placeholder('Full Name')
|
||||
->columnSpanFull(),
|
||||
|
||||
//
|
||||
// Forms\Components\TextInput::make('maildir')
|
||||
// ->label('Maildir'),
|
||||
Forms\Components\TextInput::make('quota')
|
||||
->placeholder('MB (max: 10)')
|
||||
->columnSpanFull()
|
||||
->default(10)
|
||||
->label('Quota'),
|
||||
//
|
||||
// Forms\Components\TextInput::make('local_part')
|
||||
// ->label('Local Part'),
|
||||
//
|
||||
|
||||
Forms\Components\TextInput::make('phone')
|
||||
->columnSpanFull()
|
||||
->label('Phone'),
|
||||
|
||||
Forms\Components\Checkbox::make('active')
|
||||
->label('Active')
|
||||
->columnSpanFull(),
|
||||
|
||||
// Forms\Components\TextInput::make('token')
|
||||
// ->label('Token'),
|
||||
// Forms\Components\DateTimePicker::make('token_validity')
|
||||
// ->label('Token Validity'),
|
||||
// Forms\Components\DateTimePicker::make('password_expiry')
|
||||
// ->label('Password Expiry'),
|
||||
|
||||
// Forms\Components\Checkbox::make('smtp_active')
|
||||
// ->label('Smtp Active'),
|
||||
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('email')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('quota')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
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\ListEmailBoxes::route('/'),
|
||||
'create' => Pages\CreateEmailBox::route('/create'),
|
||||
'edit' => Pages\EditEmailBox::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Email\App\Filament\Resources\EmailBoxResource\Pages;
|
||||
|
||||
use Modules\Email\App\Filament\Resources\EmailBoxResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateEmailBox extends CreateRecord
|
||||
{
|
||||
protected static string $resource = EmailBoxResource::class;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Email\App\Filament\Resources\EmailBoxResource\Pages;
|
||||
|
||||
use Modules\Email\App\Filament\Resources\EmailBoxResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditEmailBox extends EditRecord
|
||||
{
|
||||
protected static string $resource = EmailBoxResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Email\App\Filament\Resources\EmailBoxResource\Pages;
|
||||
|
||||
use Modules\Email\App\Filament\Resources\EmailBoxResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListEmailBoxes extends ListRecords
|
||||
{
|
||||
protected static string $resource = EmailBoxResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
|
@ -13,6 +13,28 @@ class EmailBox extends Model
|
|||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [];
|
||||
protected $fillable = [
|
||||
'username',
|
||||
'password',
|
||||
'name',
|
||||
'maildir',
|
||||
'quota',
|
||||
'local_part',
|
||||
'domain',
|
||||
'created',
|
||||
'modified',
|
||||
'active',
|
||||
'phone',
|
||||
'email_other',
|
||||
'token',
|
||||
'token_validity',
|
||||
'password_expiry',
|
||||
'smtp_active',
|
||||
];
|
||||
|
||||
|
||||
public function getEmailAttribute()
|
||||
{
|
||||
return $this->username . '@' . $this->domain;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ return new class extends Migration
|
|||
$table->string('password')->nullable();
|
||||
$table->string('name')->nullable();
|
||||
$table->string('maildir')->nullable();
|
||||
$table->bigInteger('quota')->default(0);
|
||||
$table->bigInteger('quota')->nullable();
|
||||
$table->string('local_part')->nullable();
|
||||
$table->string('domain')->nullable();
|
||||
$table->dateTime('created')->default('2000-01-01 00:00:00');
|
||||
|
|
Loading…
Reference in a new issue