mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-21 23:20:24 +00:00
update
This commit is contained in:
parent
830ee55ddd
commit
720859064c
2 changed files with 32 additions and 5 deletions
|
@ -11,11 +11,14 @@ use Filament\Forms\Components\TextInput;
|
|||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Support\Enums\MaxWidth;
|
||||
use Filament\Tables\Actions\Action;
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Actions\HeaderActionsPosition;
|
||||
use Filament\Tables\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
|
@ -94,11 +97,16 @@ class FileManager extends Page implements HasForms, HasTable
|
|||
->actions([
|
||||
|
||||
ActionGroup::make([
|
||||
// ViewAction::make('open')
|
||||
// ->label('Open')
|
||||
// ->hidden(fn (FileItem $record): bool => ! $record->canOpen())
|
||||
// ->url(fn (FileItem $record): string => $storage->url($record->path))
|
||||
// ->openUrlInNewTab(),
|
||||
EditAction::make('edit')
|
||||
->label('Edit')
|
||||
->hidden(fn (FileItem $record): bool => ! $record->canOpen())
|
||||
->form([
|
||||
Textarea::make('content')
|
||||
->label('Content')
|
||||
->rows(30)
|
||||
,
|
||||
]),
|
||||
|
||||
Action::make('download')
|
||||
->label('Download')
|
||||
->icon('heroicon-o-document-arrow-down')
|
||||
|
|
|
@ -22,8 +22,24 @@ class FileItem extends Model
|
|||
'dateModified' => 'datetime',
|
||||
'size' => 'integer',
|
||||
'type' => 'string',
|
||||
'content' => 'string',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'content',
|
||||
];
|
||||
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::updating(function ($model) {
|
||||
if (!empty($model->content)) {
|
||||
$model->storageInstance()->put($model->path, $model->content);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static function queryForDiskAndPath(string $rootPath = 'public', string $path = ''): Builder
|
||||
{
|
||||
static::$rootPath = $rootPath;
|
||||
|
@ -76,6 +92,7 @@ class FileItem extends Model
|
|||
|
||||
$backPath = [
|
||||
[
|
||||
'content' => null,
|
||||
'name' => '..',
|
||||
'dateModified' => null,
|
||||
'size' => null,
|
||||
|
@ -96,6 +113,7 @@ class FileItem extends Model
|
|||
'size' => null,
|
||||
'type' => 'Folder',
|
||||
'path' => $directory,
|
||||
'content' => null,
|
||||
]),
|
||||
...collect($storage->files(static::$path))
|
||||
->sort()
|
||||
|
@ -105,6 +123,7 @@ class FileItem extends Model
|
|||
'size' => $storage->size($file),
|
||||
'type' => $storage->mimeType($file) ?: 'File',
|
||||
'path' => $file,
|
||||
'content' => $storage->exists($file) ? $storage->get($file) : null,
|
||||
])
|
||||
)->toArray();
|
||||
|
||||
|
|
Loading…
Reference in a new issue