feat: send request in cloud
This commit is contained in:
parent
040f47b59c
commit
6b9c7aa9c5
54
app/Http/Livewire/Help.php
Normal file
54
app/Http/Livewire/Help.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use DanHarrin\LivewireRateLimiting\WithRateLimiting;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Livewire\Component;
|
||||
use Route;
|
||||
|
||||
class Help extends Component
|
||||
{
|
||||
use WithRateLimiting;
|
||||
public string $description;
|
||||
public string $subject;
|
||||
public ?string $path = null;
|
||||
protected $rules = [
|
||||
'description' => 'required|min:10',
|
||||
'subject' => 'required|min:3'
|
||||
];
|
||||
public function mount()
|
||||
{
|
||||
$this->path = Route::current()->uri();
|
||||
if (isDev()) {
|
||||
$this->description = "I'm having trouble with {$this->path}";
|
||||
$this->subject = "Help with {$this->path}";
|
||||
}
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
try {
|
||||
$this->rateLimit(1, 60);
|
||||
$this->validate();
|
||||
$subscriptionType = auth()->user()?->subscription?->type() ?? 'unknown';
|
||||
$debug = "Route: {$this->path}";
|
||||
$mail = new MailMessage();
|
||||
$mail->view(
|
||||
'emails.help',
|
||||
[
|
||||
'description' => $this->description,
|
||||
'debug' => $debug
|
||||
]
|
||||
);
|
||||
$mail->subject("[HELP - {$subscriptionType}]: {$this->subject}");
|
||||
send_user_an_email($mail, 'hi@coollabs.io');
|
||||
$this->emit('success', 'Your message has been sent successfully. We will get in touch with you as soon as possible.');
|
||||
} catch (\Exception $e) {
|
||||
return general_error_handler($e, $this);
|
||||
}
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.help')->layout('layouts.app');
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@
|
||||
|
||||
class TransactionalEmailChannel
|
||||
{
|
||||
private bool $isResend = false;
|
||||
public function send(User $notifiable, Notification $notification): void
|
||||
{
|
||||
$settings = InstanceSettings::get();
|
||||
@ -26,33 +25,14 @@ public function send(User $notifiable, Notification $notification): void
|
||||
}
|
||||
$this->bootConfigs();
|
||||
$mailMessage = $notification->toMail($notifiable);
|
||||
// if ($this->isResend) {
|
||||
Mail::send(
|
||||
[],
|
||||
[],
|
||||
fn (Message $message) => $message
|
||||
->from(
|
||||
data_get($settings, 'smtp_from_address'),
|
||||
data_get($settings, 'smtp_from_name'),
|
||||
)
|
||||
->to($email)
|
||||
->subject($mailMessage->subject)
|
||||
->html((string)$mailMessage->render())
|
||||
);
|
||||
// } else {
|
||||
// Mail::send(
|
||||
// [],
|
||||
// [],
|
||||
// fn (Message $message) => $message
|
||||
// ->from(
|
||||
// data_get($settings, 'smtp_from_address'),
|
||||
// data_get($settings, 'smtp_from_name'),
|
||||
// )
|
||||
// ->bcc($email)
|
||||
// ->subject($mailMessage->subject)
|
||||
// ->html((string)$mailMessage->render())
|
||||
// );
|
||||
// }
|
||||
}
|
||||
|
||||
private function bootConfigs(): void
|
||||
@ -61,8 +41,5 @@ private function bootConfigs(): void
|
||||
if (!$type) {
|
||||
throw new Exception('No email settings found.');
|
||||
}
|
||||
if ($type === 'resend') {
|
||||
$this->isResend = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Mail\Message;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
@ -261,15 +260,10 @@ function send_user_an_email(MailMessage $mail, string $email): void
|
||||
[],
|
||||
[],
|
||||
fn (Message $message) => $message
|
||||
->from(
|
||||
data_get($settings, 'smtp_from_address'),
|
||||
data_get($settings, 'smtp_from_name')
|
||||
)
|
||||
->to($email)
|
||||
->subject($mail->subject)
|
||||
->html((string) $mail->render())
|
||||
);
|
||||
|
||||
}
|
||||
function isEmailEnabled($notifiable)
|
||||
{
|
||||
|
@ -47,6 +47,9 @@ function getEndDate()
|
||||
|
||||
function isSubscriptionActive()
|
||||
{
|
||||
if (!isCloud()) {
|
||||
return false;
|
||||
}
|
||||
$team = currentTeam();
|
||||
if (!$team) {
|
||||
return false;
|
||||
|
@ -43,10 +43,6 @@
|
||||
@endisset
|
||||
@if ($modalSubmit)
|
||||
{{ $modalSubmit }}
|
||||
@else
|
||||
<x-forms.button onclick="{{ $modalId }}.close()" type="submit">
|
||||
Save
|
||||
</x-forms.button>
|
||||
@endif
|
||||
|
||||
</form>
|
||||
|
@ -95,6 +95,20 @@ class="{{ request()->is('settings*') ? 'text-warning icon' : 'icon' }}" viewBox=
|
||||
</a>
|
||||
</li>
|
||||
@endif
|
||||
@if (isSubscriptionActive() || isDev())
|
||||
<li title="Help" class="mt-auto">
|
||||
<div class="justify-center icons" wire:click="help" onclick="help.showModal()">
|
||||
<svg class="{{ request()->is('help*') ? 'text-warning icon' : 'icon' }}" viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2">
|
||||
<path d="M3 12a9 9 0 1 0 18 0a9 9 0 0 0-18 0m9 4v.01" />
|
||||
<path d="M12 13a2 2 0 0 0 .914-3.782a1.98 1.98 0 0 0-2.414.483" />
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
</li>
|
||||
@endif
|
||||
<li class="pb-6" title="Logout">
|
||||
<form action="/logout" method="POST" class=" hover:bg-transparent">
|
||||
@csrf
|
||||
|
5
resources/views/emails/help.blade.php
Normal file
5
resources/views/emails/help.blade.php
Normal file
@ -0,0 +1,5 @@
|
||||
{{ $description }}
|
||||
|
||||
{{ Illuminate\Mail\Markdown::parse('---') }}
|
||||
|
||||
{{ Illuminate\Mail\Markdown::parse($debug) }}
|
@ -25,6 +25,14 @@
|
||||
|
||||
<body>
|
||||
@livewireScripts
|
||||
@if (isSubscriptionActive() || isDev())
|
||||
<dialog id="help" class="modal">
|
||||
<livewire:help />
|
||||
<form method="dialog" class="modal-backdrop">
|
||||
<button>close</button>
|
||||
</form>
|
||||
</dialog>
|
||||
@endif
|
||||
<x-toaster-hub />
|
||||
<x-version class="fixed left-2 bottom-1" />
|
||||
<script>
|
||||
|
10
resources/views/livewire/help.blade.php
Normal file
10
resources/views/livewire/help.blade.php
Normal file
@ -0,0 +1,10 @@
|
||||
<div class="flex flex-col gap-2 rounded modal-box">
|
||||
<h3>How can we help?</h3>
|
||||
<div>You can report bug on the current page, or send us general feedback.</div>
|
||||
<form wire:submit.prevent="submit" class="flex flex-col gap-4 pt-4">
|
||||
<x-forms.input id="subject" label="Subject" placeholder="Summary of your problem."></x-forms.input>
|
||||
<x-forms.textarea id="description" label="Message"
|
||||
placeholder="Please provide as much information as possible."></x-forms.textarea>
|
||||
<x-forms.button class="w-full mt-4" type="submit">Send Request</x-forms.button>
|
||||
</form>
|
||||
</div>
|
@ -9,6 +9,7 @@
|
||||
use App\Http\Livewire\Boarding\Index;
|
||||
use App\Http\Livewire\Boarding\Server as BoardingServer;
|
||||
use App\Http\Livewire\Dashboard;
|
||||
use App\Http\Livewire\Help;
|
||||
use App\Http\Livewire\Server\All;
|
||||
use App\Http\Livewire\Server\Show;
|
||||
use App\Http\Livewire\Waitlist\Index as WaitlistIndex;
|
||||
@ -103,6 +104,7 @@
|
||||
Route::get('/force-password-reset', [Controller::class, 'force_passoword_reset'])->name('auth.force-password-reset');
|
||||
});
|
||||
Route::get('/subscription', [Controller::class, 'subscription'])->name('subscription.index');
|
||||
// Route::get('/help', Help::class)->name('help');
|
||||
Route::get('/settings', [Controller::class, 'settings'])->name('settings.configuration');
|
||||
Route::get('/settings/license', [Controller::class, 'license'])->name('settings.license');
|
||||
Route::get('/profile', fn () => view('profile', ['request' => request()]))->name('profile');
|
||||
|
Loading…
Reference in New Issue
Block a user