fixes
This commit is contained in:
1 parent
e97c7cd0f4
commit
95315d1453
8 files changed
+90
-72
No files matched your search
@@ -3,7 +3,7 @@
|
||||
namespace App\Filament\Resources\Events\Tables;
|
||||
|
||||
use App\Filament\Resources\Events\Tables\Tools\CompareOptions;
|
||||
use App\Filament\Resources\Events\Tables\Tools\LoadBettype;
|
||||
use App\Filament\Resources\Events\Tables\Tools\LoadBettypeSettings;
|
||||
use App\Filament\Resources\Events\Tables\Tools\LoadCompareDifferences;
|
||||
use App\Filament\Resources\Events\Tables\Tools\LoadMultiline;
|
||||
use App\Filament\Tables\Columns\ColumnOdds;
|
||||
@@ -59,7 +59,7 @@ class EventsTable
|
||||
{
|
||||
LoadMultiline::load();
|
||||
|
||||
LoadBettype::load();
|
||||
LoadBettypeSettings::load();
|
||||
|
||||
return $table
|
||||
->striped()
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ namespace App\Filament\Resources\Events\Tables\Tools;
|
||||
use App\Filament\Resources\Events\Tables\EventsTable;
|
||||
use App\Models\BettypeUser;
|
||||
|
||||
class LoadBettype
|
||||
class LoadBettypeSettings
|
||||
{
|
||||
public static function load()
|
||||
{
|
||||
@@ -29,16 +29,19 @@ class PersonalNotificationTable extends Component implements HasActions, HasSche
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(PersonalNotification::query()->with('bookmaker')->where('user_id', auth()->user()->id))
|
||||
->query(PersonalNotification::query()
|
||||
->with('bookmaker')
|
||||
->where('alarm_level_id', '>', 1)
|
||||
->where('user_id', auth()->user()->id))
|
||||
->description('Send a notification when favorit enters an alarm level.')
|
||||
->striped()
|
||||
->columns([
|
||||
BookmakerIcon::make('bookmaker.icon')
|
||||
->label('Bookmaker')->size('lg'),
|
||||
TextColumn::make('alarm_level.name')
|
||||
->color(fn ($record) => $record->alarm_level->color)
|
||||
->weight(FontWeight::Black)
|
||||
->extraCellAttributes(['class' => 'alarm-level-style']),
|
||||
->weight(FontWeight::Black),
|
||||
BookmakerIcon::make('bookmaker.icon')
|
||||
->alignCenter()
|
||||
->label('Bookmaker')->size('sm'),
|
||||
])
|
||||
->defaultSort('alarm_level_id', 'desc')
|
||||
->deferFilters(false)
|
||||
|
||||
@@ -4,19 +4,18 @@ namespace App\Livewire;
|
||||
|
||||
use App\Mail\UserNotification;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\MarkdownEditor;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Livewire\Component;
|
||||
@@ -27,53 +26,53 @@ class UserNotifications extends Component implements HasActions, HasSchemas, Has
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
protected Table $table2;
|
||||
public ?array $data = [];
|
||||
|
||||
public function table(Table $table): Table
|
||||
public function mount(): void
|
||||
{
|
||||
return $table
|
||||
->query(User::query()->where('client_id', auth()->user()->client_id)->orwhereIn('id', [1, 2]))
|
||||
->description('Send a message to one of the user listed')
|
||||
->columns([
|
||||
TextColumn::make('name')->icon('phosphor-user-duotone')->searchable(),
|
||||
TextColumn::make('email')->icon('phosphor-envelope-duotone'),
|
||||
$this->form->fill();
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('recipient')
|
||||
->placeholder('Select an recipient')
|
||||
->required()
|
||||
->options(fn () => User::query()->where('client_id', auth()->user()->client_id)->orwhereIn('id', [1, 2])->pluck('name', 'id')),
|
||||
Toggle::make('notify_by_email')->label('Send also as E-Mail'),
|
||||
TextInput::make('subject')
|
||||
->required(),
|
||||
MarkdownEditor::make('message')
|
||||
->required(),
|
||||
])
|
||||
->recordActions([
|
||||
Action::make('notification')
|
||||
->icon('phosphor-note-pencil-duotone')
|
||||
->tooltip('Create a notification')
|
||||
->modalHeading(fn ($record) => 'Send a notification to '.$record->name)
|
||||
->iconButton()
|
||||
->modalWidth(Width::Large)
|
||||
// ->modalDescription('Send a notification')
|
||||
->modalSubmitActionLabel('Send')
|
||||
->modalIcon('phosphor-envelope-duotone')
|
||||
->schema([
|
||||
Textarea::make('message')
|
||||
->required()
|
||||
->rows(4),
|
||||
Toggle::make('notify_by_email')->label('Send also as email')
|
||||
// ->belowContent('Notify me also by e-mail')
|
||||
->onColor('info')
|
||||
->offColor('gray'),
|
||||
])->action(function (array $data, $record) {
|
||||
->statePath('data');
|
||||
}
|
||||
|
||||
if ($data['notify_by_email']) {
|
||||
Mail::to($record)
|
||||
->send(new UserNotification($data['message']));
|
||||
}
|
||||
Notification::make()
|
||||
->title('Notification from '.$record->name)
|
||||
->icon('phosphor-envelope-duotone')
|
||||
->body($data['message'])
|
||||
->sendToDatabase($record);
|
||||
public function create(): void
|
||||
{
|
||||
$data = $this->form->getState();
|
||||
|
||||
Notification::make()
|
||||
->title('Message send successfully')
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
]);
|
||||
$recipient = User::find((int) $data['recipient']);
|
||||
|
||||
if ($recipient) {
|
||||
if ($data['notify_by_email']) {
|
||||
Mail::to($recipient)->send(new UserNotification($data['subject'], $data['message']));
|
||||
}
|
||||
Notification::make()
|
||||
->title($data['subject'])
|
||||
->icon('phosphor-envelope-duotone')
|
||||
->body($data['message'])
|
||||
->sendToDatabase($recipient);
|
||||
|
||||
Notification::make()
|
||||
->title('Message send successfully')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
$this->dispatch('close-modal', id: 'send_message_modal');
|
||||
}
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
||||
@@ -14,11 +14,15 @@ class UserNotification extends Mailable
|
||||
|
||||
protected string $message;
|
||||
|
||||
protected string $subject;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($message)
|
||||
public function __construct($subject, $message)
|
||||
{
|
||||
$this->subject = $subject;
|
||||
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
@@ -28,7 +32,7 @@ class UserNotification extends Mailable
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'NUH-Odds Notification',
|
||||
subject: $this->subject,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div>
|
||||
<x-sport-header>
|
||||
<x-sport-header>
|
||||
{{ auth()->user()->sport->name }}
|
||||
</x-sport-header>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="flex flex-1 gap-3 mr-5">
|
||||
@if ($this->current == 'filament.admin.resources.events.index')
|
||||
|
||||
|
||||
{{-- Client Swop Bookmaker --}}
|
||||
|
||||
<x-filament::dropdown>
|
||||
@@ -60,9 +60,9 @@
|
||||
</x-filament::dropdown.list>
|
||||
</x-filament::dropdown>
|
||||
|
||||
{{-- Notifications --}}
|
||||
{{-- Notifications --}}
|
||||
|
||||
<x-filament::modal width="2xl" icon="phosphor-warning-duotone" :close-by-clicking-away="true" :close-by-escaping="true"
|
||||
{{-- <x-filament::modal width="2xl" icon="phosphor-warning-duotone" :close-by-clicking-away="true" :close-by-escaping="true"
|
||||
:close-button="true">
|
||||
<x-slot name="trigger">
|
||||
<x-filament::button outlined icon="phosphor-warning-duotone" class="my-auto" color="gray"
|
||||
@@ -74,13 +74,13 @@
|
||||
</x-slot>
|
||||
|
||||
@livewire('personal-notification-table')
|
||||
|
||||
</x-filament::modal>
|
||||
|
||||
</x-filament::modal> --}}
|
||||
|
||||
{{-- Send Message --}}
|
||||
|
||||
<x-filament::modal slide-over width="2xl" icon="phosphor-paper-plane-tilt-duotone" :close-by-clicking-away="true" :close-by-escaping="true"
|
||||
:close-button="true">
|
||||
<x-filament::modal width="2xl" id="send_message_modal" icon="phosphor-paper-plane-tilt-duotone"
|
||||
:close-by-clicking-away="true" :close-by-escaping="true" :close-button="true">
|
||||
<x-slot name="trigger">
|
||||
<x-filament::button outlined icon="phosphor-paper-plane-tilt-duotone" class="my-auto" color="gray"
|
||||
tooltip="Send Message">
|
||||
@@ -97,17 +97,18 @@
|
||||
|
||||
{{-- Event Mapper --}}
|
||||
|
||||
<x-filament::modal width="screen" icon="phosphor-arrows-in-line-horizontal" :close-by-clicking-away="true" :close-by-escaping="true" :close-button="true">
|
||||
<x-filament::modal width="screen" icon="phosphor-arrows-in-line-horizontal" :close-by-clicking-away="true" :close-by-escaping="true"
|
||||
:close-button="true">
|
||||
<x-slot name="trigger">
|
||||
<x-filament::button outlined icon="phosphor-arrows-in-line-horizontal" color="gray"
|
||||
class="my-auto" tooltip="Event Mapper">
|
||||
<x-filament::button outlined icon="phosphor-arrows-in-line-horizontal" color="gray" class="my-auto"
|
||||
tooltip="Event Mapper">
|
||||
</x-filament::button>
|
||||
</x-slot>
|
||||
|
||||
<x-slot name="heading">
|
||||
<div class="flex justify-end items-center gap-20">
|
||||
<x-sport-header>
|
||||
Event Mapper {{ auth()->user()->sport->name }}
|
||||
Event Mapper {{ auth()->user()->sport->name }}
|
||||
</x-sport-header>
|
||||
@php
|
||||
if (!auth()->user()->provider_id) {
|
||||
@@ -230,7 +231,8 @@
|
||||
|
||||
{{-- Calculation --}}
|
||||
|
||||
<x-filament::modal slide-over width="4xl" icon="phosphor-sliders" :close-by-clicking-away="true" :close-by-escaping="true" :close-button="true">
|
||||
<x-filament::modal slide-over width="4xl" icon="phosphor-sliders" :close-by-clicking-away="true" :close-by-escaping="true"
|
||||
:close-button="true">
|
||||
<x-slot name="trigger">
|
||||
<x-filament::button icon="phosphor-sliders" color="gray" class="my-auto" wire:click="setUser"
|
||||
tooltip="Comparing Bookmaker">
|
||||
@@ -246,7 +248,8 @@
|
||||
</x-filament::modal>
|
||||
|
||||
{{-- Custom Groups --}}
|
||||
<x-filament::modal width="4xl" icon="phosphor-user-list" :close-by-clicking-away="true" :close-by-escaping="true" :close-button="true">
|
||||
<x-filament::modal width="4xl" icon="phosphor-user-list" :close-by-clicking-away="true" :close-by-escaping="true"
|
||||
:close-button="true">
|
||||
<x-slot name="trigger">
|
||||
<x-filament::button outlined icon="phosphor-user-list" color="gray" class="my-auto"
|
||||
tooltip="Custom Groups">
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
<div>
|
||||
{{ $this->table }}
|
||||
<form wire:submit="create">
|
||||
{{ $this->form }}
|
||||
|
||||
<x-filament::button type="submit" class="my-5" icon="phosphor-paper-plane-tilt-duotone">
|
||||
Send Message
|
||||
</x-filament::button>
|
||||
|
||||
</form>
|
||||
|
||||
<x-filament-actions::modals />
|
||||
</div>
|
||||
Reference in new issue
Block a user