+ /**
+ * Send back a json error message.
+ */
+ protected function jsonError(string $messageText = '', int $statusCode = 500): JsonResponse
+ {
+ return response()->json(['message' => $messageText, 'status' => 'error'], $statusCode);
+ }
+
+ /**
+ * Create and return a new download response factory using the current request.
+ */
+ protected function download(): DownloadResponseFactory
+ {
+ return new DownloadResponseFactory(request());
+ }
+
+ /**
+ * Show a positive, successful notification to the user on next view load.
+ */
+ protected function showSuccessNotification(string $message): void
+ {
+ session()->flash('success', $message);
+ }
+
+ /**
+ * Show a warning notification to the user on next view load.
+ */
+ protected function showWarningNotification(string $message): void
+ {
+ session()->flash('warning', $message);
+ }
+
+ /**
+ * Show an error notification to the user on next view load.
+ */
+ protected function showErrorNotification(string $message): void
+ {
+ session()->flash('error', $message);
+ }
+
+ /**
+ * Log an activity in the system.
+ *
+ * @param string|Loggable $detail
+ */
+ protected function logActivity(string $type, $detail = ''): void
+ {
+ Activity::add($type, $detail);
+ }
+
+ /**
+ * Get the validation rules for image files.
+ */
+ protected function getImageValidationRules(): array
+ {
+ return ['image_extension', 'mimes:jpeg,png,gif,webp', 'max:' . (config('app.upload_limit') * 1000)];
+ }