Skip to content

Instantly share code, notes, and snippets.

@cursosdesarrolloweb
Last active Jul 19, 2021
Embed
What would you like to do?
<?php
namespace App\Http\Livewire;
use App\Models\User;
use Illuminate\Support\Collection;
use Livewire\Component;
class Form extends Component
{
public array $users;
public int $user_id;
public int $name = 0;
public function mount() {
$this->users = User::pluck("name", "id")->toArray();
}
public function rules(): array {
return [
'user_id' => 'required|exists:users,id',
'name' => 'required|string|min:2|max:30',
];
}
public function render()
{
return view('livewire.form');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment