Files
RomhackPlaza/app/View/Components/ErrorBlock.php

56 lines
1.4 KiB
PHP
Raw Normal View History

2026-05-20 18:25:15 +02:00
<?php
namespace App\View\Components;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class ErrorBlock extends Component
{
private const array ERROR_TYPES = [
'custom' => [
'icon' => 'ban',
'message' => '%s'
],
2026-06-29 11:47:19 +02:00
'not-found' => [
'icon' => 'sticky-note-off',
'message' => "404: This page does not exist."
],
2026-05-20 18:25:15 +02:00
'page-not-allowed' => [
'icon' => 'shield-ban',
'message' => "You do not have permission to access this page.\nRequired permission: %s"
2026-06-23 19:24:38 +02:00
],
'user-state-not-valid' => [
'icon' => 'shield-ban',
'message' => "You do not have permission to access this page.\nYour user profile is incomplete: %s\nGo back to the forum for more details."
2026-06-29 11:47:19 +02:00
],
'server-error' => [
'icon' => 'bomb',
'message' => "500: Internal Server Error."
2026-05-20 18:25:15 +02:00
]
];
public array $errorArray;
/**
* Create a new component instance.
*/
public function __construct(
public string $errorType,
public string $message = ""
)
{
$this->errorArray = self::ERROR_TYPES[$errorType] ?? self::ERROR_TYPES['custom'];
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.error-block');
}
}