2023-09-02 15:37:25 +02:00
|
|
|
<?php
|
|
|
|
|
|
2023-12-07 19:06:32 +01:00
|
|
|
namespace App\Livewire;
|
2023-09-02 15:37:25 +02:00
|
|
|
|
|
|
|
|
use DanHarrin\LivewireRateLimiting\WithRateLimiting;
|
|
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
2024-02-06 11:36:20 +01:00
|
|
|
use Illuminate\Support\Facades\Http;
|
2024-11-05 09:36:40 +01:00
|
|
|
use Livewire\Attributes\Validate;
|
2023-09-02 15:37:25 +02:00
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
|
|
class Help extends Component
|
|
|
|
|
{
|
|
|
|
|
use WithRateLimiting;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-11-05 09:36:40 +01:00
|
|
|
#[Validate(['required', 'min:10', 'max:1000'])]
|
2023-09-02 15:37:25 +02:00
|
|
|
public string $description;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2026-04-19 14:48:34 +02:00
|
|
|
#[Validate(['required', 'min:3', 'max:600'])]
|
2023-09-02 15:37:25 +02:00
|
|
|
public string $subject;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-09-02 15:37:25 +02:00
|
|
|
public function submit()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$this->validate();
|
2024-11-03 21:27:26 +01:00
|
|
|
$this->rateLimit(3, 30);
|
|
|
|
|
|
|
|
|
|
$settings = instanceSettings();
|
2025-01-07 15:31:43 +01:00
|
|
|
$mail = new MailMessage;
|
|
|
|
|
$mail->view(
|
2023-09-02 15:37:25 +02:00
|
|
|
'emails.help',
|
|
|
|
|
[
|
|
|
|
|
'description' => $this->description,
|
|
|
|
|
]
|
|
|
|
|
);
|
2025-01-07 15:31:43 +01:00
|
|
|
$mail->subject("[HELP]: {$this->subject}");
|
2024-02-06 11:36:20 +01:00
|
|
|
$type = set_transanctional_email_settings($settings);
|
2024-11-03 21:27:26 +01:00
|
|
|
|
|
|
|
|
// Sending feedback through Cloud API
|
2025-02-27 12:56:37 +01:00
|
|
|
if (blank($type)) {
|
2024-06-10 20:43:34 +00:00
|
|
|
$url = 'https://app.coolify.io/api/feedback';
|
2024-02-06 11:36:20 +01:00
|
|
|
Http::post($url, [
|
2024-06-10 20:43:34 +00:00
|
|
|
'content' => 'User: `'.auth()->user()?->email.'` with subject: `'.$this->subject.'` has the following problem: `'.$this->description.'`',
|
2024-02-06 11:36:20 +01:00
|
|
|
]);
|
|
|
|
|
} else {
|
2025-09-11 20:23:07 +02:00
|
|
|
send_user_an_email($mail, auth()->user()?->email, 'feedback@coollabs.io');
|
2024-02-06 11:36:20 +01:00
|
|
|
}
|
|
|
|
|
$this->dispatch('success', 'Feedback sent.', 'We will get in touch with you as soon as possible.');
|
2024-10-03 23:27:23 +02:00
|
|
|
$this->reset('description', 'subject');
|
2025-01-07 15:31:43 +01:00
|
|
|
} catch (\Throwable $e) {
|
2023-09-15 15:34:25 +02:00
|
|
|
return handleError($e, $this);
|
2023-09-02 15:37:25 +02:00
|
|
|
}
|
|
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-09-02 15:37:25 +02:00
|
|
|
public function render()
|
|
|
|
|
{
|
|
|
|
|
return view('livewire.help')->layout('layouts.app');
|
|
|
|
|
}
|
|
|
|
|
}
|