first commit
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Hive\Services\UserService;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Livewire\Component;
|
||||
|
||||
class AssignTo extends Component
|
||||
{
|
||||
private $queryResults = [];
|
||||
|
||||
public $query = "";
|
||||
|
||||
public $value = "";
|
||||
|
||||
private $selection = [];
|
||||
|
||||
public $display = "none";
|
||||
|
||||
public $simpleResult = "";
|
||||
|
||||
private $service;
|
||||
|
||||
function boot() {
|
||||
$this->service = App::make(UserService::class);
|
||||
}
|
||||
|
||||
function updated()
|
||||
{
|
||||
if (strlen($this->query) > 2) {
|
||||
$this->display = "";
|
||||
$this->queryResults = $this->service->search($this->query);
|
||||
}
|
||||
}
|
||||
|
||||
public function add($id)
|
||||
{
|
||||
if (!str_contains($this->value, $id)) {
|
||||
$this->value .= $id . "|";
|
||||
$this->selection[] = $this->service->getById($id);
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($id)
|
||||
{
|
||||
if (str_contains($this->value, $id)) {
|
||||
$this->value = str_replace($id . "|", "", $this->value);
|
||||
$this->selection = collect($this->selection)->reject(function ($item) use ($id) {
|
||||
return $item->id == $id;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.assign-to', [
|
||||
"queryResults" => $this->queryResults,
|
||||
"simpleResult" => $this->simpleResult,
|
||||
"selection" => $this->selection
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
class Trix extends Component
|
||||
{
|
||||
|
||||
#[On('file-uploaded')]
|
||||
function uploadAttachment($event)
|
||||
{
|
||||
dd($event);
|
||||
dd(json_decode($event));
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.trix');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user