/ app / Http / Livewire / Jsons / View.php
View.php
 1  <?php
 2  
 3  namespace App\Http\Livewire\Jsons;
 4  
 5  use App\Models\Json;
 6  use App\Models\JsonDraft;
 7  use Illuminate\Support\Collection;
 8  use Illuminate\Support\Facades\Route;
 9  use Illuminate\Support\Str;
10  use Livewire\Component;
11  use Livewire\WithPagination;
12  
13  class View extends Component
14  {
15      use WithPagination;
16  
17      public int $entityId;
18  
19      public Json $json;
20  
21      public $data;
22  
23      public $isChanged = false;
24      public $nameClass;
25  
26      private $elements = null;
27  
28      public function mount($id)
29      {
30  
31          if (Str::contains(Route::getCurrentRoute()->getName(), 'draft')) {
32              $this->json = JsonDraft::findOrFail($id);
33          } else
34              $this->json = Json::findOrFail($id);
35  
36          // $this->authorize('can_read_jsons');
37          $this->data = $this->json->json;
38      }
39  
40      public function updating(): void
41      {
42          $this->resetPage();
43      }
44  
45      public function render()
46      {
47          return view('livewire.jsons.view')
48              ->layoutData([
49                  'title' => $this->json->schema_name,
50                  'entity' => $this->json,
51                  'breadcrumb' => 'jsons.view',
52              ]);
53      }
54  }