Initial commit
This commit is contained in:
43
app/View/Components/ErrorBlock.php
Normal file
43
app/View/Components/ErrorBlock.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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'
|
||||
],
|
||||
'page-not-allowed' => [
|
||||
'icon' => 'shield-ban',
|
||||
'message' => "You do not have permission to access this page.\nRequired permission: %s"
|
||||
]
|
||||
];
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user