/
dimamir
/
coolify
Обзор
Документация
Войти
/
dimamir
/
coolify
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
app/Livewire/Help.php
58 строк
2 KB
Andras Bacsai
do not use Rule (deprecated), changed to Validate
05 ноя 2024, 11:36
05 ноя 2024, 11:36
9b578b2
Код
Авторство
О чём код?
<?php namespace App\Livewire; use DanHarrin\LivewireRateLimiting\WithRateLimiting; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Support\Facades\Http; use Livewire\Attributes\Validate; use Livewire\Component; class Help extends Component { use WithRateLimiting; #[Validate(['required', 'min:10', 'max:1000'])] public string $description; #[Validate(['required', 'min:3'])] public string $subject; public function submit() { try { $this->validate(); $this->rateLimit(3, 30); $settings = instanceSettings(); $mail = new MailMessage; $mail->view( 'emails.help', [ 'description' => $this->description, ] ); $mail->subject("[HELP]: {$this->subject}"); $type = set_transanctional_email_settings($settings); // Sending feedback through Cloud API if ($type === false) { $url = 'https://app.coolify.io/api/feedback'; Http::post($url, [ 'content' => 'User: `'.auth()->user()?->email.'` with subject: `'.$this->subject.'` has the following problem: `'.$this->description.'`', ]); } else { send_user_an_email($mail, auth()->user()?->email, 'hi@coollabs.io'); } $this->dispatch('success', 'Feedback sent.', 'We will get in touch with you as soon as possible.'); $this->reset('description', 'subject'); } catch (\Throwable $e) { return handleError($e, $this); } } public function render() { return view('livewire.help')->layout('layouts.app'); } }