-
-
Save cursosdesarrolloweb/1e0765e9813dbd9e70ee22580568ab32 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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