You've already forked Epicnabbo-Catalogus-Updated-Daily
🆙 Final fix delete storage link to fix news_images and logs 🆙
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Filters;
|
||||
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class DateRangeFilter extends Filter
|
||||
{
|
||||
#[\Override]
|
||||
public static function make(?string $name = null): static
|
||||
{
|
||||
return parent::make($name)
|
||||
->schema([
|
||||
DatePicker::make("{$name}_from"),
|
||||
DatePicker::make("{$name}_until"),
|
||||
])
|
||||
->query(function (Builder $query, array $data) use (&$name): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data["{$name}_from"],
|
||||
fn (Builder $query, $date): Builder => $query->whereDate($name, '>=', $date),
|
||||
)
|
||||
->when(
|
||||
$data["{$name}_until"],
|
||||
fn (Builder $query, $date): Builder => $query->whereDate($name, '<=', $date),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,315 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Services\Parsers\ExternalTextsParser;
|
||||
use Filament\Actions\Action as PageAction;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Throwable;
|
||||
|
||||
class BadgePage extends Page
|
||||
{
|
||||
use InteractsWithForms, TranslatableResource;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Hotel';
|
||||
|
||||
protected string $view = 'filament.pages.badge-page';
|
||||
|
||||
protected static string $translateIdentifier = 'badge-resource';
|
||||
|
||||
public $badgeWasPreviouslyCreated;
|
||||
|
||||
public ?array $data = [];
|
||||
|
||||
public static string $roleName = 'badge_page';
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()->can('view::admin::' . static::$roleName);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getTitle(): string|Htmlable
|
||||
{
|
||||
return __(
|
||||
sprintf('filament::resources.resources.%s.navigation_label', static::$translateIdentifier),
|
||||
);
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make(__('filament::resources.tabs.Main'))
|
||||
->schema([
|
||||
TextInput::make('code')
|
||||
->label(__('filament::resources.inputs.badge_code'))
|
||||
->helperText(__('filament::resources.helpers.badge_code_helper'))
|
||||
->afterStateUpdated(function (?string $state, Set $set): void {
|
||||
$set('code', strtoupper($state));
|
||||
})
|
||||
->suffixAction(fn (): PageAction => PageAction::make('search')->icon('heroicon-o-magnifying-glass')->action(fn () => $this->searchBadgesByCode()),
|
||||
),
|
||||
|
||||
TextInput::make('image')
|
||||
->label(__('filament::resources.inputs.badge_image'))
|
||||
->placeholder('...')
|
||||
->autocomplete()
|
||||
->visible(fn (Get $get) => isset($this->data['image']) ?? false)
|
||||
->prefixAction(
|
||||
fn (?string $state): PageAction => PageAction::make('visit')
|
||||
->icon('heroicon-s-arrow-top-right-on-square')
|
||||
->tooltip(__('filament::resources.common.Open link'))
|
||||
->url($state)
|
||||
->visible(fn () => ! in_array($state, [null, '', '0'], true))
|
||||
->openUrlInNewTab(),
|
||||
),
|
||||
]),
|
||||
|
||||
Section::make('Nitro Texts')
|
||||
->collapsible()
|
||||
->visible(fn () => isset($this->data['nitro']) && ! empty($this->data['nitro']))
|
||||
->schema([
|
||||
TextInput::make('nitro.title')
|
||||
->label(__('filament::resources.inputs.badge_title'))
|
||||
->placeholder('...')
|
||||
->visible(fn () => isset($this->data['nitro']['title']) ?? false),
|
||||
|
||||
TextInput::make('nitro.description')
|
||||
->label(__('filament::resources.inputs.badge_description'))
|
||||
->placeholder('...')
|
||||
->visible(fn () => isset($this->data['nitro']['description']) ?? false),
|
||||
]),
|
||||
|
||||
Section::make('Flash Texts')
|
||||
->collapsible()
|
||||
->visible(fn () => isset($this->data['flash']) && ! empty($this->data['flash']))
|
||||
->schema([
|
||||
TextInput::make('flash.title')
|
||||
->label(__('filament::resources.inputs.badge_title'))
|
||||
->placeholder('...')
|
||||
->visible(fn () => isset($this->data['flash']['title']) ?? false),
|
||||
|
||||
TextInput::make('flash.description')
|
||||
->label(__('filament::resources.inputs.badge_description'))
|
||||
->placeholder('...')
|
||||
->visible(fn () => isset($this->data['flash']['description']) ?? false),
|
||||
]),
|
||||
])
|
||||
->statePath('data');
|
||||
}
|
||||
|
||||
private function searchBadgesByCode(): void
|
||||
{
|
||||
$badgeCode = $this->form->getState()['code'] ?? null;
|
||||
|
||||
if (empty($badgeCode)) {
|
||||
$this->notify('danger', __('filament::resources.notifications.badge_code_required'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$badgeData = app(ExternalTextsParser::class)->getBadgeData($badgeCode);
|
||||
$this->badgeWasPreviouslyCreated = is_array($badgeData['nitro']) || is_array($badgeData['flash']);
|
||||
|
||||
if ($this->badgeWasPreviouslyCreated) {
|
||||
Notification::make()
|
||||
->icon('heroicon-o-check-circle')
|
||||
->iconColor('success')
|
||||
->color('success')
|
||||
->title(__('filament::resources.notifications.badge_found'))
|
||||
->send();
|
||||
|
||||
$this->data = [
|
||||
'code' => $badgeCode,
|
||||
...$this->getDefaultDataBehavior(
|
||||
$badgeData['image'] ?? null,
|
||||
$badgeData['nitro']['title'] ?? null,
|
||||
$badgeData['nitro']['description'] ?? null,
|
||||
$badgeData['flash']['title'] ?? null,
|
||||
$badgeData['flash']['description'] ?? null,
|
||||
),
|
||||
];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->color('success')
|
||||
->icon('heroicon-o-check-circle')
|
||||
->iconColor('success')
|
||||
->title(__('filament::resources.notifications.create_badge'))
|
||||
->send();
|
||||
|
||||
$this->data = [
|
||||
'code' => $badgeCode,
|
||||
...$this->getDefaultDataBehavior(),
|
||||
];
|
||||
}
|
||||
|
||||
private function getDefaultDataBehavior(
|
||||
?string $badgeImageUrl = null,
|
||||
?string $nitroTitle = null,
|
||||
?string $nitroDesc = null,
|
||||
?string $flashTitle = null,
|
||||
?string $flashDesc = null,
|
||||
): array {
|
||||
return [
|
||||
'image' => $badgeImageUrl ?? '',
|
||||
'nitro' => [
|
||||
'title' => $nitroTitle ?? '',
|
||||
'description' => $nitroDesc ?? '',
|
||||
],
|
||||
'flash' => [
|
||||
'title' => $flashTitle ?? '',
|
||||
'description' => $flashDesc ?? '',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$nitroEnabled = config('hotel.client.nitro.enabled');
|
||||
$flashEnabled = config('hotel.client.flash.enabled');
|
||||
|
||||
// image and code fields are required when creating a new badge
|
||||
if (! $this->badgeWasPreviouslyCreated && (empty($this->data['image']) || empty($this->data['code']))) {
|
||||
$notificationTitle = empty($this->data['image']) ?
|
||||
__('filament::resources.notifications.badge_image_required') :
|
||||
__('filament::resources.notifications.badge_code_required');
|
||||
|
||||
Notification::make()
|
||||
->icon('heroicon-o-exclamation-triangle')
|
||||
->iconColor('danger')
|
||||
->color('danger')
|
||||
->title($notificationTitle)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$externalTextsParser = app(ExternalTextsParser::class);
|
||||
|
||||
if ((empty($this->data['nitro']) && $nitroEnabled) || (empty($this->data['flash']) && $flashEnabled)) {
|
||||
Notification::make()
|
||||
->icon('heroicon-o-exclamation-triangle')
|
||||
->iconColor('danger')
|
||||
->color('danger')
|
||||
->title(__('filament::resources.notifications.badge_texts_required'))
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->uploadBadgeImage($externalTextsParser);
|
||||
|
||||
if (! empty($this->data['nitro']) && $nitroEnabled) {
|
||||
$externalTextsParser->updateNitroBadgeTexts($this->data['code'], ...$this->data['nitro']);
|
||||
}
|
||||
if (! empty($this->data['flash']) && $flashEnabled) {
|
||||
$externalTextsParser->updateFlashBadgeTexts($this->data['code'], ...$this->data['flash']);
|
||||
}
|
||||
} catch (Throwable $exception) {
|
||||
Log::channel('badge')->error('[ORION BADGE RESOURCE] - ERROR: ' . $exception->getMessage());
|
||||
|
||||
Notification::make()
|
||||
->icon('heroicon-o-exclamation-triangle')
|
||||
->iconColor('danger')
|
||||
->color('danger')
|
||||
->title(__('filament::resources.notifications.badge_update_failed'))
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->data['image'] = $externalTextsParser->getBadgeImageUrl($this->data['code']);
|
||||
$this->badgeWasPreviouslyCreated = true;
|
||||
|
||||
Notification::make()
|
||||
->icon('heroicon-o-check-circle')
|
||||
->iconColor('success')
|
||||
->color('success')
|
||||
->title(__('filament::resources.notifications.badge_updated'))
|
||||
->send();
|
||||
}
|
||||
|
||||
protected function uploadBadgeImage(ExternalTextsParser $parser): void
|
||||
{
|
||||
if (empty($this->data['image']) || ! filter_var($this->data['image'], FILTER_VALIDATE_URL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->data['image'] == $parser->getBadgeImageUrl($this->data['code'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$image = Http::get($this->data['image']);
|
||||
|
||||
if (! $image->successful()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$contentType = $image->header('content-type');
|
||||
|
||||
$gdImage = match ($contentType) {
|
||||
'image/png' => imagecreatefrompng($this->data['image']),
|
||||
'image/gif' => imagecreatefromgif($this->data['image']),
|
||||
'image/jpeg' => imagecreatefromjpeg($this->data['image']),
|
||||
default => false
|
||||
};
|
||||
|
||||
if ($gdImage === false) {
|
||||
Notification::make()
|
||||
->icon('heroicon-o-exclamation-triangle')
|
||||
->iconColor('danger')
|
||||
->color('danger')
|
||||
->title(__('filament::resources.notifications.badge_image_upload_failed'))
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$uploadPath = public_path(sprintf('%s%s%s.gif',
|
||||
rtrim((string) config('hotel.client.flash.relative_files_path'), '\//'),
|
||||
'/c_images/album1584/',
|
||||
$this->data['code'],
|
||||
));
|
||||
|
||||
imagegif($gdImage, $uploadPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<\Filament\Actions\Action|ActionGroup>
|
||||
*/
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
PageAction::make('save')
|
||||
->label(__('filament::resources.common.Update'))
|
||||
->action(fn () => $this->create())
|
||||
->color('primary')
|
||||
->visible(fn () => isset($this->data['code']) && $this->badgeWasPreviouslyCreated),
|
||||
|
||||
PageAction::make('create')
|
||||
->label(__('filament::resources.common.Create'))
|
||||
->action(fn () => $this->create())
|
||||
->color('success')
|
||||
->visible(fn () => isset($this->data['code']) && ! $this->badgeWasPreviouslyCreated),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use Filament\Pages\Dashboard as FilamentDashboard;
|
||||
|
||||
class Dashboard extends FilamentDashboard
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Dashboard';
|
||||
|
||||
protected static ?string $navigationLabel = 'Homepage';
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-home';
|
||||
|
||||
public static string $translateIdentifier = 'dashboard';
|
||||
|
||||
public static string $roleName = 'dashboard';
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()->can('view::admin::' . static::$roleName);
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException;
|
||||
use Filament\Auth\Http\Responses\Contracts\LoginResponse;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Components\Component;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class Login extends \Filament\Auth\Pages\Login
|
||||
{
|
||||
public $username = '';
|
||||
|
||||
#[\Override]
|
||||
public function authenticate(): ?LoginResponse
|
||||
{
|
||||
try {
|
||||
$this->rateLimit(5);
|
||||
} catch (TooManyRequestsException $exception) {
|
||||
Notification::make()
|
||||
->title(__('filament-panels::pages/auth/login.notifications.throttled.title', [
|
||||
'seconds' => $exception->secondsUntilAvailable,
|
||||
'minutes' => ceil($exception->secondsUntilAvailable / 60),
|
||||
]))
|
||||
->body(array_key_exists('body', __('filament-panels::pages/auth/login.notifications.throttled') ?: []) ? __('filament-panels::pages/auth/login.notifications.throttled.body', [
|
||||
'seconds' => $exception->secondsUntilAvailable,
|
||||
'minutes' => ceil($exception->secondsUntilAvailable / 60),
|
||||
]) : null)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = $this->form->getState();
|
||||
|
||||
if (! Filament::auth()->attempt($this->getCredentialsFromFormData($data), $data['remember'] ?? false)) {
|
||||
$this->throwFailureValidationException();
|
||||
}
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
if (
|
||||
($user instanceof FilamentUser) &&
|
||||
(! $user->canAccessPanel(Filament::getCurrentOrDefaultPanel()))
|
||||
) {
|
||||
Filament::auth()->logout();
|
||||
|
||||
$this->throwFailureValidationException();
|
||||
}
|
||||
|
||||
session()->regenerate();
|
||||
|
||||
return app(LoginResponse::class);
|
||||
}
|
||||
|
||||
protected function throwFailureValidationException(): never
|
||||
{
|
||||
throw ValidationException::withMessages([
|
||||
'data.username' => __('filament-panels::pages/auth/login.messages.failed'),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getFormSchema(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('username')
|
||||
->label(__('filament::login.fields.username.label'))
|
||||
->required()
|
||||
->autocomplete(),
|
||||
TextInput::make('password')
|
||||
->label(__('filament::login.fields.password.label'))
|
||||
->password()
|
||||
->required(),
|
||||
Checkbox::make('remember')
|
||||
->label(__('filament::login.fields.remember.label')),
|
||||
];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
protected function getEmailFormComponent(): Component
|
||||
{
|
||||
return TextInput::make('username')
|
||||
->label(__('filament::login.fields.username.label'))
|
||||
->required()
|
||||
->autocomplete()
|
||||
->autofocus()
|
||||
->extraInputAttributes(['tabindex' => 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
#[\Override]
|
||||
protected function getCredentialsFromFormData(array $data): array
|
||||
{
|
||||
return [
|
||||
'username' => $data['username'],
|
||||
'password' => $data['password'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,227 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Articles;
|
||||
|
||||
use App\Filament\Resources\Atom\Articles\Pages\CreateArticle;
|
||||
use App\Filament\Resources\Atom\Articles\Pages\EditArticle;
|
||||
use App\Filament\Resources\Atom\Articles\Pages\ListArticles;
|
||||
use App\Filament\Resources\Atom\Articles\Pages\ViewArticle;
|
||||
use App\Filament\Resources\Atom\Articles\RelationManagers\TagsRelationManager;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\Articles\WebsiteArticle;
|
||||
use Exception;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\ForceDeleteBulkAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Actions\RestoreBulkAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Filters\TrashedFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class ArticleResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static ?string $model = WebsiteArticle::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-newspaper';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Website';
|
||||
|
||||
protected static ?string $slug = 'website/articles';
|
||||
|
||||
public static string $translateIdentifier = 'articles';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components(static::getForm());
|
||||
}
|
||||
|
||||
public static function getForm(): array
|
||||
{
|
||||
return [
|
||||
Tabs::make('Main')
|
||||
->tabs([
|
||||
Tab::make(__('filament::resources.tabs.Home'))
|
||||
->icon('heroicon-o-home')
|
||||
->schema([
|
||||
TextInput::make('title')
|
||||
->label(__('filament::resources.inputs.title'))
|
||||
->required()
|
||||
->autocomplete()
|
||||
->maxLength(255)
|
||||
->columnSpan('full'),
|
||||
|
||||
TextInput::make('short_story')
|
||||
->label(__('filament::resources.inputs.description'))
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->autocomplete()
|
||||
->columnSpan('full'),
|
||||
|
||||
FileUpload::make('image')
|
||||
->label(__('filament::resources.inputs.image'))
|
||||
->directory('website_news_images')
|
||||
->visibility('public'),
|
||||
|
||||
RichEditor::make('full_story')
|
||||
->label(__('filament::resources.inputs.content'))
|
||||
->required()
|
||||
->columnSpan('full'),
|
||||
|
||||
Hidden::make('user_id')
|
||||
->default(fn () => auth()->check() ? auth()->user()->id : null),
|
||||
]),
|
||||
|
||||
Tab::make(__('filament::resources.tabs.Configurations'))
|
||||
->icon('heroicon-o-cog')
|
||||
->schema([
|
||||
Toggle::make('is_visible')
|
||||
->label(__('filament::resources.inputs.visible'))
|
||||
->onIcon('heroicon-s-check')
|
||||
->offIcon('heroicon-s-x-mark')
|
||||
->default(true)
|
||||
->live()
|
||||
->afterStateUpdated(function (string $operation, $state, $record): void {
|
||||
if ($operation !== 'edit' || is_null($record)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if ($state) {
|
||||
$record->restore();
|
||||
} else {
|
||||
$record->delete();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
report($e);
|
||||
}
|
||||
})
|
||||
->formatStateUsing(function ($record) {
|
||||
if (is_null($record)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return is_null($record->deleted_at);
|
||||
}),
|
||||
|
||||
Toggle::make('can_comment')
|
||||
->onIcon('heroicon-s-check')
|
||||
->label(__('filament::resources.inputs.allow_comments'))
|
||||
->default(true)
|
||||
->offIcon('heroicon-s-x-mark'),
|
||||
]),
|
||||
])->columnSpanFull(),
|
||||
];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('id', 'desc')
|
||||
->poll('60s')
|
||||
->columns(static::getTable())
|
||||
->filters([
|
||||
TrashedFilter::make(),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
RestoreAction::make(),
|
||||
ForceDeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
DeleteBulkAction::make(),
|
||||
RestoreBulkAction::make(),
|
||||
ForceDeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getTable(): array
|
||||
{
|
||||
return [
|
||||
TextColumn::make('id')
|
||||
->label(__('filament::resources.columns.id')),
|
||||
|
||||
ImageColumn::make('image')
|
||||
->circular()
|
||||
->extraAttributes(['style' => 'image-rendering: pixelated'])
|
||||
->size(50)
|
||||
->label(__('filament::resources.columns.image')),
|
||||
|
||||
TextColumn::make('title')
|
||||
->label(__('filament::resources.columns.title'))
|
||||
->searchable()
|
||||
->limit(50),
|
||||
|
||||
TextColumn::make('user.username')
|
||||
->searchable()
|
||||
->label(__('filament::resources.columns.by')),
|
||||
|
||||
ToggleColumn::make('is_visible')
|
||||
->label(__('filament::resources.columns.visible'))
|
||||
->onIcon('heroicon-s-check')
|
||||
->toggleable()
|
||||
->state(fn ($record) => is_null($record->deleted_at))
|
||||
->disabled(),
|
||||
|
||||
ToggleColumn::make('allow_comments')
|
||||
->label(__('filament::resources.columns.allow_comments'))
|
||||
->onIcon('heroicon-s-check')
|
||||
->toggleable()
|
||||
->disabled(),
|
||||
];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
TagsRelationManager::class,
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListArticles::route('/'),
|
||||
'create' => CreateArticle::route('/create'),
|
||||
'view' => ViewArticle::route('/{record}'),
|
||||
'edit' => EditArticle::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getGlobalSearchEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getGlobalSearchEloquentQuery()->withTrashed();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Articles\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Articles\ArticleResource;
|
||||
use App\Models\Article;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateArticle extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ArticleResource::class;
|
||||
|
||||
protected function afterCreate(): void
|
||||
{
|
||||
/** @var null|Article $articleCreated */
|
||||
$articleCreated = $this->getRecord();
|
||||
|
||||
if (! $articleCreated || ! $articleCreated->visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
$articleCreated->createFollowersNotification();
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Articles\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Articles\ArticleResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditArticle extends EditRecord
|
||||
{
|
||||
protected static string $resource = ArticleResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Articles\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Articles\ArticleResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListArticles extends ListRecords
|
||||
{
|
||||
protected static string $resource = ArticleResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Articles\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Articles\ArticleResource;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ViewArticle extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ArticleResource::class;
|
||||
|
||||
public function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('Send Notification')
|
||||
->label(__('Send notifications'))
|
||||
->color('gray')
|
||||
->visible(fn (Model $record) => $record->user_id === Auth::id())
|
||||
->requiresConfirmation()
|
||||
->action(function (Model $record): void {
|
||||
$record->createFollowersNotification();
|
||||
}),
|
||||
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Articles\RelationManagers;
|
||||
|
||||
use App\Filament\Resources\Atom\Tags\TagResource;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use Filament\Actions\AttachAction;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DetachAction;
|
||||
use Filament\Actions\DetachBulkAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TagsRelationManager extends RelationManager
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static string $relationship = 'tags';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static string $translateIdentifier = 'tags';
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]);
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns(TagResource::getTable())
|
||||
->modifyQueryUsing(fn ($query) => $query->latest())
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make()
|
||||
->schema(TagResource::getForm()),
|
||||
|
||||
AttachAction::make()->preloadRecordSelect(),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
DetachAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
DetachBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\CameraWebs;
|
||||
|
||||
use App\Filament\Resources\Atom\CameraWebs\Pages\EditCameraWeb;
|
||||
use App\Filament\Resources\Atom\CameraWebs\Pages\ListCameraWeb;
|
||||
use App\Models\Miscellaneous\CameraWeb;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CameraWebResource extends Resource
|
||||
{
|
||||
protected static ?string $model = CameraWeb::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-photo';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Website';
|
||||
|
||||
protected static ?string $slug = 'camera-web';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'photos';
|
||||
|
||||
protected static ?string $navigationLabel = 'Web Camera';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Toggle::make('visible')
|
||||
->label(__('Visible'))
|
||||
->default(true),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('id', 'desc')
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label(__('filament::resources.columns.id'))
|
||||
->sortable(),
|
||||
TextColumn::make('user_id')
|
||||
->label(__('filament::resources.columns.user_id')),
|
||||
TextColumn::make('room_id')
|
||||
->label(__('filament::resources.columns.room_id')),
|
||||
TextColumn::make('timestamp')
|
||||
->label(__('filament::resources.columns.created_at'))
|
||||
->dateTime(),
|
||||
ImageColumn::make('url')
|
||||
->label(__('filament::resources.columns.image'))
|
||||
->extraAttributes(['style' => 'image-rendering: pixelated'])
|
||||
->size(125),
|
||||
ToggleColumn::make('visible')
|
||||
->label(__('Visible')),
|
||||
])
|
||||
->recordActions([
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListCameraWeb::route('/'),
|
||||
'edit' => EditCameraWeb::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function canCreate(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\CameraWebs\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\CameraWebs\CameraWebResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCameraWeb extends EditRecord
|
||||
{
|
||||
protected static string $resource = CameraWebResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\CameraWebs\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\CameraWebs\CameraWebResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCameraWeb extends ListRecords
|
||||
{
|
||||
protected static string $resource = CameraWebResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\CmsSettings;
|
||||
|
||||
use App\Filament\Resources\Atom\CmsSettings\Pages\ManageCmsSettings;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\Miscellaneous\WebsiteSetting;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CmsSettingResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static ?string $model = WebsiteSetting::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-cpu-chip';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Website';
|
||||
|
||||
protected static ?string $slug = 'website/cms-settings';
|
||||
|
||||
public static string $translateIdentifier = 'cms-settings';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make()
|
||||
->schema([
|
||||
TextInput::make('key')
|
||||
->label(__('filament::resources.inputs.key'))
|
||||
->maxLength(50)
|
||||
->autocomplete()
|
||||
->unique(ignoreRecord: true)
|
||||
->required(),
|
||||
|
||||
TextInput::make('value')
|
||||
->label(__('filament::resources.inputs.value'))
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->autocomplete(),
|
||||
|
||||
TextInput::make('comment')
|
||||
->label(__('filament::resources.inputs.comment'))
|
||||
->nullable()
|
||||
->maxLength(255)
|
||||
->autocomplete()
|
||||
->columnSpanFull(),
|
||||
])
|
||||
->columns([
|
||||
'sm' => 2,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('id', 'desc')
|
||||
->columns([
|
||||
TextColumn::make('key')
|
||||
->label(__('filament::resources.columns.key'))
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('value')
|
||||
->label(__('filament::resources.columns.value'))
|
||||
->searchable()
|
||||
->limit(30),
|
||||
|
||||
TextColumn::make('comment')
|
||||
->label(__('filament::resources.columns.comment'))
|
||||
->toggleable()
|
||||
->searchable()
|
||||
->tooltip(function (TextColumn $column): ?string {
|
||||
$state = $column->getState();
|
||||
|
||||
if (strlen($state) <= $column->getCharacterLimit()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $state;
|
||||
})
|
||||
->limit(60),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
// ...
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ManageCmsSettings::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\CmsSettings\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\CmsSettings\CmsSettingResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageCmsSettings extends ManageRecords
|
||||
{
|
||||
protected static string $resource = CmsSettingResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTableRecordsPerPageSelectOptions(): array
|
||||
{
|
||||
return [25, 50, 100];
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\HelpQuestionCategoryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\HelpQuestionCategoryResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateHelpQuestionCategory extends CreateRecord
|
||||
{
|
||||
protected static string $resource = HelpQuestionCategoryResource::class;
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\HelpQuestionCategoryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\HelpQuestionCategoryResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditHelpQuestionCategory extends EditRecord
|
||||
{
|
||||
protected static string $resource = HelpQuestionCategoryResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\HelpQuestionCategoryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\HelpQuestionCategoryResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListHelpQuestionCategories extends ListRecords
|
||||
{
|
||||
protected static string $resource = HelpQuestionCategoryResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTableReorderColumn(): ?string
|
||||
{
|
||||
return 'order';
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\HelpQuestionCategoryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\HelpQuestionCategoryResource;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewHelpQuestionCategory extends ViewRecord
|
||||
{
|
||||
protected static string $resource = HelpQuestionCategoryResource::class;
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\HelpQuestionCategoryResource\RelationManagers;
|
||||
|
||||
use App\Filament\Resources\Atom\HelpQuestionResource;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use Filament\Actions\AttachAction;
|
||||
use Filament\Actions\DetachAction;
|
||||
use Filament\Actions\DetachBulkAction;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class QuestionsRelationManager extends RelationManager
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static string $relationship = 'questions';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'title';
|
||||
|
||||
public static string $translateIdentifier = 'help-questions';
|
||||
|
||||
protected static ?string $inverseRelationship = 'categories';
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components(HelpQuestionResource::getForm(true));
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table->columns(HelpQuestionResource::getTable())
|
||||
->modifyQueryUsing(fn ($query) => $query->latest())
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
AttachAction::make(),
|
||||
])
|
||||
->recordActions([
|
||||
DetachAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
DetachBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\HelpQuestionResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\HelpQuestionResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateHelpQuestion extends CreateRecord
|
||||
{
|
||||
protected static string $resource = HelpQuestionResource::class;
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\HelpQuestionResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\HelpQuestionResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditHelpQuestion extends EditRecord
|
||||
{
|
||||
protected static string $resource = HelpQuestionResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\HelpQuestionResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\HelpQuestionResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListHelpQuestions extends ListRecords
|
||||
{
|
||||
protected static string $resource = HelpQuestionResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\HelpQuestionResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\HelpQuestionResource;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewHelpQuestion extends ViewRecord
|
||||
{
|
||||
protected static string $resource = HelpQuestionResource::class;
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\HelpQuestionResource\RelationManagers;
|
||||
|
||||
use App\Filament\Resources\Atom\HelpQuestionCategoryResource;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use Filament\Actions\AttachAction;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DetachAction;
|
||||
use Filament\Actions\DetachBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CategoriesRelationManager extends RelationManager
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static string $relationship = 'categories';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static string $translateIdentifier = 'help-question-categories';
|
||||
|
||||
protected static ?string $inverseRelationship = 'questions';
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components(HelpQuestionCategoryResource::getForm());
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table->columns(HelpQuestionCategoryResource::getTable())
|
||||
->modifyQueryUsing(fn ($query) => $query->latest('id'))
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make(),
|
||||
AttachAction::make(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DetachAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
DetachBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
-119
@@ -1,119 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\HousekeepingPermissions;
|
||||
|
||||
use App\Filament\Resources\Atom\HousekeepingPermissions\Pages\ListHousekeepingPermissions;
|
||||
use App\Models\WebsiteHousekeepingPermission;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class HousekeepingPermissionResource extends Resource
|
||||
{
|
||||
protected static ?string $model = WebsiteHousekeepingPermission::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-shield-check';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Website';
|
||||
|
||||
protected static ?string $slug = 'website/housekeeping-permissions';
|
||||
|
||||
protected static ?string $navigationLabel = 'Housekeeping permissions';
|
||||
|
||||
public static string $translateIdentifier = 'housekeeping-permissions';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make()
|
||||
->schema([
|
||||
TextInput::make('permission')
|
||||
->label(__('filament::resources.inputs.permission'))
|
||||
->maxLength(50)
|
||||
->autocomplete()
|
||||
->unique(ignoreRecord: true)
|
||||
->required(),
|
||||
|
||||
TextInput::make('min_rank')
|
||||
->label(__('filament::resources.inputs.min_rank'))
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->autocomplete(),
|
||||
|
||||
TextInput::make('description')
|
||||
->label(__('filament::resources.inputs.description'))
|
||||
->nullable()
|
||||
->maxLength(255)
|
||||
->autocomplete()
|
||||
->columnSpanFull(),
|
||||
])
|
||||
->columns([
|
||||
'sm' => 2,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('id', 'asc')
|
||||
->columns([
|
||||
TextColumn::make('permission')
|
||||
->label(__('filament::resources.columns.permission'))
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('min_rank')
|
||||
->label(__('filament::resources.columns.min_rank'))
|
||||
->searchable()
|
||||
->limit(30),
|
||||
|
||||
TextColumn::make('description')
|
||||
->label(__('filament::resources.columns.description'))
|
||||
->toggleable()
|
||||
->searchable()
|
||||
->tooltip(function (TextColumn $column): ?string {
|
||||
$state = $column->getState();
|
||||
|
||||
if (strlen($state) <= $column->getCharacterLimit()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $state;
|
||||
})
|
||||
->limit(60),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
//
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListHousekeepingPermissions::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\HousekeepingPermissions\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\HousekeepingPermissions\HousekeepingPermissionResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListHousekeepingPermissions extends ListRecords
|
||||
{
|
||||
protected static string $resource = HousekeepingPermissionResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\NavigationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\NavigationResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateNavigation extends CreateRecord
|
||||
{
|
||||
protected static string $resource = NavigationResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\NavigationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\NavigationResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditNavigation extends EditRecord
|
||||
{
|
||||
protected static string $resource = NavigationResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\NavigationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\NavigationResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListNavigations extends ListRecords
|
||||
{
|
||||
protected static string $resource = NavigationResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-92
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\NavigationResource\RelationManagers;
|
||||
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\DissociateAction;
|
||||
use Filament\Actions\DissociateBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class SubNavigationsRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'subNavigations';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'label';
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('label')
|
||||
->label(__('filament::resources.inputs.label'))
|
||||
->columnSpanFull()
|
||||
->required()
|
||||
->maxLength(255),
|
||||
|
||||
TextInput::make('slug')
|
||||
->label(__('filament::resources.inputs.slug')),
|
||||
|
||||
TextInput::make('order')
|
||||
->numeric()
|
||||
->minValue(0)
|
||||
->default(0)
|
||||
->label(__('filament::resources.columns.order')),
|
||||
|
||||
Toggle::make('visible')
|
||||
->label(__('filament::resources.columns.visible')),
|
||||
|
||||
Toggle::make('new_tab')
|
||||
->label(__('filament::resources.columns.new_tab')),
|
||||
])
|
||||
->columns([
|
||||
'sm' => 2,
|
||||
]);
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('label'),
|
||||
|
||||
TextColumn::make('slug')
|
||||
->label(__('filament::resources.columns.slug')),
|
||||
|
||||
ToggleColumn::make('visible')
|
||||
->label(__('filament::resources.columns.visible')),
|
||||
|
||||
ToggleColumn::make('new_tab')
|
||||
->label(__('filament::resources.columns.new_tab')),
|
||||
|
||||
TextColumn::make('order')
|
||||
->label(__('filament::resources.columns.order')),
|
||||
])
|
||||
->reorderable('order')
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make(),
|
||||
// Tables\Actions\AssociateAction::make(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DissociateAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
DissociateBulkAction::make(),
|
||||
DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Permissions\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Permissions\PermissionResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreatePermission extends CreateRecord
|
||||
{
|
||||
protected static string $resource = PermissionResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Permissions\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Permissions\PermissionResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditPermission extends EditRecord
|
||||
{
|
||||
protected static string $resource = PermissionResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Permissions\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Permissions\PermissionResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListPermissions extends ListRecords
|
||||
{
|
||||
protected static string $resource = PermissionResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Permissions\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Permissions\PermissionResource;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewPermission extends ViewRecord
|
||||
{
|
||||
protected static string $resource = PermissionResource::class;
|
||||
|
||||
public function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,268 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Permissions;
|
||||
|
||||
use App\Filament\Resources\Atom\Permissions\Pages\CreatePermission;
|
||||
use App\Filament\Resources\Atom\Permissions\Pages\EditPermission;
|
||||
use App\Filament\Resources\Atom\Permissions\Pages\ListPermissions;
|
||||
use App\Filament\Resources\Atom\Permissions\Pages\ViewPermission;
|
||||
use App\Filament\Tables\Columns\HabboBadgeColumn;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\Game\Permission;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\ColorPicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Pages\Enums\SubNavigationPosition;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Str;
|
||||
|
||||
class PermissionResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static ?string $model = Permission::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-shield-check';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Website';
|
||||
|
||||
protected static ?string $slug = 'website/permissions';
|
||||
|
||||
public static string $translateIdentifier = 'permissions';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'rank_name';
|
||||
|
||||
protected static ?\Filament\Pages\Enums\SubNavigationPosition $subNavigationPosition = SubNavigationPosition::Top;
|
||||
|
||||
#[\Override]
|
||||
public static function form(\Filament\Schemas\Schema $schema): \Filament\Schemas\Schema
|
||||
{
|
||||
/**
|
||||
* @param string $name
|
||||
* @param bool $needsSecondOption = false
|
||||
*/
|
||||
$groupedToggleButton = fn (string $name, bool $needsSecondOption = false): ToggleButtons => ToggleButtons::make($name)
|
||||
->label(function () use ($name) {
|
||||
$translationKey = "filament::resources.permissions.{$name}";
|
||||
$translation = __($translationKey);
|
||||
|
||||
if ($translationKey == $translation) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
return $translation;
|
||||
})
|
||||
->options(function () use ($needsSecondOption) {
|
||||
$options = [
|
||||
'0' => __('filament::resources.options.no'),
|
||||
'1' => __('filament::resources.options.yes'),
|
||||
];
|
||||
|
||||
if ($needsSecondOption) {
|
||||
$options['2'] = __('filament::resources.options.rights');
|
||||
}
|
||||
|
||||
return $options;
|
||||
})
|
||||
->icons(['0' => 'heroicon-o-check', '1' => 'heroicon-o-x-mark', '2' => 'heroicon-o-sparkles'])
|
||||
->colors(['0' => 'danger', '1' => 'success'])
|
||||
->grouped();
|
||||
|
||||
return $schema
|
||||
->components([
|
||||
Tabs::make('Main')
|
||||
->tabs([
|
||||
Tab::make(__('filament::resources.tabs.General Information'))
|
||||
->schema([
|
||||
TextInput::make('rank_name')
|
||||
->label(__('filament::resources.inputs.name'))
|
||||
->maxLength(25)
|
||||
->required(),
|
||||
|
||||
TextInput::make('badge')
|
||||
->label(__('filament::resources.inputs.badge_code'))
|
||||
->maxLength(12)
|
||||
->required(),
|
||||
|
||||
TextInput::make('level')
|
||||
->label(__('filament::resources.inputs.level'))
|
||||
->required(),
|
||||
|
||||
TextInput::make('room_effect')
|
||||
->label(__('filament::resources.inputs.room_effect'))
|
||||
->required(),
|
||||
]),
|
||||
|
||||
Tab::make(__('filament::resources.tabs.In-game Permissions'))
|
||||
->schema([
|
||||
Section::make(__('filament::resources.sections.permissions.title'))
|
||||
->description(new HtmlString(__('filament::resources.sections.permissions.description')))
|
||||
->schema([
|
||||
Grid::make()
|
||||
->columns([
|
||||
'sm' => 2,
|
||||
'md' => 3,
|
||||
'lg' => 3,
|
||||
])
|
||||
->schema(function () use ($groupedToggleButton) {
|
||||
$columns = Schema::getColumns('permissions');
|
||||
|
||||
$arcturusPermissions = collect($columns)->filter(function (array $column) {
|
||||
$columnName = $column['name'] ?? null;
|
||||
|
||||
if (! $columnName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return str_starts_with($columnName, 'cmd')
|
||||
|| str_starts_with($columnName, 'acc')
|
||||
|| str_ends_with($columnName, 'cmd');
|
||||
})->values();
|
||||
|
||||
return $arcturusPermissions->map(function (array $column) use ($groupedToggleButton) {
|
||||
$columnName = $column['name'];
|
||||
$needsSecondOption = $column['type_name'] == 'enum' && str_ends_with((string) $column['type'], "'2')");
|
||||
|
||||
return $groupedToggleButton($columnName, $needsSecondOption);
|
||||
})->toArray();
|
||||
}),
|
||||
]),
|
||||
|
||||
]),
|
||||
|
||||
Tab::make(__('filament::resources.tabs.Configurations'))
|
||||
->schema([
|
||||
Grid::make(['default' => 2])
|
||||
->schema([
|
||||
Select::make('log_commands')
|
||||
->label(__('filament::resources.inputs.log_commands'))
|
||||
->columnSpanFull()
|
||||
->options([
|
||||
'0' => __('filament::resources.options.no'),
|
||||
'1' => __('filament::resources.options.yes'),
|
||||
]),
|
||||
|
||||
TextInput::make('prefix')
|
||||
->label(__('filament::resources.inputs.prefix'))
|
||||
->maxLength(5)
|
||||
->required(),
|
||||
|
||||
ColorPicker::make('prefix_color')
|
||||
->label(__('filament::resources.inputs.prefix_color'))
|
||||
->required(),
|
||||
|
||||
Toggle::make('hidden_rank')
|
||||
->label(__('filament::resources.inputs.is_hidden'))
|
||||
->columnSpanFull(),
|
||||
|
||||
Section::make()
|
||||
->schema([
|
||||
Grid::make()
|
||||
->columns([
|
||||
'md' => 2,
|
||||
])
|
||||
->schema([
|
||||
TextInput::make('auto_credits_amount')
|
||||
->columnSpan(1)
|
||||
->label(__('filament::resources.inputs.auto_credits_amount'))
|
||||
->required(),
|
||||
|
||||
TextInput::make('auto_pixels_amount')
|
||||
->label(__('filament::resources.inputs.auto_pixels_amount'))
|
||||
->required(),
|
||||
|
||||
TextInput::make('auto_gotw_amount')
|
||||
->label(__('filament::resources.inputs.auto_gotw_amount'))
|
||||
->required(),
|
||||
|
||||
TextInput::make('auto_points_amount')
|
||||
->label(__('filament::resources.inputs.auto_points_amount'))
|
||||
->required(),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
])
|
||||
->columnSpanFull()
|
||||
->persistTabInQueryString(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('id', 'desc')
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label(__('filament::resources.columns.id')),
|
||||
|
||||
HabboBadgeColumn::make('badge')
|
||||
->alignCenter()
|
||||
->label(__('filament::resources.columns.image')),
|
||||
|
||||
TextColumn::make('rank_name')
|
||||
->label(__('filament::resources.columns.name'))
|
||||
->description(fn (Model $record) => Str::limit($record->description, 40))
|
||||
->tooltip(function (Model $record): ?string {
|
||||
$description = $record->description;
|
||||
|
||||
if (strlen($description) <= 40) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $description;
|
||||
})
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('prefix')
|
||||
->label(__('filament::resources.columns.prefix'))
|
||||
->description(fn (Model $record) => $record->prefix_color)
|
||||
->searchable(),
|
||||
|
||||
ToggleColumn::make('hidden_rank')
|
||||
->label(__('filament::resources.columns.is_hidden')),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListPermissions::route('/'),
|
||||
'create' => CreatePermission::route('/create'),
|
||||
'view' => ViewPermission::route('/{record}'),
|
||||
'edit' => EditPermission::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Tags\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Tags\TagResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTag extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TagResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Tags\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Tags\TagResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTag extends EditRecord
|
||||
{
|
||||
protected static string $resource = TagResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Tags\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Tags\TagResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTags extends ListRecords
|
||||
{
|
||||
protected static string $resource = TagResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Tags\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Tags\TagResource;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewTag extends ViewRecord
|
||||
{
|
||||
protected static string $resource = TagResource::class;
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Tags\RelationManagers;
|
||||
|
||||
use App\Filament\Resources\Atom\Articles\ArticleResource;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use Filament\Actions\AttachAction;
|
||||
use Filament\Actions\DetachAction;
|
||||
use Filament\Actions\DetachBulkAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ArticlesRelationManager extends RelationManager
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
// Use camelCase to match the method in the Tag model
|
||||
protected static string $relationship = 'websiteArticles';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'title';
|
||||
|
||||
public static string $translateIdentifier = 'article';
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components(ArticleResource::getForm());
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns(ArticleResource::getTable())
|
||||
->modifyQueryUsing(fn ($query) => $query->latest())
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
AttachAction::make()
|
||||
->preloadRecordSelect(),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
DetachAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
DetachBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Tags;
|
||||
|
||||
use App\Filament\Resources\Atom\Tags\Pages\CreateTag;
|
||||
use App\Filament\Resources\Atom\Tags\Pages\EditTag;
|
||||
use App\Filament\Resources\Atom\Tags\Pages\ListTags;
|
||||
use App\Filament\Resources\Atom\Tags\Pages\ViewTag;
|
||||
use App\Filament\Resources\Atom\Tags\RelationManagers\ArticlesRelationManager;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\Articles\Tag;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\ColorPicker;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\ColorColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TagResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static ?string $model = Tag::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-tag';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Website';
|
||||
|
||||
protected static ?string $slug = 'website/tags';
|
||||
|
||||
public static string $translateIdentifier = 'tags';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components(static::getForm());
|
||||
}
|
||||
|
||||
public static function getForm(): array
|
||||
{
|
||||
return [
|
||||
Tabs::make('Main')
|
||||
->tabs([
|
||||
Tab::make(__('filament::resources.tabs.Home'))
|
||||
->icon('heroicon-o-home')
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label(__('filament::resources.inputs.name'))
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->autocomplete()
|
||||
->columnSpan('full'),
|
||||
|
||||
ColorPicker::make('background_color')
|
||||
->label(__('filament::resources.inputs.background_color'))
|
||||
->required()
|
||||
->columnSpan('full'),
|
||||
]),
|
||||
])->columnSpanFull(),
|
||||
];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('id', 'desc')
|
||||
->columns(static::getTable())
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getTable(): array
|
||||
{
|
||||
return [
|
||||
TextColumn::make('id')
|
||||
->label(__('filament::resources.columns.id')),
|
||||
|
||||
TextColumn::make('name')
|
||||
->label(__('filament::resources.columns.name'))
|
||||
->searchable()
|
||||
->limit(50),
|
||||
|
||||
ColorColumn::make('background_color')
|
||||
->label(__('filament::resources.columns.background_color'))
|
||||
->searchable()
|
||||
->copyable()
|
||||
->copyMessage(__('filament::resources.common.Sucessfull'))
|
||||
->copyMessageDuration(1500),
|
||||
];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
ArticlesRelationManager::class,
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListTags::route('/'),
|
||||
'create' => CreateTag::route('/create'),
|
||||
'view' => ViewTag::route('/{record}'),
|
||||
'edit' => EditTag::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Teams\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Teams\TeamResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTeam extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TeamResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Teams\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Teams\TeamResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTeam extends EditRecord
|
||||
{
|
||||
protected static string $resource = TeamResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Teams\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\Teams\TeamResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTeams extends ListRecords
|
||||
{
|
||||
protected static string $resource = TeamResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\Teams;
|
||||
|
||||
use App\Filament\Resources\Atom\Teams\Pages\CreateTeam;
|
||||
use App\Filament\Resources\Atom\Teams\Pages\EditTeam;
|
||||
use App\Filament\Resources\Atom\Teams\Pages\ListTeams;
|
||||
use App\Filament\Tables\Columns\HabboBadgeColumn;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\Community\Staff\WebsiteTeam;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TeamResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static ?string $model = WebsiteTeam::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-user-group';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Website';
|
||||
|
||||
protected static ?string $slug = 'website/teams';
|
||||
|
||||
public static string $translateIdentifier = 'teams';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make()
|
||||
->schema([
|
||||
TextInput::make('rank_name')
|
||||
->autofocus()
|
||||
->maxLength(255)
|
||||
->required()
|
||||
->label(__('filament::resources.inputs.name')),
|
||||
|
||||
TextInput::make('job_description')
|
||||
->maxLength(255)
|
||||
->label(__('filament::resources.inputs.description')),
|
||||
|
||||
TextInput::make('badge')
|
||||
->maxLength(255)
|
||||
->label(__('filament::resources.inputs.badge_code'))
|
||||
->required(),
|
||||
|
||||
Toggle::make('hidden_rank')
|
||||
->label(__('filament::resources.inputs.is_hidden')),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('id', 'desc')
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label(__('filament::resources.columns.id')),
|
||||
|
||||
HabboBadgeColumn::make('badge')
|
||||
->label(__('filament::resources.columns.badge')),
|
||||
|
||||
TextColumn::make('rank_name')
|
||||
->label(__('filament::resources.columns.name')),
|
||||
|
||||
TextColumn::make('job_description')
|
||||
->label(__('filament::resources.inputs.description')),
|
||||
|
||||
IconColumn::make('hidden_rank')
|
||||
->label(__('filament::resources.columns.is_hidden'))
|
||||
->icon(fn (Model $record) => $record->hidden_rank ? 'heroicon-o-check-circle' : 'heroicon-o-x-circle')
|
||||
->colors([
|
||||
'danger' => false,
|
||||
'success' => true,
|
||||
]),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListTeams::route('/'),
|
||||
'create' => CreateTeam::route('/create'),
|
||||
'edit' => EditTeam::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\WebsiteDrawBadges\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\WebsiteDrawBadges\WebsiteDrawBadgeResource;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditWebsiteDrawBadge extends EditRecord
|
||||
{
|
||||
protected static string $resource = WebsiteDrawBadgeResource::class;
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\WebsiteDrawBadges\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\WebsiteDrawBadges\WebsiteDrawBadgeResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListWebsiteDrawBadge extends ListRecords
|
||||
{
|
||||
protected static string $resource = WebsiteDrawBadgeResource::class;
|
||||
}
|
||||
-176
@@ -1,176 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\WebsiteDrawBadges;
|
||||
|
||||
use App\Filament\Resources\Atom\WebsiteDrawBadges\Pages\EditWebsiteDrawBadge;
|
||||
use App\Filament\Resources\Atom\WebsiteDrawBadges\Pages\ListWebsiteDrawBadge;
|
||||
use App\Models\WebsiteDrawBadge;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class WebsiteDrawBadgeResource extends Resource
|
||||
{
|
||||
protected static ?string $model = WebsiteDrawBadge::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-trophy';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Website';
|
||||
|
||||
protected static ?string $slug = 'draw-badges';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'draw badges';
|
||||
|
||||
protected static ?string $navigationLabel = 'Draw Badges';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('badge_name')
|
||||
->label(__('Badge Name'))
|
||||
->nullable()
|
||||
->maxLength(24)
|
||||
->autocomplete(false),
|
||||
TextInput::make('badge_desc')
|
||||
->label(__('Badge Description'))
|
||||
->nullable()
|
||||
->maxLength(255)
|
||||
->autocomplete(false)
|
||||
->columnSpanFull(),
|
||||
Toggle::make('published')
|
||||
->label(__('Published'))
|
||||
->default(false),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('id', 'desc')
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label(__('ID'))
|
||||
->sortable(),
|
||||
TextColumn::make('user_id')
|
||||
->label(__('User ID')),
|
||||
TextColumn::make('user.username')
|
||||
->label(__('Username'))
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('badge_name')
|
||||
->limit(8)
|
||||
->label(__('Badge Name')),
|
||||
TextColumn::make('badge_desc')
|
||||
->label(__('Badge description'))
|
||||
->limit(35)
|
||||
->tooltip(function (TextColumn $column): ?string {
|
||||
$state = $column->getState();
|
||||
if (strlen($state) <= $column->getCharacterLimit()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $state;
|
||||
}),
|
||||
TextColumn::make('created_at')
|
||||
->label(__('Created At'))
|
||||
->dateTime(),
|
||||
ImageColumn::make('badge_url')
|
||||
->label(__('Badge'))
|
||||
->getStateUsing(fn ($record) => config('app.url') . $record->badge_url)
|
||||
->extraAttributes(['style' => 'image-rendering: pixelated'])
|
||||
->size(40),
|
||||
ToggleColumn::make('published')
|
||||
->label(__('Published')),
|
||||
])
|
||||
->recordActions([
|
||||
DeleteAction::make()
|
||||
->before(function (DeleteAction $action, WebsiteDrawBadge $record): void {
|
||||
$badgeCode = pathinfo($record->badge_path, PATHINFO_FILENAME);
|
||||
|
||||
// Remove the badge from any user before deleting it.
|
||||
if ($record->published) {
|
||||
DB::table('users_badges')
|
||||
->where('user_id', $record->user_id)
|
||||
->where('badge_code', $badgeCode)
|
||||
->delete();
|
||||
}
|
||||
|
||||
// Remove from JSON
|
||||
$filePath = DB::table('website_settings')->where('key', 'nitro_external_texts_file')->value('value');
|
||||
|
||||
if ($filePath && file_exists($filePath) && is_writable($filePath)) {
|
||||
$json = json_decode(file_get_contents($filePath), true);
|
||||
unset($json["badge_name_{$badgeCode}"]);
|
||||
unset($json["badge_desc_{$badgeCode}"]);
|
||||
file_put_contents($filePath, json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||
}
|
||||
|
||||
// Delete the badge file from the filesystem
|
||||
$badgePath = $record->badge_path;
|
||||
if ($badgePath && file_exists($badgePath)) {
|
||||
unlink($badgePath);
|
||||
}
|
||||
}),
|
||||
])
|
||||
->toolbarActions([
|
||||
DeleteBulkAction::make()
|
||||
->before(function (DeleteBulkAction $action, $records): void {
|
||||
foreach ($records as $record) {
|
||||
$badgeCode = pathinfo((string) $record->badge_path, PATHINFO_FILENAME);
|
||||
|
||||
// Remove the badge from any user before deleting it.
|
||||
if ($record->published) {
|
||||
DB::table('users_badges')
|
||||
->where('user_id', $record->user_id)
|
||||
->where('badge_code', $badgeCode)
|
||||
->delete();
|
||||
}
|
||||
|
||||
$filePath = DB::table('website_settings')->where('key', 'nitro_external_texts_file')->value('value');
|
||||
|
||||
if ($filePath && file_exists($filePath) && is_writable($filePath)) {
|
||||
$json = json_decode(file_get_contents($filePath), true);
|
||||
unset($json["badge_name_{$badgeCode}"]);
|
||||
unset($json["badge_desc_{$badgeCode}"]);
|
||||
file_put_contents($filePath, json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||
}
|
||||
|
||||
$badgePath = $record->badge_path;
|
||||
if ($badgePath && file_exists($badgePath)) {
|
||||
unlink($badgePath);
|
||||
}
|
||||
}
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListWebsiteDrawBadge::route('/'),
|
||||
'edit' => EditWebsiteDrawBadge::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function canCreate(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Atom\WriteableBoxResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Atom\WriteableBoxResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageWriteableBoxes extends ManageRecords
|
||||
{
|
||||
protected static string $resource = WriteableBoxResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DashboardResource\Widgets;
|
||||
|
||||
use App\Filament\Resources\Shop\ShopOrderResource;
|
||||
use App\Models\User\UserOrder;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Widgets\TableWidget as BaseWidget;
|
||||
|
||||
class LatestOrders extends BaseWidget
|
||||
{
|
||||
protected int|string|array $columnSpan = 'full';
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(UserOrder::latest())
|
||||
->paginated([3, 5, 8])
|
||||
->columns(ShopOrderResource::getTable())
|
||||
->recordActions([
|
||||
ViewAction::make()->schema(ShopOrderResource::getForm()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DashboardResource\Widgets;
|
||||
|
||||
use App\Models\User\UserOrder;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Flowframe\Trend\Trend;
|
||||
use Flowframe\Trend\TrendValue;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class OrdersAggregateChart extends ChartWidget
|
||||
{
|
||||
protected ?string $maxHeight = '300px';
|
||||
|
||||
protected string $color = 'secondary';
|
||||
|
||||
#[\Override]
|
||||
public function getHeading(): string|Htmlable|null
|
||||
{
|
||||
return __('filament::resources.stats.orders_chart.title');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getDescription(): string|Htmlable|null
|
||||
{
|
||||
return __('filament::resources.stats.orders_chart.description');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
protected function getData(): array
|
||||
{
|
||||
$pendingOrder = Trend::query(UserOrder::pending())
|
||||
->between(start: now()->startOfMonth(), end: now()->endOfMonth())
|
||||
->perDay()
|
||||
->count();
|
||||
|
||||
$cancelledOrder = Trend::query(UserOrder::cancelled())
|
||||
->between(start: now()->startOfMonth(), end: now()->endOfMonth())
|
||||
->perDay()
|
||||
->count();
|
||||
|
||||
$completedOrder = Trend::query(UserOrder::completed())
|
||||
->between(start: now()->startOfMonth(), end: now()->endOfMonth())
|
||||
->perDay()
|
||||
->count();
|
||||
|
||||
$datasets = [
|
||||
$this->getDataset($pendingOrder, __('filament::resources.stats.orders_chart.pending'), '#fbbf24', '#f59e0b'),
|
||||
$this->getDataset($cancelledOrder, __('filament::resources.stats.orders_chart.cancelled'), '#dc2626', '#b91c1c'),
|
||||
$this->getDataset($completedOrder, __('filament::resources.stats.orders_chart.completed'), '#10b981', '#059669'),
|
||||
];
|
||||
|
||||
$data = $pendingOrder->map(fn (TrendValue $value) => $value->date)->merge(
|
||||
$cancelledOrder->map(fn (TrendValue $value) => $value->date),
|
||||
)->merge(
|
||||
$completedOrder->map(fn (TrendValue $value) => $value->date),
|
||||
)->unique()->sort()->flatten();
|
||||
|
||||
return [
|
||||
'datasets' => $datasets,
|
||||
'labels' => $data,
|
||||
];
|
||||
}
|
||||
|
||||
protected function getDataset($data, $label, string $backgroundColor, string $borderColor): array
|
||||
{
|
||||
return [
|
||||
'label' => $label,
|
||||
'data' => $data->map(fn (TrendValue $value) => $value->aggregate),
|
||||
'backgroundColor' => $backgroundColor,
|
||||
'borderColor' => $borderColor,
|
||||
];
|
||||
}
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'bar';
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\Achievements;
|
||||
|
||||
use App\Enums\AchievementCategory;
|
||||
use App\Enums\CurrencyTypes;
|
||||
use App\Filament\Resources\Hotel\Achievements\Pages\CreateAchievement;
|
||||
use App\Filament\Resources\Hotel\Achievements\Pages\EditAchievement;
|
||||
use App\Filament\Resources\Hotel\Achievements\Pages\ListAchievements;
|
||||
use App\Filament\Resources\Hotel\Achievements\Pages\ViewAchievement;
|
||||
use App\Filament\Tables\Columns\HabboBadgeColumn;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\Achievement;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class AchievementResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static ?string $model = Achievement::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-academic-cap';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Hotel';
|
||||
|
||||
public static string $translateIdentifier = 'achievements';
|
||||
|
||||
protected static ?string $slug = 'hotel/achievements';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Tabs::make('Main')
|
||||
->tabs([
|
||||
Tab::make(__('filament::resources.tabs.Home'))
|
||||
->icon('heroicon-o-home')
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label(__('filament::resources.inputs.name'))
|
||||
->required()
|
||||
->maxLength(64)
|
||||
->autocomplete()
|
||||
->columnSpan('full'),
|
||||
|
||||
TextInput::make('level')
|
||||
->label(__('filament::resources.inputs.level'))
|
||||
->numeric()
|
||||
->required()
|
||||
->autocomplete()
|
||||
->columnSpan('full'),
|
||||
|
||||
Select::make('category')
|
||||
->native(false)
|
||||
->label(__('filament::resources.inputs.category'))
|
||||
->options(AchievementCategory::toInput()),
|
||||
]),
|
||||
|
||||
Tab::make(__('filament::resources.tabs.Configurations'))
|
||||
->icon('heroicon-o-cog')
|
||||
->schema([
|
||||
Select::make('visible')
|
||||
->native(false)
|
||||
->label(__('filament::resources.inputs.visible'))
|
||||
->options([
|
||||
'1' => __('filament::resources.common.Yes'),
|
||||
'0' => __('filament::resources.common.No'),
|
||||
]),
|
||||
|
||||
Select::make('reward_type')
|
||||
->native(false)
|
||||
->label(__('filament::resources.inputs.reward_type'))
|
||||
->options(CurrencyTypes::toInput()),
|
||||
|
||||
TextInput::make('reward_amount')
|
||||
->label(__('filament::resources.inputs.reward_amount'))
|
||||
->numeric()
|
||||
->required(),
|
||||
|
||||
TextInput::make('points')
|
||||
->label(__('filament::resources.inputs.points'))
|
||||
->helperText(__('filament::resources.helpers.achievement_points'))
|
||||
->numeric()
|
||||
->required(),
|
||||
|
||||
TextInput::make('progress_needed')
|
||||
->label(__('filament::resources.inputs.progress_needed'))
|
||||
->helperText(__('filament::resources.helpers.achievement_progress_needed'))
|
||||
->numeric()
|
||||
->required(),
|
||||
]),
|
||||
])->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('id', 'desc')
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label(__('filament::resources.columns.id')),
|
||||
|
||||
HabboBadgeColumn::make('badge')
|
||||
->label(__('filament::resources.columns.badge')),
|
||||
|
||||
TextColumn::make('name')
|
||||
->label(__('filament::resources.columns.name'))
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('level')
|
||||
->label(__('filament::resources.columns.level')),
|
||||
|
||||
TextColumn::make('category')
|
||||
->badge()
|
||||
->searchable()
|
||||
->label(__('filament::resources.columns.category'))
|
||||
->toggleable(),
|
||||
|
||||
ToggleColumn::make('visible')
|
||||
->label(__('filament::resources.columns.visible'))
|
||||
->disabled()
|
||||
->toggleable(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('visible')
|
||||
->options([
|
||||
'1' => __('filament::resources.common.Yes'),
|
||||
'0' => __('filament::resources.common.No'),
|
||||
])
|
||||
->label(__('filament::resources.columns.visible'))
|
||||
->placeholder(__('filament::resources.common.All')),
|
||||
|
||||
SelectFilter::make('category')
|
||||
->options(AchievementCategory::toInput())
|
||||
->label(__('filament::resources.columns.category'))
|
||||
->placeholder(__('filament::resources.common.All')),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListAchievements::route('/'),
|
||||
'create' => CreateAchievement::route('/create'),
|
||||
'view' => ViewAchievement::route('/{record}'),
|
||||
'edit' => EditAchievement::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\Achievements\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\Achievements\AchievementResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateAchievement extends CreateRecord
|
||||
{
|
||||
protected static string $resource = AchievementResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\Achievements\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\Achievements\AchievementResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditAchievement extends EditRecord
|
||||
{
|
||||
protected static string $resource = AchievementResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
// Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\Achievements\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\Achievements\AchievementResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListAchievements extends ListRecords
|
||||
{
|
||||
protected static string $resource = AchievementResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
// Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\Achievements\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\Achievements\AchievementResource;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewAchievement extends ViewRecord
|
||||
{
|
||||
protected static string $resource = AchievementResource::class;
|
||||
}
|
||||
-101
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\BadgeTextEditors;
|
||||
|
||||
use App\Filament\Resources\Hotel\BadgeTextEditors\Pages\CreateBadgeTextEditor;
|
||||
use App\Filament\Resources\Hotel\BadgeTextEditors\Pages\EditBadgeTextEditor;
|
||||
use App\Filament\Resources\Hotel\BadgeTextEditors\Pages\ListBadgeTextEditors;
|
||||
use App\Models\WebsiteBadge;
|
||||
use App\Services\SettingsService;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class BadgeTextEditorResource extends Resource
|
||||
{
|
||||
protected static ?string $model = WebsiteBadge::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Hotel';
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-pencil-square';
|
||||
|
||||
protected static ?string $navigationLabel = 'Badge Editor';
|
||||
|
||||
protected static ?string $modelLabel = 'Badge Text';
|
||||
|
||||
protected static ?string $slug = 'hotel/badge-text-editor';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('badge_key')
|
||||
->required()
|
||||
->label('Badge Key - Expl. ATOM101')
|
||||
->placeholder('This is the badge code'),
|
||||
TextInput::make('badge_name')
|
||||
->required()
|
||||
->label('Badge Name')
|
||||
->placeholder('This is the name of the badge: Expl. The ATOM Badge'),
|
||||
Textarea::make('badge_description')
|
||||
->required()
|
||||
->label('Badge Description')
|
||||
->placeholder('Please add a description for the badge.'),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
$settingsService = app(SettingsService::class);
|
||||
$badgesPath = $settingsService->getOrDefault('badges_path', '/gamedata/c_images/album1584/');
|
||||
|
||||
return $table
|
||||
->columns([
|
||||
ImageColumn::make('badge_key')
|
||||
->label('Badge Image')
|
||||
->getStateUsing(function ($record) use ($badgesPath) {
|
||||
$badgeName = str_replace('badge_desc_', '', $record->badge_key);
|
||||
|
||||
return asset($badgesPath . $badgeName . '.gif');
|
||||
})
|
||||
->width(50)
|
||||
->height(50),
|
||||
TextColumn::make('badge_name')
|
||||
->label('Badge Code & Name')
|
||||
->formatStateUsing(fn ($record) => $record->badge_key . ' : ' . $record->badge_name)
|
||||
->searchable(query: function ($query, $search): void {
|
||||
$query->where('badge_key', 'like', "%{$search}%")
|
||||
->orWhere('badge_name', 'like', "%{$search}%");
|
||||
})
|
||||
->sortable(),
|
||||
TextColumn::make('badge_description')
|
||||
->label('Badge Description')
|
||||
->getStateUsing(fn ($record) => Str::limit($record->badge_description, 65))
|
||||
->searchable(),
|
||||
])
|
||||
->filters([])
|
||||
->defaultSort('badge_key', 'asc')
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListBadgeTextEditors::route('/'),
|
||||
'create' => CreateBadgeTextEditor::route('/create'),
|
||||
'edit' => EditBadgeTextEditor::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\BadgeTextEditors\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\BadgeTextEditors\BadgeTextEditorResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateBadgeTextEditor extends CreateRecord
|
||||
{
|
||||
protected static string $resource = BadgeTextEditorResource::class;
|
||||
}
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\BadgeTextEditors\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\BadgeTextEditors\BadgeTextEditorResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use PDOException;
|
||||
|
||||
class EditBadgeTextEditor extends EditRecord
|
||||
{
|
||||
protected static string $resource = BadgeTextEditorResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [DeleteAction::make()];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function afterSave(): void {}
|
||||
|
||||
#[\Override]
|
||||
protected function handleRecordUpdate(Model $record, array $data): Model
|
||||
{
|
||||
try {
|
||||
return parent::handleRecordUpdate($record, $data);
|
||||
} catch (PDOException $e) {
|
||||
if ($e->getCode() === '23000') {
|
||||
Log::error('Duplicate badge key error: ' . $e->getMessage());
|
||||
|
||||
Notification::make()
|
||||
->title('Duplicate Badge Key')
|
||||
->body('The badge key already exists. Please use a unique badge key.')
|
||||
->danger()
|
||||
->persistent()
|
||||
->send();
|
||||
|
||||
return $record;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
-153
@@ -1,153 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\BadgeTextEditors\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\BadgeTextEditors\BadgeTextEditorResource;
|
||||
use App\Models\WebsiteBadge;
|
||||
use App\Services\SettingsService;
|
||||
use Exception;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ListBadgeTextEditors extends ListRecords
|
||||
{
|
||||
protected static string $resource = BadgeTextEditorResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make()
|
||||
->label('Add Badge')
|
||||
->color('info')
|
||||
->modalHeading('Add a New Badge')
|
||||
->modalButton('Create Badge')
|
||||
->after(function (): void {
|
||||
Notification::make()
|
||||
->title('Badge Created')
|
||||
->body('The badge was successfully created.')
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
Action::make('export')
|
||||
->label('Export to ExternalTexts')
|
||||
->action('exportToJson'),
|
||||
Action::make('backup')
|
||||
->label('Create Backup of ExternalTexts')
|
||||
->color('success')
|
||||
->action('createBackup'),
|
||||
];
|
||||
}
|
||||
|
||||
public function exportToJson(SettingsService $settingsService)
|
||||
{
|
||||
$jsonPath = $settingsService->getOrDefault('nitro_external_texts_file');
|
||||
|
||||
if ($jsonPath === '' || $jsonPath === '0') {
|
||||
Notification::make()
|
||||
->title('Export Failed')
|
||||
->body('The JSON file path is not configured in the website settings.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! file_exists($jsonPath)) {
|
||||
Notification::make()
|
||||
->title('Export Failed')
|
||||
->body('The JSON file does not exist at the specified path.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$jsonData = json_decode(file_get_contents($jsonPath), true);
|
||||
|
||||
$badges = WebsiteBadge::all();
|
||||
$badgeKeys = $badges->pluck('badge_key')->toArray();
|
||||
|
||||
foreach ($jsonData as $key => $value) {
|
||||
if (
|
||||
(str_starts_with((string) $key, 'badge_desc_') || str_starts_with((string) $key, 'badge_name_')) &&
|
||||
! in_array(str_replace(['badge_desc_', 'badge_name_'], '', $key), $badgeKeys)
|
||||
) {
|
||||
unset($jsonData[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($badges as $badge) {
|
||||
$jsonData['badge_desc_' . $badge->badge_key] = $badge->badge_description;
|
||||
$jsonData['badge_name_' . $badge->badge_key] = $badge->badge_name;
|
||||
}
|
||||
|
||||
try {
|
||||
$result = file_put_contents(
|
||||
$jsonPath,
|
||||
json_encode($jsonData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||
);
|
||||
|
||||
if ($result === false) {
|
||||
throw new Exception('Failed to write to the JSON file.');
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Export Successful')
|
||||
->body('Badge data exported successfully.')
|
||||
->success()
|
||||
->send();
|
||||
} catch (Exception $e) {
|
||||
Log::error('Failed to export badge data: ' . $e->getMessage());
|
||||
|
||||
Notification::make()
|
||||
->title('Export Failed')
|
||||
->body('Failed to export badge data. Please check file permissions or contact your administrator.')
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
public function createBackup(SettingsService $settingsService)
|
||||
{
|
||||
$jsonPath = $settingsService->getOrDefault('nitro_external_texts_file');
|
||||
|
||||
if ($jsonPath === '' || $jsonPath === '0') {
|
||||
Notification::make()
|
||||
->title('Backup Failed')
|
||||
->body('The JSON file path is not configured in the website settings.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! file_exists($jsonPath)) {
|
||||
Notification::make()
|
||||
->title('Backup Failed')
|
||||
->body('The JSON file does not exist at the specified path.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$backupPath = dirname($jsonPath) . '/ExternalTexts_' . time() . '.json';
|
||||
|
||||
if (copy($jsonPath, $backupPath)) {
|
||||
Notification::make()
|
||||
->title('Backup Successful')
|
||||
->body('A backup of the JSON file has been created: ' . basename($backupPath))
|
||||
->success()
|
||||
->send();
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('Backup Failed')
|
||||
->body('Failed to create a backup of the JSON file.')
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\BadgeUploads;
|
||||
|
||||
use App\Filament\Resources\Hotel\BadgeUploads\Pages\ManageBadgeUploads;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
|
||||
class BadgeUploadResource extends Resource
|
||||
{
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Hotel';
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-gif';
|
||||
|
||||
protected static ?string $label = 'Badge Upload';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
FileUpload::make('badge_file')
|
||||
->label('Upload Badge')
|
||||
->disk('local')
|
||||
->directory(setting('badge_path_filesystem'))
|
||||
->required()
|
||||
->getUploadedFileNameForStorageUsing(
|
||||
fn (TemporaryUploadedFile $file): string => strtolower(str_replace([' ', '-', 'æ', 'ø', 'å'], ['_', '_', 'ae', 'oe', 'aa'], $file->getClientOriginalName())),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('filename')
|
||||
->label('File Name')
|
||||
->sortable(),
|
||||
TextColumn::make('path')
|
||||
->label('File Path'),
|
||||
])
|
||||
->filters([]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ManageBadgeUploads::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getFiles(): array
|
||||
{
|
||||
$badgePath = env('BadgePath', 'badges');
|
||||
$files = Storage::disk('local')->files($badgePath);
|
||||
|
||||
return collect($files)->map(fn ($file) => [
|
||||
'filename' => basename($file),
|
||||
'path' => $file,
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\BadgeUploads\Pages;
|
||||
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\Page; // Import the Notification class
|
||||
|
||||
class ManageBadgeUploads extends Page implements HasForms
|
||||
{
|
||||
use InteractsWithForms;
|
||||
|
||||
public $badge_file;
|
||||
|
||||
protected static string $resource = \App\Filament\Resources\Hotel\BadgeUploads\BadgeUploadResource::class;
|
||||
|
||||
protected string $view = 'filament.pages.manage-badge-uploads';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->form->fill([]);
|
||||
}
|
||||
|
||||
protected function getFormSchema(): array
|
||||
{
|
||||
return [
|
||||
FileUpload::make('badge_file')
|
||||
->label('Upload Badge')
|
||||
->disk('badges')
|
||||
->preserveFilenames()
|
||||
->acceptedFileTypes(['image/gif'])
|
||||
->rules(['mimes:gif'])
|
||||
->required(),
|
||||
];
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$this->form->getState();
|
||||
|
||||
Notification::make()
|
||||
->title('Badge uploaded successfully!')
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\CatalogPages;
|
||||
|
||||
use App\Filament\Resources\Hotel\CatalogPages\Pages\CreateCatalogPage;
|
||||
use App\Filament\Resources\Hotel\CatalogPages\Pages\EditCatalogPage;
|
||||
use App\Filament\Resources\Hotel\CatalogPages\Pages\ListCatalogPages;
|
||||
use App\Filament\Resources\Hotel\CatalogPages\RelationManagers\CatalogItemsRelationManager;
|
||||
use App\Models\Game\Furniture\CatalogPage;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CatalogPageResource extends Resource
|
||||
{
|
||||
protected static ?string $model = CatalogPage::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Hotel';
|
||||
|
||||
public static string $translateIdentifier = 'catalog-pages';
|
||||
|
||||
protected static ?string $slug = 'hotel/catalog-pages';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('parent_id')
|
||||
->required()
|
||||
->integer(),
|
||||
|
||||
TextInput::make('caption_save')
|
||||
->required(),
|
||||
|
||||
TextInput::make('caption')
|
||||
->required(),
|
||||
|
||||
TextInput::make('page_layout')
|
||||
->required(),
|
||||
|
||||
TextInput::make('icon_color')
|
||||
->required()
|
||||
->integer(),
|
||||
|
||||
TextInput::make('icon_image')
|
||||
->required()
|
||||
->integer(),
|
||||
|
||||
TextInput::make('min_rank')
|
||||
->required()
|
||||
->integer(),
|
||||
|
||||
TextInput::make('order_num')
|
||||
->required()
|
||||
->integer(),
|
||||
|
||||
TextInput::make('visible')
|
||||
->required(),
|
||||
|
||||
TextInput::make('enabled')
|
||||
->required(),
|
||||
|
||||
TextInput::make('club_only')
|
||||
->required(),
|
||||
|
||||
TextInput::make('vip_only')
|
||||
->required(),
|
||||
|
||||
TextInput::make('page_headline')
|
||||
->required(),
|
||||
|
||||
TextInput::make('page_teaser')
|
||||
->required(),
|
||||
|
||||
TextInput::make('page_special'),
|
||||
|
||||
TextInput::make('page_text1'),
|
||||
|
||||
TextInput::make('page_text2'),
|
||||
|
||||
TextInput::make('page_text_details'),
|
||||
|
||||
TextInput::make('page_text_teaser'),
|
||||
|
||||
TextInput::make('room_id')
|
||||
->integer(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('parent_id'),
|
||||
|
||||
TextColumn::make('caption_save'),
|
||||
|
||||
TextColumn::make('caption')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('page_layout'),
|
||||
|
||||
TextColumn::make('icon_color'),
|
||||
|
||||
ImageColumn::make('icon_image'),
|
||||
|
||||
TextColumn::make('min_rank'),
|
||||
|
||||
TextColumn::make('order_num'),
|
||||
|
||||
TextColumn::make('visible'),
|
||||
|
||||
TextColumn::make('enabled'),
|
||||
|
||||
TextColumn::make('club_only'),
|
||||
|
||||
TextColumn::make('vip_only'),
|
||||
|
||||
TextColumn::make('page_headline'),
|
||||
|
||||
TextColumn::make('page_teaser'),
|
||||
|
||||
TextColumn::make('page_special'),
|
||||
|
||||
TextColumn::make('page_text1'),
|
||||
|
||||
TextColumn::make('page_text2'),
|
||||
|
||||
TextColumn::make('room_id'),
|
||||
|
||||
TextColumn::make('includes'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListCatalogPages::route('/'),
|
||||
'create' => CreateCatalogPage::route('/create'),
|
||||
'edit' => EditCatalogPage::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
CatalogItemsRelationManager::class,
|
||||
];
|
||||
}
|
||||
|
||||
public static function getGloballySearchableAttributes(): array
|
||||
{
|
||||
return ['caption'];
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\CatalogPages\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\CatalogPages\CatalogPageResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCatalogPage extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CatalogPageResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\CatalogPages\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\CatalogPages\CatalogPageResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCatalogPage extends EditRecord
|
||||
{
|
||||
protected static string $resource = CatalogPageResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\CatalogPages\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\CatalogPages\CatalogPageResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCatalogPages extends ListRecords
|
||||
{
|
||||
protected static string $resource = CatalogPageResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-467
@@ -1,467 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\CatalogPages\RelationManagers;
|
||||
|
||||
use App\Models\Game\Furniture\ItemBase;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Filters\TernaryFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CatalogItemsRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'catalogItems';
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('item_ids')
|
||||
->label('Furniture Item')
|
||||
->relationship(
|
||||
name: 'itemBase',
|
||||
titleAttribute: 'item_name',
|
||||
modifyQueryUsing: fn (Builder $query) => $query->orderBy('item_name'),
|
||||
)
|
||||
->searchable()
|
||||
->required()
|
||||
->preload()
|
||||
->createOptionForm([
|
||||
TextInput::make('sprite_id')
|
||||
->label('Sprite ID')
|
||||
->numeric()
|
||||
->default(0),
|
||||
TextInput::make('public_name')
|
||||
->maxLength(56),
|
||||
TextInput::make('item_name')
|
||||
->required()
|
||||
->maxLength(70),
|
||||
TextInput::make('type')
|
||||
->default('s')
|
||||
->maxLength(3),
|
||||
Grid::make(3)
|
||||
->schema([
|
||||
TextInput::make('width')
|
||||
->numeric()
|
||||
->default(1),
|
||||
TextInput::make('length')
|
||||
->numeric()
|
||||
->default(1),
|
||||
TextInput::make('stack_height')
|
||||
->numeric()
|
||||
->default(0.00),
|
||||
]),
|
||||
Grid::make(3)
|
||||
->schema([
|
||||
Toggle::make('allow_stack')
|
||||
->default(true),
|
||||
Toggle::make('allow_sit')
|
||||
->default(false),
|
||||
Toggle::make('allow_lay')
|
||||
->default(false),
|
||||
]),
|
||||
Grid::make(3)
|
||||
->schema([
|
||||
Toggle::make('allow_walk')
|
||||
->default(false),
|
||||
Toggle::make('allow_gift')
|
||||
->default(true),
|
||||
Toggle::make('allow_trade')
|
||||
->default(true),
|
||||
]),
|
||||
Grid::make(3)
|
||||
->schema([
|
||||
Toggle::make('allow_recycle')
|
||||
->default(false),
|
||||
Toggle::make('allow_marketplace_sell')
|
||||
->default(false),
|
||||
Toggle::make('allow_inventory_stack')
|
||||
->default(true),
|
||||
]),
|
||||
TextInput::make('interaction_type')
|
||||
->default('default')
|
||||
->maxLength(500),
|
||||
Grid::make(2)
|
||||
->schema([
|
||||
TextInput::make('interaction_modes_count')
|
||||
->numeric()
|
||||
->default(1),
|
||||
TextInput::make('vending_ids')
|
||||
->default('0')
|
||||
->maxLength(255),
|
||||
]),
|
||||
Grid::make(2)
|
||||
->schema([
|
||||
TextInput::make('multiheight')
|
||||
->default('0')
|
||||
->maxLength(50),
|
||||
TextInput::make('customparams')
|
||||
->maxLength(256),
|
||||
]),
|
||||
Grid::make(2)
|
||||
->schema([
|
||||
TextInput::make('effect_id_male')
|
||||
->numeric()
|
||||
->default(0),
|
||||
TextInput::make('effect_id_female')
|
||||
->numeric()
|
||||
->default(0),
|
||||
]),
|
||||
TextInput::make('clothing_on_walk')
|
||||
->maxLength(255),
|
||||
])
|
||||
->columnSpanFull(),
|
||||
|
||||
TextInput::make('catalog_name')
|
||||
->label('Catalog Name')
|
||||
->required()
|
||||
->maxLength(100)
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
|
||||
Grid::make(2)
|
||||
->schema([
|
||||
TextInput::make('cost_credits')
|
||||
->label('Cost Credits')
|
||||
->numeric()
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? '')
|
||||
->default(3),
|
||||
|
||||
TextInput::make('cost_points')
|
||||
->label('Cost Points')
|
||||
->numeric()
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? '')
|
||||
->default(0),
|
||||
]),
|
||||
|
||||
Grid::make(2)
|
||||
->schema([
|
||||
TextInput::make('points_type')
|
||||
->label('Points Type')
|
||||
->numeric()
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? '')
|
||||
->default(0),
|
||||
|
||||
TextInput::make('amount')
|
||||
->label('Amount')
|
||||
->numeric()
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? '')
|
||||
->default(1),
|
||||
]),
|
||||
|
||||
Grid::make(2)
|
||||
->schema([
|
||||
Toggle::make('limited_stack')
|
||||
->label('Limited Stack')
|
||||
->dehydrateStateUsing(fn ($state) => $state ? '1' : '0'),
|
||||
|
||||
Toggle::make('limited_sells')
|
||||
->label('Limited Sells')
|
||||
->dehydrateStateUsing(fn ($state) => $state ? '1' : '0'),
|
||||
]),
|
||||
|
||||
Grid::make(3)
|
||||
->schema([
|
||||
TextInput::make('order_number')
|
||||
->numeric()
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? '')
|
||||
->default(1),
|
||||
|
||||
TextInput::make('offer_id')
|
||||
->numeric()
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
|
||||
TextInput::make('song_id')
|
||||
->numeric()
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? '')
|
||||
->default(0),
|
||||
]),
|
||||
|
||||
Textarea::make('extradata')
|
||||
->label('Extra Data')
|
||||
->maxLength(500)
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
|
||||
Grid::make(2)
|
||||
->schema([
|
||||
Toggle::make('have_offer')
|
||||
->label('Have Offer')
|
||||
->default(true)
|
||||
->dehydrateStateUsing(fn ($state) => $state ? '1' : '0'),
|
||||
|
||||
Toggle::make('club_only')
|
||||
->label('Club Only')
|
||||
->default(false)
|
||||
->dehydrateStateUsing(fn ($state) => $state ? '1' : '0'),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('catalog_name')
|
||||
->columns([
|
||||
ImageColumn::make('icon')
|
||||
->getStateUsing(fn ($record) => url($record->itemBase?->icon()))
|
||||
->size('25px')
|
||||
|
||||
->label('Icon')
|
||||
->circular(),
|
||||
|
||||
TextColumn::make('itemBase.item_name')
|
||||
->label('Furniture Name')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('catalog_name')
|
||||
->label('Catalog Name')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('cost_credits')
|
||||
->label('Credits')
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('cost_points')
|
||||
->label('Points')
|
||||
->sortable(),
|
||||
|
||||
IconColumn::make('limited_stack')
|
||||
->label('Limited')
|
||||
->boolean(),
|
||||
|
||||
IconColumn::make('club_only')
|
||||
->label('HC Only')
|
||||
->boolean(),
|
||||
|
||||
TextColumn::make('itemBase.type')
|
||||
->label('Type')
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
TextColumn::make('itemBase.width')
|
||||
->label('Width')
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
TextColumn::make('itemBase.length')
|
||||
->label('Length')
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
TextColumn::make('order_number')
|
||||
->label('Order')
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('type')
|
||||
->query(fn (Builder $query, array $data): Builder => empty($data['values'])
|
||||
? $query
|
||||
: $query->whereHas('itemBase', function (Builder $query) use ($data): void {
|
||||
$query->whereIn('type', $data['values']);
|
||||
}))
|
||||
->options(
|
||||
fn () => ItemBase::query()
|
||||
->select('type')
|
||||
->distinct()
|
||||
->orderBy('type')
|
||||
->pluck('type', 'type')
|
||||
->toArray(),
|
||||
)
|
||||
->multiple()
|
||||
->searchable()
|
||||
->preload(),
|
||||
|
||||
TernaryFilter::make('club_only')
|
||||
->label('HC Only'),
|
||||
|
||||
TernaryFilter::make('limited_stack')
|
||||
->label('Limited'),
|
||||
])
|
||||
->defaultSort('order_number')
|
||||
->headerActions([
|
||||
CreateAction::make(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->label('Edit Catalog Item'),
|
||||
|
||||
Action::make('editItemBase')
|
||||
->label('Edit Item base')
|
||||
->icon('heroicon-m-cube')
|
||||
->modalWidth('3xl')
|
||||
->modalHeading('Edit Item Base')
|
||||
->fillForm(function ($record) {
|
||||
$itemBase = $record->itemBase;
|
||||
if (! $itemBase) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
'sprite_id' => $itemBase->sprite_id,
|
||||
'public_name' => $itemBase->public_name,
|
||||
'item_name' => $itemBase->item_name,
|
||||
'type' => $itemBase->type,
|
||||
'width' => $itemBase->width,
|
||||
'length' => $itemBase->length,
|
||||
'stack_height' => $itemBase->stack_height,
|
||||
'allow_stack' => $itemBase->allow_stack,
|
||||
'allow_sit' => $itemBase->allow_sit,
|
||||
'allow_lay' => $itemBase->allow_lay,
|
||||
'allow_walk' => $itemBase->allow_walk,
|
||||
'allow_gift' => $itemBase->allow_gift,
|
||||
'allow_trade' => $itemBase->allow_trade,
|
||||
'allow_recycle' => $itemBase->allow_recycle,
|
||||
'allow_marketplace_sell' => $itemBase->allow_marketplace_sell,
|
||||
'allow_inventory_stack' => $itemBase->allow_inventory_stack,
|
||||
'interaction_type' => $itemBase->interaction_type,
|
||||
'interaction_modes_count' => $itemBase->interaction_modes_count,
|
||||
'vending_ids' => $itemBase->vending_ids,
|
||||
'multiheight' => $itemBase->multiheight,
|
||||
'customparams' => $itemBase->customparams,
|
||||
'effect_id_male' => $itemBase->effect_id_male,
|
||||
'effect_id_female' => $itemBase->effect_id_female,
|
||||
'clothing_on_walk' => $itemBase->clothing_on_walk,
|
||||
];
|
||||
})
|
||||
->schema([
|
||||
TextInput::make('sprite_id')
|
||||
->label('Sprite ID')
|
||||
->numeric()
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
TextInput::make('public_name')
|
||||
->label('Public Name')
|
||||
->maxLength(56)
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
TextInput::make('item_name')
|
||||
->label('Item Name')
|
||||
->required()
|
||||
->maxLength(70),
|
||||
TextInput::make('type')
|
||||
->maxLength(3)
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
Grid::make(3)
|
||||
->schema([
|
||||
TextInput::make('width')
|
||||
->numeric()
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
TextInput::make('length')
|
||||
->numeric()
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
TextInput::make('stack_height')
|
||||
->numeric()
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
]),
|
||||
Grid::make(3)
|
||||
->schema([
|
||||
Toggle::make('allow_stack'),
|
||||
Toggle::make('allow_sit'),
|
||||
Toggle::make('allow_lay'),
|
||||
]),
|
||||
Grid::make(3)
|
||||
->schema([
|
||||
Toggle::make('allow_walk'),
|
||||
Toggle::make('allow_gift'),
|
||||
Toggle::make('allow_trade'),
|
||||
]),
|
||||
Grid::make(3)
|
||||
->schema([
|
||||
Toggle::make('allow_recycle'),
|
||||
Toggle::make('allow_marketplace_sell'),
|
||||
Toggle::make('allow_inventory_stack'),
|
||||
]),
|
||||
TextInput::make('interaction_type')
|
||||
->maxLength(500)
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
Grid::make(2)
|
||||
->schema([
|
||||
TextInput::make('interaction_modes_count')
|
||||
->numeric()
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
TextInput::make('vending_ids')
|
||||
->maxLength(255)
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
]),
|
||||
Grid::make(2)
|
||||
->schema([
|
||||
TextInput::make('multiheight')
|
||||
->maxLength(50)
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
TextInput::make('customparams')
|
||||
->maxLength(256)
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
]),
|
||||
Grid::make(2)
|
||||
->schema([
|
||||
TextInput::make('effect_id_male')
|
||||
->numeric()
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
TextInput::make('effect_id_female')
|
||||
->numeric()
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
]),
|
||||
TextInput::make('clothing_on_walk')
|
||||
->maxLength(255)
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ?? ''),
|
||||
])
|
||||
->action(function (array $data, $record): void {
|
||||
// Transform any null or empty values to empty strings
|
||||
$data = collect($data)->map(function ($value) {
|
||||
if ($value === null || $value === '') {
|
||||
return '';
|
||||
}
|
||||
if (is_bool($value)) {
|
||||
return $value ? '1' : '0';
|
||||
}
|
||||
|
||||
return $value;
|
||||
})->toArray();
|
||||
|
||||
$record->itemBase->forceFill($data)->save();
|
||||
})
|
||||
->visible(fn ($record) => $record->itemBase !== null),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\ChatlogPrivates;
|
||||
|
||||
use App\Filament\Resources\Hotel\ChatlogPrivates\Pages\ManageChatlogPrivates;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\ChatlogPrivate;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ChatlogPrivateResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static ?string $model = ChatlogPrivate::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-chat-bubble-left-right';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Logs';
|
||||
|
||||
public static string $translateIdentifier = 'chatlog-private';
|
||||
|
||||
protected static ?string $slug = 'hotel/chatlog-private';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('sender')
|
||||
->disabled()
|
||||
->formatStateUsing(fn ($record) => $record->sender?->username)
|
||||
->label(__('filament::resources.inputs.sender')),
|
||||
|
||||
TextInput::make('receiver')
|
||||
->disabled()
|
||||
->formatStateUsing(fn ($record) => $record->receiver?->username)
|
||||
->label(__('filament::resources.inputs.receiver')),
|
||||
|
||||
Textarea::make('message')
|
||||
->label(__('filament::resources.inputs.message'))
|
||||
->columnSpanFull()
|
||||
->disabled(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('timestamp', 'desc')
|
||||
->columns(self::getTable())
|
||||
->filters([])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
])
|
||||
->toolbarActions([]);
|
||||
}
|
||||
|
||||
public static function getTable(): array
|
||||
{
|
||||
return [
|
||||
TextColumn::make('sender.username')
|
||||
->label(__('filament::resources.columns.sender'))
|
||||
->toggleable()
|
||||
->searchable(isIndividual: true),
|
||||
|
||||
TextColumn::make('receiver.username')
|
||||
->label(__('filament::resources.columns.receiver'))
|
||||
->toggleable()
|
||||
->searchable(isIndividual: true),
|
||||
|
||||
TextColumn::make('message')
|
||||
->label(__('filament::resources.columns.message'))
|
||||
->limit(40)
|
||||
->searchable(isIndividual: true),
|
||||
|
||||
TextColumn::make('timestamp')
|
||||
->label(__('filament::resources.columns.executed_at'))
|
||||
->dateTime('Y-m-d H:i')
|
||||
->toggleable(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ManageChatlogPrivates::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\ChatlogPrivates\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\ChatlogPrivates\ChatlogPrivateResource;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageChatlogPrivates extends ManageRecords
|
||||
{
|
||||
protected static string $resource = ChatlogPrivateResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\ChatlogRooms;
|
||||
|
||||
use App\Filament\Resources\Hotel\ChatlogRooms\Pages\ManageChatlogRooms;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\ChatlogRoom;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ChatlogRoomResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static ?string $model = ChatlogRoom::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-chat-bubble-left-right';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Logs';
|
||||
|
||||
public static string $translateIdentifier = 'chatlog-rooms';
|
||||
|
||||
protected static ?string $slug = 'hotel/chatlog-room';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('room')
|
||||
->label(__('filament::resources.inputs.room'))
|
||||
->formatStateUsing(fn ($record) => $record->room?->name)
|
||||
->columnSpanFull()
|
||||
->disabled(),
|
||||
|
||||
TextInput::make('sender')
|
||||
->label(__('filament::resources.inputs.sender'))
|
||||
->formatStateUsing(fn ($record) => $record->sender?->username)
|
||||
->disabled(),
|
||||
|
||||
TextInput::make('receiver')
|
||||
->label(__('filament::resources.inputs.receiver'))
|
||||
->formatStateUsing(fn ($record) => $record->receiver?->username)
|
||||
->disabled(),
|
||||
|
||||
Textarea::make('message')
|
||||
->label(__('filament::resources.inputs.message'))
|
||||
->columnSpanFull()
|
||||
->disabled(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('timestamp', 'desc')
|
||||
->columns(self::getTable())
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
])
|
||||
->toolbarActions([]);
|
||||
}
|
||||
|
||||
public static function getTable(): array
|
||||
{
|
||||
return [
|
||||
TextColumn::make('room.name')
|
||||
->label(__('filament::resources.columns.room'))
|
||||
->toggleable()
|
||||
->searchable(isIndividual: true),
|
||||
|
||||
TextColumn::make('sender.username')
|
||||
->label(__('filament::resources.columns.sender'))
|
||||
->toggleable()
|
||||
->searchable(isIndividual: true),
|
||||
|
||||
TextColumn::make('receiver.username')
|
||||
->label(__('filament::resources.columns.receiver'))
|
||||
->toggleable()
|
||||
->searchable(isIndividual: true),
|
||||
|
||||
TextColumn::make('message')
|
||||
->label(__('filament::resources.columns.message'))
|
||||
->limit(40)
|
||||
->searchable(isIndividual: true),
|
||||
|
||||
TextColumn::make('timestamp')
|
||||
->label(__('filament::resources.columns.executed_at'))
|
||||
->dateTime('Y-m-d H:i')
|
||||
->toggleable(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ManageChatlogRooms::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\ChatlogRooms\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\ChatlogRooms\ChatlogRoomResource;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageChatlogRooms extends ManageRecords
|
||||
{
|
||||
protected static string $resource = ChatlogRoomResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\CommandLogs;
|
||||
|
||||
use App\Filament\Resources\Hotel\CommandLogs\Pages\ManageCommandLogs;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\CommandLog;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CommandLogResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static ?string $model = CommandLog::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-chat-bubble-bottom-center-text';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Logs';
|
||||
|
||||
public static string $translateIdentifier = 'command-logs';
|
||||
|
||||
protected static ?string $slug = 'logs/commands';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('timestamp', 'desc')
|
||||
->columns([
|
||||
TextColumn::make('user.username')
|
||||
->label(__('filament::resources.columns.username'))
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('command')
|
||||
->label(__('filament::resources.columns.command'))
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('succes')
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'yes' => 'primary',
|
||||
'no' => 'warning'
|
||||
})
|
||||
->label(__('filament::resources.columns.success'))
|
||||
->formatStateUsing(fn (string $state): string => __("filament::resources.options.{$state}")),
|
||||
|
||||
TextColumn::make('timestamp')
|
||||
->label(__('filament::resources.columns.executed_at'))
|
||||
->dateTime('Y-m-d H:i')
|
||||
->searchable(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('succes')
|
||||
->label(__('filament::resources.filters.success'))
|
||||
->options([
|
||||
'yes' => __('filament::resources.options.yes'),
|
||||
'no' => __('filament::resources.options.no'),
|
||||
]),
|
||||
])
|
||||
->recordActions([])
|
||||
->toolbarActions([]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ManageCommandLogs::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\CommandLogs\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\CommandLogs\CommandLogResource;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageCommandLogs extends ManageRecords
|
||||
{
|
||||
protected static string $resource = CommandLogResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getPrimaryKey(): string
|
||||
{
|
||||
return 'timestamp';
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class CustomQueryBuilder extends Builder
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// Call the parent constructor with a dummy query
|
||||
parent::__construct(app('db')->query());
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function get($columns = ['*']): Collection
|
||||
{
|
||||
return collect(); // Return an empty collection
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\EmulatorSettings;
|
||||
|
||||
use App\Filament\Resources\Hotel\EmulatorSettings\Pages\CreateEmulatorSetting;
|
||||
use App\Filament\Resources\Hotel\EmulatorSettings\Pages\EditEmulatorSetting;
|
||||
use App\Filament\Resources\Hotel\EmulatorSettings\Pages\ListEmulatorSettings;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\EmulatorSetting;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class EmulatorSettingResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static ?string $model = EmulatorSetting::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-adjustments-horizontal';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Hotel';
|
||||
|
||||
public static string $translateIdentifier = 'emulator-settings';
|
||||
|
||||
protected static ?string $slug = 'hotel/emulator-settings';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make()
|
||||
->schema([
|
||||
TextInput::make('key')
|
||||
->label(__('filament::resources.inputs.key'))
|
||||
->required()
|
||||
->maxLength(100)
|
||||
->unique(ignoreRecord: true),
|
||||
|
||||
TextInput::make('value')
|
||||
->label(__('filament::resources.inputs.value'))
|
||||
->required()
|
||||
->maxLength(512),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('key')
|
||||
->label(__('filament::resources.columns.key'))
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('value')
|
||||
->label(__('filament::resources.columns.value'))
|
||||
->searchable(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListEmulatorSettings::route('/'),
|
||||
'create' => CreateEmulatorSetting::route('/create'),
|
||||
'edit' => EditEmulatorSetting::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\EmulatorSettings\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\EmulatorSettings\EmulatorSettingResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateEmulatorSetting extends CreateRecord
|
||||
{
|
||||
protected static string $resource = EmulatorSettingResource::class;
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\EmulatorSettings\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\EmulatorSettings\EmulatorSettingResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditEmulatorSetting extends EditRecord
|
||||
{
|
||||
protected static string $resource = EmulatorSettingResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\EmulatorSettings\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\EmulatorSettings\EmulatorSettingResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListEmulatorSettings extends ListRecords
|
||||
{
|
||||
protected static string $resource = EmulatorSettingResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\EmulatorTexts;
|
||||
|
||||
use App\Filament\Resources\Hotel\EmulatorTexts\Pages\ManageEmulatorTexts;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\EmulatorText;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class EmulatorTextResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static ?string $model = EmulatorText::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-clipboard-document-list';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Hotel';
|
||||
|
||||
protected static ?string $slug = 'hotel/emulator-texts';
|
||||
|
||||
public static string $translateIdentifier = 'emulator-texts';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('key')
|
||||
->label(__('filament::resources.inputs.key'))
|
||||
->required()
|
||||
->maxLength(100)
|
||||
->unique(ignoreRecord: true),
|
||||
|
||||
TextInput::make('value')
|
||||
->label(__('filament::resources.inputs.value'))
|
||||
->required()
|
||||
->maxLength(512),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('key')
|
||||
->label(__('filament::resources.columns.key'))
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('value')
|
||||
->label(__('filament::resources.columns.value'))
|
||||
->searchable(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ManageEmulatorTexts::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\EmulatorTexts\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\EmulatorTexts\EmulatorTextResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageEmulatorTexts extends ManageRecords
|
||||
{
|
||||
protected static string $resource = EmulatorTextResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make('create'),
|
||||
];
|
||||
}
|
||||
|
||||
public function getPrimaryKey(): string
|
||||
{
|
||||
return 'key';
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\OpenPositions;
|
||||
|
||||
use App\Filament\Resources\Hotel\OpenPositions\Pages\CreateOpenPosition;
|
||||
use App\Filament\Resources\Hotel\OpenPositions\Pages\EditOpenPosition;
|
||||
use App\Filament\Resources\Hotel\OpenPositions\Pages\ListOpenPositions;
|
||||
use App\Models\Community\Staff\WebsiteOpenPosition;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class OpenPositionResource extends Resource
|
||||
{
|
||||
protected static ?string $model = WebsiteOpenPosition::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-briefcase';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Hotel';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('permission_id')
|
||||
->label('Rank')
|
||||
->relationship('permission', 'rank_name')
|
||||
->required()
|
||||
->searchable()
|
||||
->preload()
|
||||
->unique(ignoreRecord: true)
|
||||
->placeholder('Select a rank'),
|
||||
Textarea::make('description')
|
||||
->label('Position Description')
|
||||
->required()
|
||||
->maxLength(65535)
|
||||
->columnSpanFull(),
|
||||
DateTimePicker::make('apply_from')
|
||||
->label('Application Start Date')
|
||||
->nullable(),
|
||||
DateTimePicker::make('apply_to')
|
||||
->label('Application End Date')
|
||||
->nullable(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('permission.rank_name')
|
||||
->label('Rank')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('description')
|
||||
->label('Description')
|
||||
->limit(50)
|
||||
->searchable(),
|
||||
TextColumn::make('apply_from')
|
||||
->label('Apply From')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
TextColumn::make('apply_to')
|
||||
->label('Apply To')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->label('Created')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make()
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Delete Open Position')
|
||||
->modalDescription('This will also delete all related staff applications. Are you sure?')
|
||||
->modalSubmitActionLabel('Yes, delete')
|
||||
->successNotification(
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Open Position Deleted')
|
||||
->body('The open position and its related staff applications have been deleted successfully.'),
|
||||
),
|
||||
])
|
||||
->toolbarActions([
|
||||
DeleteBulkAction::make()
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Delete Open Positions')
|
||||
->modalDescription('This will also delete all related staff applications for the selected positions. Are you sure?')
|
||||
->modalSubmitActionLabel('Yes, delete')
|
||||
->successNotification(
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Open Positions Deleted')
|
||||
->body('The selected open positions and their related staff applications have been deleted successfully.'),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListOpenPositions::route('/'),
|
||||
'create' => CreateOpenPosition::route('/create'),
|
||||
'edit' => EditOpenPosition::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\OpenPositions\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\OpenPositions\OpenPositionResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateOpenPosition extends CreateRecord
|
||||
{
|
||||
protected static string $resource = OpenPositionResource::class;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\OpenPositions\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\OpenPositions\OpenPositionResource;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditOpenPosition extends EditRecord
|
||||
{
|
||||
protected static string $resource = OpenPositionResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\OpenPositions\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\OpenPositions\OpenPositionResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListOpenPositions extends ListRecords
|
||||
{
|
||||
protected static string $resource = OpenPositionResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\StaffApplications\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\StaffApplications\StaffApplicationResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditStaffApplication extends EditRecord
|
||||
{
|
||||
protected static string $resource = StaffApplicationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\StaffApplications\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\StaffApplications\StaffApplicationResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListStaffApplications extends ListRecords
|
||||
{
|
||||
protected static string $resource = StaffApplicationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-92
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\StaffApplications;
|
||||
|
||||
use App\Filament\Resources\Hotel\StaffApplications\Pages\EditStaffApplication;
|
||||
use App\Filament\Resources\Hotel\StaffApplications\Pages\ListStaffApplications;
|
||||
use App\Models\Community\Staff\WebsiteStaffApplications;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class StaffApplicationResource extends Resource
|
||||
{
|
||||
protected static ?string $model = WebsiteStaffApplications::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-user-group';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Hotel';
|
||||
|
||||
public static function canCreate(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('user_id')
|
||||
->relationship('user', 'username')
|
||||
->required()
|
||||
->searchable(),
|
||||
Select::make('rank_id')
|
||||
->relationship('rank', 'rank_name')
|
||||
->required()
|
||||
->searchable(),
|
||||
Textarea::make('content')
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('user.username')
|
||||
->label('User')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('rank.rank_name')
|
||||
->label('Rank')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('content')
|
||||
->limit(50)
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
// Add filters if needed
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListStaffApplications::route('/'),
|
||||
'edit' => EditStaffApplication::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\WebsiteAds\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\WebsiteAds\WebsiteAdResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateWebsiteAd extends CreateRecord
|
||||
{
|
||||
protected static string $resource = WebsiteAdResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\WebsiteAds\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\WebsiteAds\WebsiteAdResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditWebsiteAd extends EditRecord
|
||||
{
|
||||
protected static string $resource = WebsiteAdResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\WebsiteAds\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\WebsiteAds\WebsiteAdResource;
|
||||
use App\Models\WebsiteAd;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class ListWebsiteAds extends ListRecords
|
||||
{
|
||||
protected static string $resource = WebsiteAdResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make()
|
||||
->label('Create new ADS')
|
||||
->color('success'),
|
||||
Action::make('importAdsData')
|
||||
->label('Import ADS Images from folder')
|
||||
->color('info')
|
||||
->action(function (): void {
|
||||
Artisan::call('import:ads-data');
|
||||
session()->flash('success', 'ADS data imported successfully!');
|
||||
})
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Import ADS Data')
|
||||
->modalDescription('Are you sure you want to import ADS data? This action cannot be undone.')
|
||||
->modalButton('Yes, import data'),
|
||||
Action::make('emptyTable')
|
||||
->label('Empty Database Table')
|
||||
->color('danger')
|
||||
->action(function (): void {
|
||||
WebsiteAd::truncate();
|
||||
session()->flash('success', 'The table has been emptied successfully!');
|
||||
})
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Empty Table')
|
||||
->modalDescription('Are you sure you want to empty the table? This action cannot be undone and will delete all records.')
|
||||
->modalButton('Yes, empty table'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\WebsiteAds;
|
||||
|
||||
use App\Filament\Resources\Hotel\WebsiteAds\Pages\CreateWebsiteAd;
|
||||
use App\Filament\Resources\Hotel\WebsiteAds\Pages\ListWebsiteAds;
|
||||
use App\Models\WebsiteAd;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\Layout\Stack;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
|
||||
class WebsiteAdResource extends Resource
|
||||
{
|
||||
protected static ?string $model = WebsiteAd::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Hotel';
|
||||
|
||||
protected static ?string $navigationLabel = 'ADS Images';
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-sparkles';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
FileUpload::make('image')
|
||||
->label('Image')
|
||||
->disk('ads')
|
||||
->preserveFilenames()
|
||||
->image()
|
||||
->rules(['required', 'image', 'mimes:jpeg,png,jpg,gif'])
|
||||
->validationMessages([
|
||||
'required' => 'Please upload an image.', 'image' => 'The file must be a valid image.', 'mimes' => 'Only JPEG, PNG, JPG, and GIF images are allowed.'])
|
||||
->required()
|
||||
->getUploadedFileNameForStorageUsing(
|
||||
fn (TemporaryUploadedFile $file): string => strtolower(str_replace([' ', '-', 'æ', 'ø', 'å'], ['_', '_', 'ae', 'oe', 'aa'], $file->getClientOriginalName())),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Stack::make([
|
||||
ImageColumn::make('image_url')
|
||||
->label('')
|
||||
->extraAttributes(['style' => 'image-rendering: pixelated'])
|
||||
->size(125),
|
||||
TextColumn::make('image')
|
||||
->label('')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
]),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime(),
|
||||
])
|
||||
->filters([
|
||||
])
|
||||
->recordActions([
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->searchable();
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListWebsiteAds::route('/'),
|
||||
'create' => CreateWebsiteAd::route('/create'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\WordFilters\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\WordFilters\WordFilterResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageWordFilters extends ManageRecords
|
||||
{
|
||||
protected static string $resource = WordFilterResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\WordFilters;
|
||||
|
||||
use App\Filament\Resources\Hotel\WordFilters\Pages\ManageWordFilters;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\Wordfilter;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class WordFilterResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static ?string $model = Wordfilter::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-eye-slash';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Hotel';
|
||||
|
||||
protected static ?string $slug = 'hotel/wordfilters';
|
||||
|
||||
public static string $translateIdentifier = 'word-filters';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('key')
|
||||
->label(__('filament::resources.inputs.key'))
|
||||
->maxLength(256)
|
||||
->unique('wordfilter', 'key', ignoreRecord: true)
|
||||
->required(),
|
||||
|
||||
TextInput::make('replacement')
|
||||
->label(__('filament::resources.inputs.replacement'))
|
||||
->maxLength(16)
|
||||
->required(),
|
||||
|
||||
Select::make('hide')
|
||||
->native(false)
|
||||
->label(__('filament::resources.inputs.hideable'))
|
||||
->default('0')
|
||||
->options([
|
||||
'0' => __('filament::resources.options.no'),
|
||||
'1' => __('filament::resources.options.yes'),
|
||||
]),
|
||||
|
||||
Select::make('report')
|
||||
->native(false)
|
||||
->label(__('filament::resources.inputs.reportable'))
|
||||
->default('0')
|
||||
->options([
|
||||
'0' => __('filament::resources.options.no'),
|
||||
'1' => __('filament::resources.options.yes'),
|
||||
]),
|
||||
|
||||
TextInput::make('mute')
|
||||
->label(__('filament::resources.inputs.mute_time'))
|
||||
->columnSpanFull()
|
||||
->default(0),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('key')
|
||||
->label(__('filament::resources.columns.key'))
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('replacement')
|
||||
->label(__('filament::resources.columns.replacement'))
|
||||
->searchable(),
|
||||
|
||||
IconColumn::make('hide')
|
||||
->label(__('filament::resources.columns.hideable'))
|
||||
->icon(fn (string $state): string => $state === '0' ? 'heroicon-o-x-circle' : 'heroicon-o-check-circle')
|
||||
->colors([
|
||||
'danger' => '0',
|
||||
'success' => '1',
|
||||
]),
|
||||
|
||||
IconColumn::make('report')
|
||||
->label(__('filament::resources.columns.reportable'))
|
||||
->icon(fn (string $state): string => $state === '0' ? 'heroicon-o-x-circle' : 'heroicon-o-check-circle')
|
||||
->colors([
|
||||
'danger' => '0',
|
||||
'success' => '1',
|
||||
]),
|
||||
|
||||
TextColumn::make('mute')
|
||||
->label(__('filament::resources.columns.mute_time'))
|
||||
->searchable(),
|
||||
])
|
||||
->filters([
|
||||
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ManageWordFilters::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\User\Bans;
|
||||
|
||||
use App\Filament\Resources\User\Bans\Pages\ManageBans;
|
||||
use App\Filament\Tables\Columns\UserAvatarColumn;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\User\Ban;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class BanResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
protected static ?string $model = Ban::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-shield-exclamation';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'User Management';
|
||||
|
||||
protected static ?string $slug = 'user-management/bans';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
public static string $translateIdentifier = 'bans';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Textarea::make('ban_reason')
|
||||
->label(__('filament::resources.inputs.reason'))
|
||||
->columnSpanFull(),
|
||||
|
||||
Select::make('type')
|
||||
->native(false)
|
||||
->label(__('filament::resources.inputs.type'))
|
||||
->columnSpanFull()
|
||||
->options([
|
||||
'account' => __('filament::resources.common.Account'),
|
||||
'ip' => __('filament::resources.common.IP'),
|
||||
'machine' => __('filament::resources.common.Machine'),
|
||||
'super' => __('filament::resources.common.Super'),
|
||||
]),
|
||||
|
||||
DateTimePicker::make('ban_expire')
|
||||
->native(false)
|
||||
->label(__('filament::resources.inputs.expires_at'))
|
||||
->displayFormat('Y-m-d H:i')
|
||||
->format('U')
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('id', 'desc')
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label(__('filament::resources.columns.id')),
|
||||
|
||||
UserAvatarColumn::make('avatar')
|
||||
->toggleable()
|
||||
->pointer('user.look')
|
||||
->label(__('filament::resources.columns.avatar'))
|
||||
->options('&size=m&head_direction=3&gesture=sml&headonly=1'),
|
||||
|
||||
TextColumn::make('user.username')
|
||||
->label(__('filament::resources.columns.username'))
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('staff.username')
|
||||
->label(__('filament::resources.columns.by'))
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('ban_reason')
|
||||
->label(__('filament::resources.columns.reason'))
|
||||
->tooltip(function (TextColumn $column): ?string {
|
||||
$state = $column->getState();
|
||||
|
||||
if (strlen($state) <= $column->getCharacterLimit()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $state;
|
||||
})
|
||||
->limit(15)
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('type')
|
||||
->badge()
|
||||
->label(__('filament::resources.columns.type'))
|
||||
->formatStateUsing(fn (string $state): string => match ($state) {
|
||||
'account' => __('filament::resources.common.Account'),
|
||||
'ip' => __('filament::resources.common.IP'),
|
||||
'machine' => __('filament::resources.common.Machine'),
|
||||
'super' => __('filament::resources.common.Super'),
|
||||
})
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'account' => 'primary',
|
||||
'ip' => 'success',
|
||||
'machine' => 'primary',
|
||||
'super' => 'danger',
|
||||
}),
|
||||
|
||||
TextColumn::make('timestamp')
|
||||
->label(__('filament::resources.columns.banned_at'))
|
||||
->date('Y-m-d H:i'),
|
||||
|
||||
TextColumn::make('ban_expire')
|
||||
->label(__('filament::resources.columns.expires_at'))
|
||||
->formatStateUsing(fn (string $state): string => $state == 0 ? __('filament::resources.common.Never') : date('Y-m-d H:i', $state)),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ManageBans::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\User\Bans\Pages;
|
||||
|
||||
use App\Filament\Resources\User\Bans\BanResource;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageBans extends ManageRecords
|
||||
{
|
||||
protected static string $resource = BanResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
// ...
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\User\Users\Pages;
|
||||
|
||||
use App\Filament\Resources\User\Users\UserResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateUser extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
}
|
||||
@@ -1,216 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\User\Users\Pages;
|
||||
|
||||
use App\Actions\SendCurrency;
|
||||
use App\Enums\CurrencyTypes;
|
||||
use App\Filament\Resources\User\Users\UserResource;
|
||||
use App\Models\Game\Player\UserCurrency;
|
||||
use App\Services\RconService;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Filament\Support\Exceptions\Halt;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class EditUser extends EditRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
protected function mutateFormDataBeforeFill(array $data): array
|
||||
{
|
||||
return static::$resource::fillWithOutsideData(
|
||||
$this->getRecord(),
|
||||
$data,
|
||||
);
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return static::getModel()::query()->with(['currencies', 'settings']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Halt
|
||||
*/
|
||||
protected function beforeSave(): void
|
||||
{
|
||||
$user = $this->getRecord();
|
||||
$data = $this->form->getState();
|
||||
|
||||
if ($data['rank'] > auth()->user()->rank) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title(__('You cannot edit this user!'))
|
||||
->body(__('You cannot edit users with a higher rank than yours.'))
|
||||
->send();
|
||||
|
||||
$this->halt();
|
||||
}
|
||||
|
||||
$rcon = app(RconService::class);
|
||||
|
||||
if (! $user->online) {
|
||||
DB::transaction(function () use ($user, $data): void {
|
||||
$this->treatChangedCurrenciesWithoutRcon($user, $data);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($user->online && ! $rcon->isConnected()) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title(__('RCON is not enabled!'))
|
||||
->body(__('You cannot edit users because RCON is not enabled and the user is online.'))
|
||||
->send();
|
||||
|
||||
$this->halt();
|
||||
}
|
||||
|
||||
DB::transaction(function () use ($user, $data, $rcon): void {
|
||||
if ($data['credits'] != $user->credits) {
|
||||
$rcon->giveCredits($user, -$user->credits + $data['credits']);
|
||||
}
|
||||
|
||||
$this->checkUsernameChangedPermission($user, $data, $rcon);
|
||||
$this->treatChangedCurrencies($user, $data);
|
||||
$this->treatChangedUserRank($user, $data, $rcon);
|
||||
$this->treatChangedUserMotto($user, $data, $rcon);
|
||||
});
|
||||
}
|
||||
|
||||
private function treatChangedCurrenciesWithoutRcon(Model $user, array $data): void
|
||||
{
|
||||
$user->currencies->each(function (UserCurrency $currency) use ($data, $user): void {
|
||||
$updatedCurrencyAmount = $data["currency_{$currency->type}"] ?? $currency->amount;
|
||||
if ($updatedCurrencyAmount == $currency->amount) {
|
||||
return;
|
||||
}
|
||||
|
||||
$updated = $user->currencies()->where('type', $currency->type)->update(['amount' => $updatedCurrencyAmount]);
|
||||
|
||||
if ($updated) {
|
||||
activity()
|
||||
->performedOn($currency)
|
||||
->withProperties(['old_amount' => $currency->amount, 'new_amount' => $updatedCurrencyAmount, 'user_id' => $user->id, 'type' => $currency->type])
|
||||
->event('updated')
|
||||
->log("Currency updated for user {$user->username}");
|
||||
|
||||
} else {
|
||||
activity()
|
||||
->withProperties(['user_id' => $user->id, 'type' => $currency->type])
|
||||
->event('failed_update')
|
||||
->log("Failed to update currency for user {$user->username}");
|
||||
}
|
||||
});
|
||||
|
||||
$user->settings->update(['can_change_name' => $data['allow_change_username'] ? '1' : '0']);
|
||||
}
|
||||
|
||||
private function checkUsernameChangedPermission(Model $user, array $data, RconService $rcon): void
|
||||
{
|
||||
if ($data['allow_change_username'] == $user->settings->can_change_name) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $rcon->isConnected()) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title(__('RCON is not enabled!'))
|
||||
->body(__('You cannot edit users because RCON is not enabled and the user is online.'))
|
||||
->send();
|
||||
|
||||
$this->halt();
|
||||
}
|
||||
|
||||
$rcon->disconnectUser($user);
|
||||
$user->settings->update(['can_change_name' => $data['allow_change_username'] ? '1' : '0']);
|
||||
}
|
||||
|
||||
private function treatChangedCurrencies(Model $user, array $data): void
|
||||
{
|
||||
$user->currencies->each(function (UserCurrency $currency) use ($data, $user): void {
|
||||
$updatedCurrencyAmount = $data["currency_{$currency->type}"] ?? $currency->amount;
|
||||
$currencyType = match ($currency->type) {
|
||||
CurrencyTypes::Duckets => 'duckets',
|
||||
CurrencyTypes::Diamonds => 'diamonds',
|
||||
CurrencyTypes::Points => 'points',
|
||||
};
|
||||
|
||||
if ($updatedCurrencyAmount == $currency->amount) {
|
||||
return;
|
||||
}
|
||||
|
||||
app(SendCurrency::class)->execute($user, $currencyType, -$currency->amount + $updatedCurrencyAmount);
|
||||
});
|
||||
}
|
||||
|
||||
private function treatChangedUserRank(Model $user, array $data, RconService $rcon): void
|
||||
{
|
||||
if ($data['rank'] == $user->rank) {
|
||||
return;
|
||||
}
|
||||
if ($data['rank'] > auth()->user()->rank) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($user->online && ! $rcon->isConnected()) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title(__('RCON is not enabled!'))
|
||||
->body(__('You cannot edit users because RCON is not enabled and the user is online.'))
|
||||
->send();
|
||||
|
||||
$this->halt();
|
||||
}
|
||||
|
||||
if (! $user->online) {
|
||||
$user->update(['rank' => $data['rank']]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$rcon->alertUser($user, __('You have been disconnected because your rank has been changed. Please re-enter the hotel.'));
|
||||
\Illuminate\Support\Sleep::sleep(2);
|
||||
|
||||
$rcon->disconnectUser($user);
|
||||
$rcon->setRank($user, $data['rank']);
|
||||
}
|
||||
|
||||
private function treatChangedUserMotto(Model $user, array $data, RconService $rcon): void
|
||||
{
|
||||
if ($data['motto'] == $user->motto) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($user->online && ! $rcon->isConnected()) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title(__('RCON is not enabled!'))
|
||||
->body(__('You cannot edit users because RCON is not enabled and the user is online.'))
|
||||
->send();
|
||||
|
||||
$this->halt();
|
||||
}
|
||||
|
||||
if (! $user->online) {
|
||||
$user->update(['motto' => $data['motto']]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$rcon->setMotto($user, $data['motto']);
|
||||
$rcon->alertUser($user, __('Your motto has been changed by a staff member.'));
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\User\Users\Pages;
|
||||
|
||||
use App\Enums\NotificationType;
|
||||
use App\Filament\Resources\User\Users\UserResource;
|
||||
use App\Models\User;
|
||||
use App\Models\User\UserNotification;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListUsers extends ListRecords
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make(__('filament::resources.actions.send_notifications'))
|
||||
->modal()
|
||||
->color('gray')
|
||||
->modalHeading(__('filament::resources.actions.send_notifications'))
|
||||
->icon('heroicon-o-bell')
|
||||
->schema([
|
||||
Select::make('users')
|
||||
->label(__('filament::resources.inputs.users'))
|
||||
->searchable()
|
||||
->getSearchResultsUsing(fn (string $search): array => User::where('username', 'like', "%{$search}%")->limit(50)->pluck('username', 'id')->toArray())
|
||||
->multiple()
|
||||
->native(false)
|
||||
->nullable(),
|
||||
|
||||
TextInput::make('message')
|
||||
->label(__('filament::resources.inputs.message'))
|
||||
->maxLength(100)
|
||||
->required(),
|
||||
|
||||
TextInput::make('url')
|
||||
->label(__('filament::resources.inputs.url'))
|
||||
->nullable(),
|
||||
|
||||
Toggle::make('as_staff')
|
||||
->label(__('filament::resources.inputs.as_staff'))
|
||||
->default(false),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$notifications = collect();
|
||||
$allUsersId = collect($data['users'])->values();
|
||||
$senderId = $data['as_staff'] ? null : auth()->id();
|
||||
|
||||
if ($allUsersId->isEmpty()) {
|
||||
$allUsersId = User::select('id')->get()->pluck('id');
|
||||
}
|
||||
|
||||
$allUsersId->each(function ($userId) use ($senderId, $data, $notifications): void {
|
||||
$notifications->push([
|
||||
'sender_id' => $senderId,
|
||||
'recipient_id' => $userId,
|
||||
'type' => NotificationType::HousekeepingCustomMessage,
|
||||
'message' => $data['message'],
|
||||
'url' => $data['url'] ?? null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
});
|
||||
|
||||
UserNotification::insert($notifications->toArray());
|
||||
|
||||
Notification::make()
|
||||
->body(__('Notification sent successfully.'))
|
||||
->icon('heroicon-o-check-circle')
|
||||
->iconColor('success')
|
||||
->send();
|
||||
}),
|
||||
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\User\Users\Pages;
|
||||
|
||||
use App\Filament\Resources\User\Users\UserResource;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewUser extends ViewRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
#[\Override]
|
||||
protected function mutateFormDataBeforeFill(array $data): array
|
||||
{
|
||||
return static::$resource::fillWithOutsideData(
|
||||
$this->getRecord(),
|
||||
$data,
|
||||
);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user