/ app / Http / Livewire / SidePanel.php
SidePanel.php
 1  <?php
 2  
 3  namespace App\Http\Livewire;
 4  
 5  use App\Enums\ReviewTypeEnum;
 6  use Illuminate\Contracts\View\View as ViewContract;
 7  use Illuminate\Support\Facades\View;
 8  use Livewire\Component;
 9  
10  final class SidePanel extends Component
11  {
12      public bool $open = false;
13  
14      public string $title = 'Default Panel';
15  
16      public string $component = '';
17  
18      public int|null $entityId = null;
19  
20      public string $entityType;
21  
22      public string $reviewType;
23  
24      public array $params;
25  
26      protected $listeners = [
27          'openPanel',
28          'closePanel',
29      ];
30  
31      public function closePanel()
32      {
33          $this->open = false;
34      }
35  
36      public function openPanel(string $title, string $component, int $entityId = null, ?string $entityType = '', $reviewType = '', ?array $params = []): void
37      {
38          $this->title = $title;
39          $this->component = $component;
40          $this->entityId = $entityId;
41          $this->entityType = $entityType;
42          $this->reviewType = $reviewType;
43          $this->params = $params;
44          $this->open = true;
45      }
46  
47      public function render(): ViewContract
48      {
49          return View::make(
50              view: 'livewire.side-panel',
51          );
52      }
53  }