From 1549fb0f43f45d1790e2c4f7559ca5c0a78196e2 Mon Sep 17 00:00:00 2001 From: Benjamin Takats Date: Mon, 12 Dec 2022 18:32:50 +0100 Subject: [PATCH] bitcoin events added --- .blueprint | 6 + .../BitcoinEvent/BitcoinEventTable.php | 15 +++ .../Livewire/Tables/BitcoinEventTable.php | 45 +++++++ app/Models/BitcoinEvent.php | 35 ++++++ app/Nova/BitcoinEvent.php | 112 ++++++++++++++++++ app/Providers/NovaServiceProvider.php | 7 ++ database/factories/BitcoinEventFactory.php | 35 ++++++ ..._12_171115_create_bitcoin_events_table.php | 44 +++++++ database/seeders/DatabaseSeeder.php | 24 ++++ draft.yaml | 13 -- .../bitcoin-event-table.blade.php | 12 ++ .../views/livewire/frontend/header.blade.php | 6 + .../views/livewire/frontend/welcome.blade.php | 4 +- resources/views/navigation-menu.blade.php | 6 + routes/web.php | 8 ++ 15 files changed, 357 insertions(+), 15 deletions(-) create mode 100644 app/Http/Livewire/BitcoinEvent/BitcoinEventTable.php create mode 100644 app/Http/Livewire/Tables/BitcoinEventTable.php create mode 100644 app/Models/BitcoinEvent.php create mode 100644 app/Nova/BitcoinEvent.php create mode 100644 database/factories/BitcoinEventFactory.php create mode 100644 database/migrations/2022_12_12_171115_create_bitcoin_events_table.php create mode 100644 resources/views/livewire/bitcoin-event/bitcoin-event-table.blade.php diff --git a/.blueprint b/.blueprint index 84aabfbb..03a9a294 100644 --- a/.blueprint +++ b/.blueprint @@ -1,3 +1,8 @@ +created: + - database/factories/BitcoinEventFactory.php + - database/migrations/2022_12_12_171115_create_bitcoin_events_table.php + - app/Models/BitcoinEvent.php + - app/Nova/BitcoinEvent.php models: BookCase: { title: string, latitude: 'float:10', longitude: 'float:10', address: 'text nullable', type: string, open: 'string nullable', comment: 'text nullable', contact: 'text nullable', bcz: 'text nullable', digital: boolean, icontype: string, deactivated: boolean, deactreason: string, entrytype: string, homepage: 'text nullable' } Category: { name: string, slug: string } @@ -22,3 +27,4 @@ models: TeamInvitation: { team_id: biginteger, email: string, role: 'string nullable' } User: { name: string, public_key: 'string nullable', email: 'string nullable', email_verified_at: 'datetime nullable', password: 'string nullable', remember_token: 'string:100 nullable', current_team_id: 'biginteger nullable', profile_photo_path: 'string:2048 nullable', is_lecturer: 'boolean default:', two_factor_secret: 'text nullable', two_factor_recovery_codes: 'text nullable', two_factor_confirmed_at: 'datetime nullable', timezone: 'string default:Europe/Berlin' } Venue: { city_id: biginteger, name: string, slug: string, street: string } + BitcoinEvent: { venue_id: foreign, from: datetime, to: datetime, title: string, description: text, link: string } diff --git a/app/Http/Livewire/BitcoinEvent/BitcoinEventTable.php b/app/Http/Livewire/BitcoinEvent/BitcoinEventTable.php new file mode 100644 index 00000000..fe107717 --- /dev/null +++ b/app/Http/Livewire/BitcoinEvent/BitcoinEventTable.php @@ -0,0 +1,15 @@ +setPrimaryKey('id') + ->setAdditionalSelects(['bitcoin_events.id']) + ->setThAttributes(function (Column $column) { + return [ + 'class' => 'px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider dark:bg-gray-800 dark:text-gray-400', + 'default' => false, + ]; + }) + ->setTdAttributes(function (Column $column, $row, $columnIndex, $rowIndex) { + return [ + 'class' => 'px-6 py-4 text-sm font-medium dark:text-white', + 'default' => false, + ]; + }) + ->setColumnSelectStatus(false) + ->setPerPage(50); + } + + public function columns(): array + { + return [ + Column::make(__('Venue'), 'venue.name'), + Column::make(__('Title'), 'title') + ->sortable(), + Column::make(__('Link'), 'link') + ->sortable(), + ]; + } +} diff --git a/app/Models/BitcoinEvent.php b/app/Models/BitcoinEvent.php new file mode 100644 index 00000000..4a092d31 --- /dev/null +++ b/app/Models/BitcoinEvent.php @@ -0,0 +1,35 @@ + 'integer', + 'venue_id' => 'integer', + 'from' => 'datetime', + 'to' => 'datetime', + ]; + + public function venue(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(Venue::class); + } +} diff --git a/app/Nova/BitcoinEvent.php b/app/Nova/BitcoinEvent.php new file mode 100644 index 00000000..49abafc2 --- /dev/null +++ b/app/Nova/BitcoinEvent.php @@ -0,0 +1,112 @@ +sortable(), + + DateTime::make('From') + ->rules('required'), + + DateTime::make('To') + ->rules('required'), + + Text::make('Title') + ->rules('required', 'string'), + + Text::make('Description') + ->rules('required', 'string')->hideFromIndex(), + + Text::make('Link') + ->rules('required', 'string'), + + BelongsTo::make('Venue'), + + + ]; + } + + /** + * Get the cards available for the request. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function cards(Request $request) + { + return []; + } + + /** + * Get the filters available for the resource. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function filters(Request $request) + { + return []; + } + + /** + * Get the lenses available for the resource. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function lenses(Request $request) + { + return []; + } + + /** + * Get the actions available for the resource. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function actions(Request $request) + { + return []; + } +} diff --git a/app/Providers/NovaServiceProvider.php b/app/Providers/NovaServiceProvider.php index 004069ed..ddb45c00 100644 --- a/app/Providers/NovaServiceProvider.php +++ b/app/Providers/NovaServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use App\Nova\BitcoinEvent; use App\Nova\BookCase; use App\Nova\Category; use App\Nova\City; @@ -54,6 +55,12 @@ class NovaServiceProvider extends NovaApplicationServiceProvider ->icon('calendar') ->collapsable(), + MenuSection::make('Events', [ + MenuItem::resource(BitcoinEvent::class), + ]) + ->icon('star') + ->collapsable(), + MenuSection::make('Schule', [ MenuItem::resource(City::class), MenuItem::resource(Venue::class), diff --git a/database/factories/BitcoinEventFactory.php b/database/factories/BitcoinEventFactory.php new file mode 100644 index 00000000..abe91023 --- /dev/null +++ b/database/factories/BitcoinEventFactory.php @@ -0,0 +1,35 @@ + Venue::factory(), + 'from' => $this->faker->dateTime(), + 'to' => $this->faker->dateTime(), + 'title' => $this->faker->sentence(4), + 'description' => $this->faker->text, + 'link' => $this->faker->word, + ]; + } +} diff --git a/database/migrations/2022_12_12_171115_create_bitcoin_events_table.php b/database/migrations/2022_12_12_171115_create_bitcoin_events_table.php new file mode 100644 index 00000000..b1b77cd8 --- /dev/null +++ b/database/migrations/2022_12_12_171115_create_bitcoin_events_table.php @@ -0,0 +1,44 @@ +id(); + $table->foreignId('venue_id') + ->constrained() + ->cascadeOnDelete() + ->cascadeOnUpdate(); + $table->dateTime('from'); + $table->dateTime('to'); + $table->string('title'); + $table->text('description') + ->nullable(); + $table->string('link') + ->nullable(); + $table->timestamps(); + }); + + Schema::enableForeignKeyConstraints(); + } + + /** + * Reverse the migrations. + * @return void + */ + public function down(): void + { + Schema::dropIfExists('bitcoin_events'); + } +} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 33c13045..be6ae86e 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -6,6 +6,7 @@ namespace Database\Seeders; use App\Console\Commands\Database\CreateTags; use App\Console\Commands\Feed\ReadAndSyncEinundzwanzigPodcastFeed; use App\Console\Commands\OpenBooks\SyncOpenBooks; +use App\Models\BitcoinEvent; use App\Models\Category; use App\Models\City; use App\Models\Country; @@ -22,6 +23,7 @@ use App\Models\Team; use App\Models\User; use App\Models\Venue; use Illuminate\Database\Seeder; +use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Str; use Spatie\Permission\Models\Role; @@ -119,6 +121,11 @@ class DatabaseSeeder extends Seeder 'name' => 'The Blue Studio Coworking (Pfronten)', 'street' => 'Teststraße 3', ]); + Venue::create([ + 'city_id' => 4, + 'name' => 'Innsbruck', + 'street' => 'Innsbrucker Straße 1', + ]); Lecturer::create([ 'team_id' => 1, 'name' => 'Markus Turm', @@ -298,5 +305,22 @@ class DatabaseSeeder extends Seeder 'description' => fake()->text(), 'link' => 'https://t.me/EinundzwanzigKempten', ]); + BitcoinEvent::create([ + 'venue_id' => 4, + 'from' => Carbon::parse('2023-09-12') + ->startOfDay() + ->addHours(8), + 'to' => Carbon::parse('2023-09-16') + ->startOfDay() + ->addHours(18), + 'title' => 'BTC23', + 'description' => 'The largest Bitcoin conference in German is entering the second round: The BTC23 will be even better, more diverse and quite controversial. We are open - for Bitcoiners, interested parties and skeptics from all directions. Three days with bitcoiners, thought leaders and entrepreneurs from space - full of relevant lectures, debates and conversations. And of course parties! The following applies: The BTC23 is there for everyone, no matter what level of knowledge you have on the subject. #bitcoinonly + +Advance ticket sales begin on December 21, 2022 at 9:21 p.m. with time-limited early bird tickets. + +Ticket presale begins on December 21, 2022 at 9:21 p.m. Be quick - there are a limited amount of early bird tickets again. +', + 'link' => 'https://bconf.de/en/', + ]); } } diff --git a/draft.yaml b/draft.yaml index dc2463f5..e69de29b 100644 --- a/draft.yaml +++ b/draft.yaml @@ -1,13 +0,0 @@ -models: - Meetup: - city_id: foreign - name: string:unique - link: string - MeetupEvent: - meetup_id: foreign - date: date - start: time - end: time:nullable - location: string:nullable - description: text:nullable - link: string:nullable diff --git a/resources/views/livewire/bitcoin-event/bitcoin-event-table.blade.php b/resources/views/livewire/bitcoin-event/bitcoin-event-table.blade.php new file mode 100644 index 00000000..43232653 --- /dev/null +++ b/resources/views/livewire/bitcoin-event/bitcoin-event-table.blade.php @@ -0,0 +1,12 @@ +
+ {{-- HEADER --}} + + {{-- MAIN --}} +
+
+ +
+
+ {{-- FOOTER --}} + +
diff --git a/resources/views/livewire/frontend/header.blade.php b/resources/views/livewire/frontend/header.blade.php index db228ef8..25e5bb86 100644 --- a/resources/views/livewire/frontend/header.blade.php +++ b/resources/views/livewire/frontend/header.blade.php @@ -66,6 +66,12 @@ Meetup-Termine @endif + @if(str(request()->route()->getName())->contains('bitcoinEvent.')) + + Veranstaltungen + + @endif diff --git a/resources/views/livewire/frontend/welcome.blade.php b/resources/views/livewire/frontend/welcome.blade.php index 3832e51f..22968bf6 100644 --- a/resources/views/livewire/frontend/welcome.blade.php +++ b/resources/views/livewire/frontend/welcome.blade.php @@ -77,7 +77,7 @@
-
@@ -91,7 +91,7 @@ Worldwide

- Events + Veranstaltungen

diff --git a/resources/views/navigation-menu.blade.php b/resources/views/navigation-menu.blade.php index 6c58c4ec..b88a75b6 100644 --- a/resources/views/navigation-menu.blade.php +++ b/resources/views/navigation-menu.blade.php @@ -46,6 +46,12 @@ @endif + @if(str(request()->route()->getName())->contains('bitcoinEvent.')) + + {{ __('Veranstaltung eintragen') }} + + @endif + {{ __('Mein Profil') }} diff --git a/routes/web.php b/routes/web.php index 0f3267af..7821b2ca 100644 --- a/routes/web.php +++ b/routes/web.php @@ -63,6 +63,14 @@ Route::middleware([]) /* * Events * */ +Route::middleware([]) + ->as('bitcoinEvent.') + ->prefix('meetup') + ->group(function () { + Route::get('/{country:code}/table/event', \App\Http\Livewire\BitcoinEvent\BitcoinEventTable::class) + ->name('table.bitcoinEvent'); + }); + /* * Meetups