- Added migration for ticket assignment and comments (`assigned_user_id` and `ticket_replies` table). - Implemented `TicketAssignedNotification` and `TicketCommentedNotification`. - Created `ReplyData`, `TicketListData`, and `PostReplyRequest` data classes. - Introduced `ResolveNotificationRouteController` for modular notification redirection. - Updated UI to support assigning users and posting comments on tickets. - User is navigated to comments page when clicked on the ticket, upon navigation ticket details modal is opened. - Extended tests to cover assignments, comments, status transitions, and notifications.
44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Concerns;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Validation\ValidationException;
|
|
use Mary\Traits\Toast;
|
|
use Throwable;
|
|
|
|
trait HandlesOperations
|
|
{
|
|
use Toast;
|
|
|
|
public function attempt(callable $action, ?callable $onError = null, string $successMessage = 'Success !', string $errorMessage = 'Something gone wrong!', bool $showSuccess = true): void
|
|
{
|
|
try {
|
|
// call the action callback
|
|
$action();
|
|
if ($showSuccess) {
|
|
$this->success($successMessage, css: 'alert-success alert-dismissible alert-soft');
|
|
}
|
|
} catch (ValidationException $exception) {
|
|
|
|
/**
|
|
* We are catching this exception intentionally so that, generic throwable catch block
|
|
* doesn't catch this, which will lead to close the modal.
|
|
*
|
|
* But, we are rethrowing this so that validation errors can be handled by others.
|
|
*/
|
|
|
|
throw $exception;
|
|
} catch (Throwable $exception) {
|
|
if (null !== $onError) {
|
|
// call the callback
|
|
$onError();
|
|
}
|
|
$this->error($errorMessage, css: 'alert-error alert-dismissible alert-soft');
|
|
Log::error($exception->getMessage());
|
|
}
|
|
}
|
|
}
|