Skip to content

Commit de76858

Browse files
committed
05 Video code for event listing, create with validation
1 parent f681b33 commit de76858

File tree

13 files changed

+169
-48277
lines changed

13 files changed

+169
-48277
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ Homestead.json
1010
Homestead.yaml
1111
npm-debug.log
1212
yarn-error.log
13+
.idea

.idea/php.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

+13-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/Http/Livewire/EventAddForm.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,17 @@ class EventAddForm extends Component
1414

1515
public function submit()
1616
{
17+
$this->validate([
18+
'eventName' => ['required', 'min:3'],
19+
'contactName' => ['required', 'min:3'],
20+
'contactEmail' => ['required', 'email'],
21+
'allowedParticipants' => ['required', 'numeric'],
22+
]);
23+
1724
Event::create([
1825
'event_name' => $this->eventName,
1926
'contact_person' => $this->contactName,
20-
'content_email' => $this->contactEmail,
27+
'contact_email' => $this->contactEmail,
2128
'allowed_participant' => $this->allowedParticipants,
2229
]);
2330

app/Http/Livewire/EventListing.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace App\Http\Livewire;
4+
5+
use App\Models\Event;
6+
use Livewire\Component;
7+
8+
class EventListing extends Component
9+
{
10+
public $events;
11+
12+
public function mount()
13+
{
14+
$this->events = Event::query()
15+
->orderByDesc('id')
16+
->get();
17+
}
18+
19+
public function render()
20+
{
21+
return view('livewire.event-listing');
22+
}
23+
}

database/migrations/2020_05_17_180854_create_events_table.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function up()
1717
$table->id();
1818
$table->string('event_name');
1919
$table->string('contact_person');
20-
$table->string('content_email');
20+
$table->string('contact_email');
2121
$table->integer('allowed_participant');
2222
$table->integer('registered_participant')->default(0);
2323
$table->timestamps();

0 commit comments

Comments
 (0)