KTVCentral/app/Livewire/Modals/StickerModal.php

45 lines
977 B
PHP
Raw Normal View History

<?php
namespace App\Livewire\Modals;
use Livewire\Component;
class StickerModal extends Component
{
protected $listeners = [
'openModal','closeModal'
];
public bool $showModal = false;
public $selectedSticker = null;
public $stickers = [];
public function mount()
{
$this->stickers = collect(glob(storage_path('app/public/superstar-pic/*.png')))
//->map(fn($path) => 'superstar-pic/' . basename($path))
->map(fn($path) => basename($path))
->toArray();
}
public function openModal()
{
$this->showModal = true;
}
public function closeModal()
{
$this->showModal = false;
}
public function select($sticker)
{
$this->dispatch('stickerSelected', $sticker);
$this->selectedSticker =$sticker;
$this->showModal = false;
}
public function render()
{
return view('livewire.modals.sticker-modal');
}
}