33 lines
691 B
PHP
33 lines
691 B
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use Livewire\Component;
|
|
use Livewire\WithFileUploads;
|
|
|
|
class SingleUploadImage extends Component
|
|
{
|
|
use WithFileUploads;
|
|
|
|
public $image;
|
|
public $name;
|
|
public $label;
|
|
public $required = false;
|
|
public $limit100kb = false;
|
|
public $imgStyle = ['width' => '100%', 'height' => '135px'];
|
|
|
|
public function updatedImage()
|
|
{
|
|
$this->validate([
|
|
'image' => 'image|mimes:jpeg,png,gif|max:' . ($this->limit100kb ? '100' : '2048'), // 100KB or 2MB
|
|
]);
|
|
|
|
$this->dispatch('imageUploaded', $this->image);
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.single-upload-image');
|
|
}
|
|
}
|