diff --git a/IDEAS.md b/IDEAS.md index 955f56f..e7e5c79 100644 --- a/IDEAS.md +++ b/IDEAS.md @@ -1,3 +1,4 @@ - Permettre à un user de suivre un projet - permettre d'insérer des @user dans le texte avec lien vers user - permettre de modifier son mot de passe ? (je crois que ça n'as pas été mis exprès) +- ~~parser les liens http~~ diff --git a/app/Lib/Utils.php b/app/Lib/Utils.php new file mode 100644 index 0000000..10c11b6 --- /dev/null +++ b/app/Lib/Utils.php @@ -0,0 +1,29 @@ +first() ?? ''; + if (filter_var($match, FILTER_VALIDATE_EMAIL)) { + return strlen($match) ? "$match" : $match; + } else { + $url = $match; + if (\strpos($url, 'http') === false and \strpos($url, 'https') === false) { + $url = sprintf('http://%s', $url); + } + return strlen($match) ? "$match" : $match; + } + }, + $text + ); + return nl2br($text); + } +} diff --git a/config/app.php b/config/app.php index c697c9a..58b8ecc 100644 --- a/config/app.php +++ b/config/app.php @@ -227,7 +227,8 @@ return [ 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, 'TicketType' => App\Enums\TicketType::class, - 'TicketStatus' => App\Enums\TicketStatus::class + 'TicketStatus' => App\Enums\TicketStatus::class, + 'Utils' => App\Lib\Utils::class ], ]; diff --git a/resources/views/ticket/show.blade.php b/resources/views/ticket/show.blade.php index 534746c..a54a661 100644 --- a/resources/views/ticket/show.blade.php +++ b/resources/views/ticket/show.blade.php @@ -96,22 +96,23 @@ @foreach ($messages as $message) @if ($message->user_id === null)
{!! nl2br(e($ticket->text)) !!}
+{!! Utils::plainToHtml($ticket->text) !!}
Créé le {{ \Carbon\Carbon::parse($ticket->created_at)->format('d/m/Y à H:i') }} par {{ $ticket->user->name }}