From 595530dbf09448feffd16f2858b2002b328d7e9b Mon Sep 17 00:00:00 2001 From: Benjamin Takats Date: Tue, 6 Dec 2022 23:56:33 +0100 Subject: [PATCH] bookCases added --- .blueprint | 7 + .../Commands/OpenBooks/SyncOpenBooks.php | 58 +++++++ app/Http/Livewire/Frontend/SearchBookCase.php | 22 +++ app/Http/Livewire/Tables/BookCaseTable.php | 55 +++++++ app/Models/BookCase.php | 31 ++++ app/Nova/BookCase.php | 141 ++++++++++++++++++ database/factories/BookCaseFactory.php | 43 ++++++ ...2_12_06_222651_create_book_cases_table.php | 50 +++++++ database/seeders/DatabaseSeeder.php | 2 + draft.yaml | 17 +++ .../frontend/search-book-case.blade.php | 123 +++++++++++++++ routes/web.php | 3 + 12 files changed, 552 insertions(+) create mode 100644 app/Console/Commands/OpenBooks/SyncOpenBooks.php create mode 100644 app/Http/Livewire/Frontend/SearchBookCase.php create mode 100644 app/Http/Livewire/Tables/BookCaseTable.php create mode 100644 app/Models/BookCase.php create mode 100644 app/Nova/BookCase.php create mode 100644 database/factories/BookCaseFactory.php create mode 100644 database/migrations/2022_12_06_222651_create_book_cases_table.php create mode 100644 resources/views/livewire/frontend/search-book-case.blade.php diff --git a/.blueprint b/.blueprint index 14741d32..069eace2 100644 --- a/.blueprint +++ b/.blueprint @@ -1,3 +1,8 @@ +created: + - database/factories/BookCaseFactory.php + - database/migrations/2022_12_06_222651_create_book_cases_table.php + - app/Models/BookCase.php + - app/Nova/BookCase.php models: Category: { name: string, slug: string } City: { country_id: biginteger, name: string, slug: string, longitude: 'float:10', latitude: 'float:10' } @@ -18,3 +23,5 @@ 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 } + Case: { title: string, lat: double, lon: json, address: text, type: string, open: string, comment: text, contact: text, bcz: text, digital: boolean, icontype: string, deactivated: boolean, deactreason: string, entrytype: string, homepage: string } + BookCase: { title: string, lat: double, lon: json, address: text, type: string, open: string, comment: text, contact: text, bcz: text, digital: boolean, icontype: string, deactivated: boolean, deactreason: string, entrytype: string, homepage: string } diff --git a/app/Console/Commands/OpenBooks/SyncOpenBooks.php b/app/Console/Commands/OpenBooks/SyncOpenBooks.php new file mode 100644 index 00000000..225bff59 --- /dev/null +++ b/app/Console/Commands/OpenBooks/SyncOpenBooks.php @@ -0,0 +1,58 @@ +json()['cases'] as $case) { + BookCase::updateOrCreate( + [ + 'id' => $case['id'], + ], + [ + 'title' => $case['title'], + 'lat' => (float)$case['lat'], + 'lon' => (float)$case['lon'], + 'address' => $case['address'], + 'type' => $case['type'], + 'open' => $case['open'], + 'comment' => $case['comment'], + 'contact' => $case['contact'], + 'bcz' => $case['bcz'], + 'digital' => $case['digital'] ?? false, + 'icontype' => $case['icontype'], + 'deactivated' => $case['deactivated'], + 'deactreason' => $case['deactreason'], + 'entrytype' => $case['entrytype'], + 'homepage' => $case['homepage'], + ] + ); + } + + return Command::SUCCESS; + } +} diff --git a/app/Http/Livewire/Frontend/SearchBookCase.php b/app/Http/Livewire/Frontend/SearchBookCase.php new file mode 100644 index 00000000..ee90e29c --- /dev/null +++ b/app/Http/Livewire/Frontend/SearchBookCase.php @@ -0,0 +1,22 @@ + BookCase::get(), + 'countries' => Country::query() + ->select(['code', 'name']) + ->get(), + ]); + } +} diff --git a/app/Http/Livewire/Tables/BookCaseTable.php b/app/Http/Livewire/Tables/BookCaseTable.php new file mode 100644 index 00000000..a98cd364 --- /dev/null +++ b/app/Http/Livewire/Tables/BookCaseTable.php @@ -0,0 +1,55 @@ +setPrimaryKey('id') + ->setAdditionalSelects(['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("Name", "title") + ->sortable() + ->searchable(), + Column::make("Adresse", "address") + ->sortable() + ->searchable(), + Column::make("Link") + ->label( + fn( + $row, + Column $column + ) => 'Link' + ) + ->html(), + BooleanColumn::make('Oranged-Pilled', 'deactivated') + ->sortable(), + ]; + } +} diff --git a/app/Models/BookCase.php b/app/Models/BookCase.php new file mode 100644 index 00000000..4ffac1a3 --- /dev/null +++ b/app/Models/BookCase.php @@ -0,0 +1,31 @@ + 'integer', + 'lat' => 'double', + 'lon' => 'array', + 'digital' => 'boolean', + 'deactivated' => 'boolean', + ]; +} diff --git a/app/Nova/BookCase.php b/app/Nova/BookCase.php new file mode 100644 index 00000000..1786a27b --- /dev/null +++ b/app/Nova/BookCase.php @@ -0,0 +1,141 @@ +sortable(), + + Text::make('Title') + ->rules('required', 'string'), + + Number::make('Lat') + ->rules('required', 'numeric'), + + Code::make('Lon') + ->rules('required', 'json') + ->json(), + + Text::make('Address') + ->rules('required', 'string'), + + Text::make('Type') + ->rules('required', 'string'), + + Text::make('Open') + ->rules('required', 'string'), + + Text::make('Comment') + ->rules('required', 'string'), + + Text::make('Contact') + ->rules('required', 'string'), + + Text::make('Bcz') + ->rules('required', 'string'), + + Boolean::make('Digital') + ->rules('required'), + + Text::make('Icontype') + ->rules('required', 'string'), + + Boolean::make('Deactivated') + ->rules('required'), + + Text::make('Deactreason') + ->rules('required', 'string'), + + Text::make('Entrytype') + ->rules('required', 'string'), + + Text::make('Homepage') + ->rules('required', 'string'), + + + ]; + } + + /** + * 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/database/factories/BookCaseFactory.php b/database/factories/BookCaseFactory.php new file mode 100644 index 00000000..384b0056 --- /dev/null +++ b/database/factories/BookCaseFactory.php @@ -0,0 +1,43 @@ + $this->faker->sentence(4), + 'lat' => $this->faker->latitude, + 'lon' => '{}', + 'address' => $this->faker->text, + 'type' => $this->faker->word, + 'open' => $this->faker->word, + 'comment' => $this->faker->text, + 'contact' => $this->faker->text, + 'bcz' => $this->faker->text, + 'digital' => $this->faker->boolean, + 'icontype' => $this->faker->word, + 'deactivated' => $this->faker->boolean, + 'deactreason' => $this->faker->word, + 'entrytype' => $this->faker->word, + 'homepage' => $this->faker->word, + ]; + } +} diff --git a/database/migrations/2022_12_06_222651_create_book_cases_table.php b/database/migrations/2022_12_06_222651_create_book_cases_table.php new file mode 100644 index 00000000..39b865f5 --- /dev/null +++ b/database/migrations/2022_12_06_222651_create_book_cases_table.php @@ -0,0 +1,50 @@ +id(); + $table->string('title'); + $table->double('lat'); + $table->double('lon'); + $table->text('address') + ->nullable(); + $table->string('type'); + $table->string('open') + ->nullable(); + $table->text('comment') + ->nullable(); + $table->text('contact') + ->nullable(); + $table->text('bcz') + ->nullable(); + $table->boolean('digital'); + $table->string('icontype'); + $table->boolean('deactivated'); + $table->string('deactreason'); + $table->string('entrytype'); + $table->text('homepage') + ->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * @return void + */ + public function down(): void + { + Schema::dropIfExists('book_cases'); + } +} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 1788fcda..e1054608 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -5,6 +5,7 @@ namespace Database\Seeders; // use Illuminate\Database\Console\Seeds\WithoutModelEvents; use App\Console\Commands\Database\CreateTags; use App\Console\Commands\Feed\ReadAndSyncEinundzwanzigPodcastFeed; +use App\Console\Commands\OpenBooks\SyncOpenBooks; use App\Models\Category; use App\Models\City; use App\Models\Country; @@ -279,5 +280,6 @@ class DatabaseSeeder extends Seeder $nonPublicLibrary->libraryItems() ->attach($libraryItem); Artisan::call(ReadAndSyncEinundzwanzigPodcastFeed::class); + Artisan::call(SyncOpenBooks::class); } } diff --git a/draft.yaml b/draft.yaml index e69de29b..145d95b9 100644 --- a/draft.yaml +++ b/draft.yaml @@ -0,0 +1,17 @@ +models: + BookCase: + title: string + lat: double + lon: json + address: text + type: string + open: string + comment: text + contact: text + bcz: text + digital: boolean + icontype: string + deactivated: boolean + deactreason: string + entrytype: string + homepage: string diff --git a/resources/views/livewire/frontend/search-book-case.blade.php b/resources/views/livewire/frontend/search-book-case.blade.php new file mode 100644 index 00000000..bc613c15 --- /dev/null +++ b/resources/views/livewire/frontend/search-book-case.blade.php @@ -0,0 +1,123 @@ +
+ + + {{-- HEADER --}} +
+
+
+
+
+ + + + +
+ @auth +
+ @else + + @endauth +
+
+
+ +

+ Bitcoin School +
Worldwide +

+

+ Finde einen Bücher-Schrank in deiner City

+ + 👇 Bücher-Schrank finden 👇 + +

{{-- TEXT --}}

+
+ +
+
+
+
+ {{-- MAIN --}} +
+
+ +
+
+ {{-- FOOTER --}} + +
diff --git a/routes/web.php b/routes/web.php index befa782e..fba03b74 100644 --- a/routes/web.php +++ b/routes/web.php @@ -39,6 +39,9 @@ Route::get('/{country:code}/dozenten/bibliothek', \App\Http\Livewire\Frontend\Li Route::get('/dozenten', \App\Http\Livewire\Guest\Welcome::class) ->name('search.lecturers'); +Route::get('/buecher-schraenke', \App\Http\Livewire\Frontend\SearchBookCase::class) + ->name('search.bookcases'); + Route::middleware([ 'auth:sanctum', config('jetstream.auth_session'),