the RunwareAI Plugin is working now
This commit is contained in:
@@ -35,12 +35,16 @@ class AiModelResource extends Resource
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('model_type')
|
||||
->label(__('filament.resource.ai_model.form.model_type'))
|
||||
->nullable()
|
||||
->maxLength(255),
|
||||
Forms\Components\Toggle::make('enabled')
|
||||
->label(__('filament.resource.ai_model.form.enabled'))
|
||||
->default(true),
|
||||
Select::make('apiProviders')
|
||||
->relationship('apiProviders', 'name')
|
||||
->multiple()
|
||||
->preload()
|
||||
->searchable(false)
|
||||
->label(__('filament.resource.ai_model.form.api_providers')),
|
||||
]);
|
||||
}
|
||||
@@ -52,6 +56,9 @@ class AiModelResource extends Resource
|
||||
TextColumn::make('name')->label(__('filament.resource.ai_model.table.name'))->searchable()->sortable(),
|
||||
TextColumn::make('model_id')->label(__('filament.resource.ai_model.table.model_id'))->searchable()->sortable(),
|
||||
TextColumn::make('model_type')->label(__('filament.resource.ai_model.table.model_type'))->searchable()->sortable(),
|
||||
Tables\Columns\IconColumn::make('enabled')
|
||||
->label(__('filament.resource.ai_model.table.enabled'))
|
||||
->boolean(),
|
||||
TextColumn::make('apiProviders.name')->label(__('filament.resource.ai_model.table.api_providers'))->searchable()->sortable(),
|
||||
])
|
||||
->filters([
|
||||
|
||||
67
app/Filament/Resources/SettingResource.php
Normal file
67
app/Filament/Resources/SettingResource.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\SettingResource\Pages;
|
||||
use App\Filament\Resources\SettingResource\RelationManagers;
|
||||
use App\Models\Setting;
|
||||
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 SettingResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Setting::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
//
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
//
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->emptyStateActions([
|
||||
Tables\Actions\CreateAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListSettings::route('/'),
|
||||
'create' => Pages\CreateSetting::route('/create'),
|
||||
'edit' => Pages\EditSetting::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SettingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\SettingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSetting extends CreateRecord
|
||||
{
|
||||
protected static string $resource = SettingResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/SettingResource/Pages/EditSetting.php
Normal file
19
app/Filament/Resources/SettingResource/Pages/EditSetting.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SettingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\SettingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSetting extends EditRecord
|
||||
{
|
||||
protected static string $resource = SettingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SettingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\SettingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListSettings extends ListRecords
|
||||
{
|
||||
protected static string $resource = SettingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
64
app/Filament/Resources/SettingResource/Pages/Settings.php
Normal file
64
app/Filament/Resources/SettingResource/Pages/Settings.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SettingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\SettingResource;
|
||||
use App\Models\Setting;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Settings extends Page implements HasForms
|
||||
{
|
||||
use InteractsWithForms;
|
||||
|
||||
protected static string $resource = SettingResource::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-cog';
|
||||
|
||||
protected static ?string $navigationGroup = 'Settings';
|
||||
|
||||
protected static ?string $navigationLabel = 'Global Settings';
|
||||
|
||||
protected static ?string $slug = 'global-settings';
|
||||
|
||||
protected static string $view = 'filament.resources.setting-resource.pages.settings';
|
||||
|
||||
public ?array $data = [];
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->form->fill(
|
||||
collect(Setting::all())
|
||||
->mapWithKeys(fn (Setting $setting) => [$setting->key => $setting->value])
|
||||
->all()
|
||||
);
|
||||
}
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
TextInput::make('gallery_heading')
|
||||
->label(__('settings.gallery_heading')),
|
||||
])
|
||||
->statePath('data')
|
||||
->model(Setting::class);
|
||||
}
|
||||
|
||||
public function submit(): void
|
||||
{
|
||||
foreach ($this->form->getState() as $key => $value) {
|
||||
Setting::updateOrCreate(['key' => $key], ['value' => $value]);
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title(__('settings.saved_successfully'))
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user