34 lines
		
	
	
		
			924 B
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			924 B
		
	
	
	
		
			PHP
		
	
	
	
| <?php
 | |
| 
 | |
| namespace App\View\Ui;
 | |
| 
 | |
| use Illuminate\View\Component;
 | |
| 
 | |
| class Errors extends Component
 | |
| {
 | |
| 
 | |
|     public function __construct(
 | |
|         public string $for,
 | |
|     ) {
 | |
|     }
 | |
| 
 | |
|     public function id(): string
 | |
|     {
 | |
|         return 'errors-' . str_replace('.', '--', $this->for);
 | |
|     }
 | |
| 
 | |
|     public function render()
 | |
|     {
 | |
|         return <<<'HTML'
 | |
|             @error($for)
 | |
|             <div x-data="{error: ''}" x-init="window.setTimeout(() => document.querySelector('#{{$id()}}') ? document.querySelector('#{{$id()}}').remove() : null, 2000)" class="absolute bottom-[calc(100%+0.5rem)] right-0" id="{{$id}}">
 | |
|                 <div class="tippy-box" tabindex="-1" data-theme="danger" data-placement="top">
 | |
|                     <div class="tippy-content">{{$message}}</div>
 | |
|                     <div class="tippy-arrow absolute right-0 mr-2"></div>
 | |
|                 </div>
 | |
|             </div>
 | |
|             @enderror
 | |
|         HTML;
 | |
|     }
 | |
| }
 |