diff --git a/app/Activity.php b/app/Activity.php new file mode 100644 index 00000000..ac3b29fa --- /dev/null +++ b/app/Activity.php @@ -0,0 +1,21 @@ + 'integer' + ]; + + public function groups() { + return $this->belongsToMany(Group::class); + } +} diff --git a/app/Confession.php b/app/Confession.php new file mode 100644 index 00000000..0e548f88 --- /dev/null +++ b/app/Confession.php @@ -0,0 +1,12 @@ + 'boolean' + ]; +} diff --git a/app/Group.php b/app/Group.php new file mode 100644 index 00000000..68233c21 --- /dev/null +++ b/app/Group.php @@ -0,0 +1,16 @@ +belongsToMany(Activity::class); + } +} diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index fd86158b..2081227e 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -37,6 +37,7 @@ class Kernel extends HttpKernel \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, \App\Http\Middleware\InertiaShareMiddleware::class, + \App\Http\Middleware\RedirectIfNotInitializedMiddleware::class ], 'api' => [ diff --git a/app/Http/Middleware/RedirectIfNotInitializedMiddleware.php b/app/Http/Middleware/RedirectIfNotInitializedMiddleware.php new file mode 100644 index 00000000..90f29de7 --- /dev/null +++ b/app/Http/Middleware/RedirectIfNotInitializedMiddleware.php @@ -0,0 +1,39 @@ +shouldRedirect()) { + return $next($request); + } + + if (!$this->initialized()) { + return redirect()->route('initialize.index'); + } + + return $next($request); + } + + public function shouldRedirect() { + return !in_array(request()->route()->getName(), $this->dontRedirect) && auth()->check(); + } + + public function initialized() { + return \App\Fee::get()->count() > 0; + } +} diff --git a/app/Initialize/InitializeActivities.php b/app/Initialize/InitializeActivities.php new file mode 100644 index 00000000..ca30b9db --- /dev/null +++ b/app/Initialize/InitializeActivities.php @@ -0,0 +1,29 @@ +bar = $bar; + $this->api = $api; + } + + public function handle() { + $this->bar->task('Synchronisiere Tätigkeiten', function() { + collect($this->api->activities()->data)->each(function($activity) { + $activity = \App\Activity::create(['nami_id' => $activity->id, 'name' => $activity->descriptor]); + + $groups = []; + collect($this->api->groupForActivity($activity->id)->data)->each(function($group) use ($activity, &$groups) { + $group = \App\Group::updateOrCreate(['nami_id' => $group->id], ['nami_id' => $group->id, 'name' => $group->descriptor]); + $groups[] = $group->id; + }); + $activity->groups()->sync($groups); + }); + }); + } +} diff --git a/app/Initialize/InitializeConfessions.php b/app/Initialize/InitializeConfessions.php new file mode 100644 index 00000000..1ef4c458 --- /dev/null +++ b/app/Initialize/InitializeConfessions.php @@ -0,0 +1,23 @@ +bar = $bar; + $this->api = $api; + } + + public function handle() { + $this->bar->task('Synchronisiere Konfessionen', function() { + collect($this->api->confessions()->data)->each(function($confession) { + \App\Confession::create(['nami_id' => $confession->id, 'name' => $confession->descriptor, 'is_null' => $this->nullName === $confession->descriptor]); + }); + }); + } +} diff --git a/app/Initialize/InitializeController.php b/app/Initialize/InitializeController.php new file mode 100644 index 00000000..a57cfd25 --- /dev/null +++ b/app/Initialize/InitializeController.php @@ -0,0 +1,19 @@ +user()); + + return \Inertia::render('Initialize/Index'); + } +} diff --git a/app/Initialize/InitializeCountries.php b/app/Initialize/InitializeCountries.php new file mode 100644 index 00000000..413dd201 --- /dev/null +++ b/app/Initialize/InitializeCountries.php @@ -0,0 +1,22 @@ +bar = $bar; + $this->api = $api; + } + + public function handle() { + $this->bar->task('Synchronisiere Länder', function() { + collect($this->api->countries()->data)->each(function($nationality) { + \App\Country::create(['nami_id' => $nationality->id, 'name' => $nationality->descriptor]); + }); + }); + } +} diff --git a/app/Initialize/InitializeFees.php b/app/Initialize/InitializeFees.php new file mode 100644 index 00000000..5039883b --- /dev/null +++ b/app/Initialize/InitializeFees.php @@ -0,0 +1,23 @@ +bar = $bar; + $this->api = $api; + } + + public function handle() { + $this->bar->task('Synchronisiere Beiträge', function() { + collect($this->api->fees()->data)->each(function($fee) { + $title = preg_replace('/^.*\((.*)\).*$/', '\\1', $fee->descriptor); + \App\Fee::create(['nami_id' => $fee->id, 'title' => $title]); + }); + }); + } +} diff --git a/app/Initialize/InitializeGenders.php b/app/Initialize/InitializeGenders.php new file mode 100644 index 00000000..321dc242 --- /dev/null +++ b/app/Initialize/InitializeGenders.php @@ -0,0 +1,23 @@ +bar = $bar; + $this->api = $api; + } + + public function handle() { + $this->bar->task('Synchronisiere Geschlechter', function() { + collect($this->api->genders()->data)->each(function($gender) { + \App\Gender::create(['nami_id' => $gender->id, 'name' => $gender->descriptor, 'is_null' => $gender->descriptor === $this->nullName]); + }); + }); + } +} diff --git a/app/Initialize/InitializeJob.php b/app/Initialize/InitializeJob.php new file mode 100644 index 00000000..fada38ae --- /dev/null +++ b/app/Initialize/InitializeJob.php @@ -0,0 +1,51 @@ +user = $user; + } + + /** + * Execute the job. + * + * @return void + */ + public function handle() + { + $api = $this->user->getNamiApi(); + $bar = $this->createProgressBar('Initialisiere'); + + foreach (static::$initializers as $initializer) { + (new $initializer($bar, $api))->handle(); + } + + $bar->finish('Initialisierung abgeschlossen'); + } +} diff --git a/app/Initialize/InitializeMembers.php b/app/Initialize/InitializeMembers.php new file mode 100644 index 00000000..135a8230 --- /dev/null +++ b/app/Initialize/InitializeMembers.php @@ -0,0 +1,28 @@ +bar = $bar; + $this->api = $api; + } + + public function handle() { + $allMembers = collect([]); + + $this->bar->task('Finde Mitglieder', function() use (&$allMembers) { + $allMembers = collect($this->api->allMembers()->data); + }); + + $this->bar->tasks($allMembers, function($member) { + return "Synchronisiere {$member->entries_vorname} {$member->entries_nachname}"; + }, function($member) { + // Member::createFromNami($this->api->getMember($member->id)->data); + }); + } +} diff --git a/app/Initialize/InitializeNationalities.php b/app/Initialize/InitializeNationalities.php new file mode 100644 index 00000000..78a66e14 --- /dev/null +++ b/app/Initialize/InitializeNationalities.php @@ -0,0 +1,22 @@ +bar = $bar; + $this->api = $api; + } + + public function handle() { + $this->bar->task('Synchronisiere Nationalitäten', function() { + collect($this->api->nationalities()->data)->each(function($nationality) { + \App\Nationality::create(['nami_id' => $nationality->id, 'name' => $nationality->descriptor]); + }); + }); + } +} diff --git a/app/Initialize/InitializeRegions.php b/app/Initialize/InitializeRegions.php new file mode 100644 index 00000000..da077670 --- /dev/null +++ b/app/Initialize/InitializeRegions.php @@ -0,0 +1,23 @@ +bar = $bar; + $this->api = $api; + } + + public function handle() { + $this->bar->task('Synchronisiere Bundesländer', function() { + collect($this->api->regions()->data)->each(function($region) { + \App\Region::create(['nami_id' => $region->id, 'name' => $region->descriptor, 'is_null' => $region->descriptor === $this->nullName]); + }); + }); + } +} diff --git a/app/Member.php b/app/Member.php new file mode 100644 index 00000000..2062bbae --- /dev/null +++ b/app/Member.php @@ -0,0 +1,91 @@ + 'boolean', + 'keepdata' => 'boolean', + 'sendnewspaper' => 'boolean', + 'gender_id' => 'integer', + 'way_id' => 'integer', + 'country_id' => 'integer', + 'region_id' => 'integer', + 'confession_id' => 'integer', + 'nami_id' => 'integer', + ]; + + public function newCollection(array $models = []) + { + return new OwnCollection($models); + } + + //----------------------------------- Getters ----------------------------------- + public function getFullnameAttribute() { + return $this->firstname.' '.$this->lastname; + } + + //---------------------------------- Relations ---------------------------------- + public function country() + { + return $this->belongsTo(\App\Country::class); + } + + public function gender() + { + return $this->belongsTo(\App\Gender::class); + } + + public function region() + { + return $this->belongsTo(\App\Region::class); + } + + public function confession() + { + return $this->belongsTo(\App\Confession::class); + } + + public function payments() + { + return $this->hasMany(\App\Payment::class)->orderBy('nr'); + } + + public function way() + { + return $this->belongsTo(Way::class); + } + + public function nationality() + { + return $this->belongsTo(Nationality::class); + } + + public function memberships() + { + return $this->hasMany(Membership::class); + } + + public function subscription() + { + return $this->belongsTo(Subscription::class); + } +} diff --git a/app/Nami/InitializeService.php b/app/Nami/InitializeService.php new file mode 100644 index 00000000..9c2e7d89 --- /dev/null +++ b/app/Nami/InitializeService.php @@ -0,0 +1,17 @@ +api = $api; + } + + public function handle() { + dd(auth()->user()->getNamiService()->fees()); + } + +} diff --git a/app/Nationality.php b/app/Nationality.php new file mode 100644 index 00000000..2c07a710 --- /dev/null +++ b/app/Nationality.php @@ -0,0 +1,10 @@ +namespace($this->namespace) ->group(base_path('routes/web.php')); } diff --git a/app/Region.php b/app/Region.php new file mode 100644 index 00000000..82b30bcb --- /dev/null +++ b/app/Region.php @@ -0,0 +1,16 @@ + 'boolean' + ]; +} diff --git a/composer.json b/composer.json index d5e3f3ba..653ef3ad 100644 --- a/composer.json +++ b/composer.json @@ -7,11 +7,13 @@ "laravel" ], "repositories": [ - { "type": "path", "url": "./packages/laravel-nami", "options": {"symlink": true} } + { "type": "path", "url": "./packages/laravel-nami", "options": {"symlink": true} }, + { "type": "path", "url": "./packages/agnoster-installer", "options": {"symlink": true} } ], "license": "MIT", "require": { "php": "^7.2.5", + "aweos/agnoster-installer": "^1.0", "fideloper/proxy": "^4.2", "fruitcake/laravel-cors": "^1.0", "guzzlehttp/guzzle": "^6.3", @@ -19,6 +21,7 @@ "laravel/framework": "^7.0", "laravel/tinker": "^2.0", "laravel/ui": "^2.0", + "predis/predis": "^1.1", "spatie/laravel-medialibrary": "^7.19", "zoomyboy/laravel-nami": "dev-master" }, diff --git a/composer.lock b/composer.lock index 9b8d4677..584b74a0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "62db182c80f51832cfe1d9cef34a9063", + "content-hash": "c847473848098caa2e954501424d7009", "packages": [ { "name": "asm89/stack-cors", @@ -58,6 +58,34 @@ ], "time": "2019-12-24T22:41:47+00:00" }, + { + "name": "aweos/agnoster-installer", + "version": "1.0.0", + "dist": { + "type": "path", + "url": "./packages/agnoster-installer", + "reference": "de957edea4f5a7571f4979a5fa4e43b7d22eeff9" + }, + "bin": [ + "bin/agnoster" + ], + "type": "library", + "autoload": { + "psr-4": { + "Aweos\\Agnoster\\": "src/" + } + }, + "authors": [ + { + "name": "philipp lang", + "email": "philipp@aweos.de" + } + ], + "description": "Agnoster Backend package for UI scaffolding", + "transport-options": { + "symlink": true + } + }, { "name": "brick/math", "version": "0.8.14", @@ -1775,6 +1803,56 @@ ], "time": "2020-03-21T18:07:53+00:00" }, + { + "name": "predis/predis", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/nrk/predis.git", + "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1", + "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "suggest": { + "ext-curl": "Allows access to Webdis when paired with phpiredis", + "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol" + }, + "type": "library", + "autoload": { + "psr-4": { + "Predis\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniele Alessandri", + "email": "suppakilla@gmail.com", + "homepage": "http://clorophilla.net" + } + ], + "description": "Flexible and feature-complete Redis client for PHP and HHVM", + "homepage": "http://github.com/nrk/predis", + "keywords": [ + "nosql", + "predis", + "redis" + ], + "time": "2016-06-16T16:22:20+00:00" + }, { "name": "psr/container", "version": "1.0.0", diff --git a/database/migrations/2017_07_04_223230_create_members_table.php b/database/migrations/2017_07_04_223230_create_members_table.php new file mode 100644 index 00000000..31228daa --- /dev/null +++ b/database/migrations/2017_07_04_223230_create_members_table.php @@ -0,0 +1,59 @@ +increments('id'); + $table->string('firstname'); + $table->string('lastname'); + $table->string('nickname')->nullable(); + $table->integer('gender_id')->unsigned()->nullable(); + $table->integer('country_id')->unsigned(); + $table->string('other_country')->nullable(); + $table->integer('confession_id')->unsigned()->nullable(); + $table->date('birthday'); + $table->date('joined_at'); + $table->boolean('keepdata'); + $table->boolean('sendnewspaper'); + $table->string('address'); + $table->string('further_address')->nullable(); + $table->string('zip'); + $table->string('city'); + $table->string('region_id')->nullable(); + $table->string('phone')->nullable(); + $table->string('mobile')->nullable(); + $table->string('business_phone')->nullable(); + $table->string('fax')->nullable(); + $table->integer('way_id'); + $table->string('email')->nullable(); + $table->string('email_parents')->nullable(); + $table->boolean('active')->default(1); + $table->integer('nami_id')->nullable(); + $table->integer('nationality_id')->unsigned(); + $table->integer('subscription_id')->nullable(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('members'); + } +} diff --git a/database/migrations/2014_10_12_100000_create_password_resets_table.php b/database/migrations/2017_07_04_235624_create_countries_table.php similarity index 54% rename from database/migrations/2014_10_12_100000_create_password_resets_table.php rename to database/migrations/2017_07_04_235624_create_countries_table.php index 0ee0a36a..b4702f09 100644 --- a/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/database/migrations/2017_07_04_235624_create_countries_table.php @@ -1,10 +1,10 @@ string('email')->index(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); + Schema::create('countries', function (Blueprint $table) { + $table->increments('id'); + $table->string('name'); + $table->string('nami_id')->nullable(); }); } @@ -27,6 +27,6 @@ class CreatePasswordResetsTable extends Migration */ public function down() { - Schema::dropIfExists('password_resets'); + Schema::dropIfExists('countries'); } } diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2017_07_05_000438_create_genders_table.php similarity index 55% rename from database/migrations/2014_10_12_000000_create_users_table.php rename to database/migrations/2017_07_05_000438_create_genders_table.php index 621a24eb..4f9e307c 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2017_07_05_000438_create_genders_table.php @@ -1,10 +1,10 @@ id(); + Schema::create('genders', function (Blueprint $table) { + $table->increments('id'); $table->string('name'); - $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); - $table->string('password'); - $table->rememberToken(); + $table->boolean('is_null'); + $table->integer('nami_id'); $table->timestamps(); }); } @@ -31,6 +29,6 @@ class CreateUsersTable extends Migration */ public function down() { - Schema::dropIfExists('users'); + Schema::dropIfExists('genders'); } } diff --git a/database/migrations/2017_07_05_000810_create_regions_table.php b/database/migrations/2017_07_05_000810_create_regions_table.php new file mode 100644 index 00000000..1ab27b1b --- /dev/null +++ b/database/migrations/2017_07_05_000810_create_regions_table.php @@ -0,0 +1,33 @@ +increments('id'); + $table->string('name'); + $table->boolean('is_null'); + $table->integer('nami_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('regions'); + } +} diff --git a/database/migrations/2017_07_05_001729_create_confessions_table.php b/database/migrations/2017_07_05_001729_create_confessions_table.php new file mode 100644 index 00000000..914f74ca --- /dev/null +++ b/database/migrations/2017_07_05_001729_create_confessions_table.php @@ -0,0 +1,33 @@ +increments('id'); + $table->string('name'); + $table->integer('nami_id')->nullable(); + $table->boolean('is_null'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('confessions'); + } +} diff --git a/database/migrations/2017_12_25_231219_create_ways_table.php b/database/migrations/2017_12_25_231219_create_ways_table.php new file mode 100644 index 00000000..12aa88a8 --- /dev/null +++ b/database/migrations/2017_12_25_231219_create_ways_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->string('title'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('ways'); + } +} diff --git a/database/migrations/2018_01_14_235348_create_nationalities_table.php b/database/migrations/2018_01_14_235348_create_nationalities_table.php new file mode 100644 index 00000000..9247492f --- /dev/null +++ b/database/migrations/2018_01_14_235348_create_nationalities_table.php @@ -0,0 +1,33 @@ +increments('id'); + $table->string('name'); + $table->integer('nami_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('nationalities'); + } +} diff --git a/database/migrations/2018_01_16_012910_create_activities_table.php b/database/migrations/2018_01_16_012910_create_activities_table.php new file mode 100644 index 00000000..d38070b5 --- /dev/null +++ b/database/migrations/2018_01_16_012910_create_activities_table.php @@ -0,0 +1,32 @@ +increments('id'); + $table->string('name'); + $table->integer('nami_id'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('activities'); + } +} diff --git a/database/migrations/2018_01_18_205354_create_memberships_table.php b/database/migrations/2018_01_18_205354_create_memberships_table.php new file mode 100644 index 00000000..1dbe8663 --- /dev/null +++ b/database/migrations/2018_01_18_205354_create_memberships_table.php @@ -0,0 +1,36 @@ +increments('id'); + $table->integer('activity_id'); + $table->integer('group_id')->nullable(); + $table->integer('member_id'); + $table->integer('nami_id')->nullable(); + $table->timestamps(); + $table->unique(['activity_id', 'group_id', 'member_id', 'nami_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('memberships'); + } +} diff --git a/database/migrations/2018_01_22_234145_create_fees_table.php b/database/migrations/2018_01_22_234145_create_fees_table.php new file mode 100644 index 00000000..b3876953 --- /dev/null +++ b/database/migrations/2018_01_22_234145_create_fees_table.php @@ -0,0 +1,32 @@ +increments('id'); + $table->string('title'); + $table->integer('nami_id'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('fees'); + } +} diff --git a/database/migrations/2018_01_22_235143_create_subscriptions_table.php b/database/migrations/2018_01_22_235143_create_subscriptions_table.php new file mode 100644 index 00000000..f8e71157 --- /dev/null +++ b/database/migrations/2018_01_22_235143_create_subscriptions_table.php @@ -0,0 +1,32 @@ +increments('id'); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('subscriptions'); + } +} diff --git a/database/migrations/2020_04_11_215742_create_groups_table.php b/database/migrations/2020_04_11_215742_create_groups_table.php new file mode 100644 index 00000000..f37e0f91 --- /dev/null +++ b/database/migrations/2020_04_11_215742_create_groups_table.php @@ -0,0 +1,32 @@ +increments('id'); + $table->string('name'); + $table->string('nami_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('groups'); + } +} diff --git a/database/migrations/2020_04_11_215831_create_activity_group_table.php b/database/migrations/2020_04_11_215831_create_activity_group_table.php new file mode 100644 index 00000000..f1aaf20b --- /dev/null +++ b/database/migrations/2020_04_11_215831_create_activity_group_table.php @@ -0,0 +1,32 @@ +integer('activity_id'); + $table->integer('group_id'); + $table->unique(['activity_id', 'group_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('activity_group'); + } +} diff --git a/package-lock.json b/package-lock.json index ad808c82..28a9441e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1344,6 +1344,11 @@ } } }, + "after": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", + "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=" + }, "aggregate-error": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.0.1.tgz", @@ -1568,6 +1573,11 @@ "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", "dev": true }, + "arraybuffer.slice": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", + "integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog==" + }, "arrify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", @@ -1642,8 +1652,7 @@ "async-limiter": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", - "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==", - "dev": true + "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" }, "atob": { "version": "2.1.2", @@ -1793,6 +1802,11 @@ "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==" }, + "backo2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", + "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=" + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -1853,6 +1867,11 @@ } } }, + "base64-arraybuffer": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", + "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=" + }, "base64-js": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", @@ -1865,6 +1884,14 @@ "integrity": "sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY=", "dev": true }, + "better-assert": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", + "integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=", + "requires": { + "callsite": "1.0.0" + } + }, "big.js": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", @@ -1887,6 +1914,11 @@ "file-uri-to-path": "1.0.0" } }, + "blob": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", + "integrity": "sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig==" + }, "bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -2199,6 +2231,11 @@ "caller-callsite": "^2.0.0" } }, + "callsite": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", + "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=" + }, "callsites": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", @@ -2507,12 +2544,22 @@ "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", "dev": true }, + "component-bind": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", + "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=" + }, "component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", "dev": true }, + "component-inherit": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", + "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=" + }, "compressible": { "version": "2.0.18", "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz", @@ -3433,6 +3480,64 @@ "once": "^1.4.0" } }, + "engine.io-client": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.4.0.tgz", + "integrity": "sha512-a4J5QO2k99CM2a0b12IznnyQndoEvtA4UAldhGzKqnHf42I3Qs2W5SPnDvatZRcMaNZs4IevVicBPayxYt6FwA==", + "requires": { + "component-emitter": "1.2.1", + "component-inherit": "0.0.3", + "debug": "~4.1.0", + "engine.io-parser": "~2.2.0", + "has-cors": "1.1.0", + "indexof": "0.0.1", + "parseqs": "0.0.5", + "parseuri": "0.0.5", + "ws": "~6.1.0", + "xmlhttprequest-ssl": "~1.5.4", + "yeast": "0.1.2" + }, + "dependencies": { + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=" + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "ws": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.4.tgz", + "integrity": "sha512-eqZfL+NE/YQc1/ZynhojeV8q+H050oR8AZ2uIev7RU10svA9ZnJUddHcOUZTJLinZ9yEfdA2kSATS2qZK5fhJA==", + "requires": { + "async-limiter": "~1.0.0" + } + } + } + }, + "engine.io-parser": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.2.0.tgz", + "integrity": "sha512-6I3qD9iUxotsC5HEMuuGsKA0cXerGz+4uGcXQEkfBidgKf0amsjrrtwcbwK/nzpZBxclXlV7gGl9dgWvu4LF6w==", + "requires": { + "after": "0.8.2", + "arraybuffer.slice": "~0.0.7", + "base64-arraybuffer": "0.1.5", + "blob": "0.0.5", + "has-binary2": "~1.0.2" + } + }, "enhanced-resolve": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.1.1.tgz", @@ -4953,6 +5058,26 @@ "ansi-regex": "^2.0.0" } }, + "has-binary2": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz", + "integrity": "sha512-G1LWKhDSvhGeAQ8mPVQlqNcOB2sJdwATtZKl2pDKKHfpf/rYj24lkinxf69blJbnsvtqqNU+L3SL50vzZhXOnw==", + "requires": { + "isarray": "2.0.1" + }, + "dependencies": { + "isarray": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", + "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=" + } + } + }, + "has-cors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz", + "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=" + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -5347,6 +5472,11 @@ "resolved": "https://registry.npmjs.org/indexes-of/-/indexes-of-1.0.1.tgz", "integrity": "sha1-8w9xbI4r00bHtn0985FVZqfAVgc=" }, + "indexof": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", + "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=" + }, "infer-owner": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz", @@ -5848,6 +5978,11 @@ "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", "dev": true }, + "laravel-echo": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/laravel-echo/-/laravel-echo-1.7.0.tgz", + "integrity": "sha512-ZihYxqqhR1FAllsdYLwHHkopyN9pujG4H0p2SIK1r4sTnQnZw+P9WAkDF3QoHJFoCo44AUKWmyw7G/HqWgnObQ==" + }, "laravel-mix": { "version": "5.0.4", "resolved": "https://registry.npmjs.org/laravel-mix/-/laravel-mix-5.0.4.tgz", @@ -6647,6 +6782,11 @@ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" }, + "object-component": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz", + "integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=" + }, "object-copy": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", @@ -6955,6 +7095,22 @@ "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", "dev": true }, + "parseqs": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", + "integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=", + "requires": { + "better-assert": "~1.0.0" + } + }, + "parseuri": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz", + "integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=", + "requires": { + "better-assert": "~1.0.0" + } + }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -9048,6 +9204,69 @@ } } }, + "socket.io-client": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.3.0.tgz", + "integrity": "sha512-cEQQf24gET3rfhxZ2jJ5xzAOo/xhZwK+mOqtGRg5IowZsMgwvHwnf/mCRapAAkadhM26y+iydgwsXGObBB5ZdA==", + "requires": { + "backo2": "1.0.2", + "base64-arraybuffer": "0.1.5", + "component-bind": "1.0.0", + "component-emitter": "1.2.1", + "debug": "~4.1.0", + "engine.io-client": "~3.4.0", + "has-binary2": "~1.0.2", + "has-cors": "1.1.0", + "indexof": "0.0.1", + "object-component": "0.0.3", + "parseqs": "0.0.5", + "parseuri": "0.0.5", + "socket.io-parser": "~3.3.0", + "to-array": "0.1.4" + }, + "dependencies": { + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=" + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, + "socket.io-parser": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.3.0.tgz", + "integrity": "sha512-hczmV6bDgdaEbVqhAeVMM/jfUfzuEZHsQg6eOmLgJht6G3mPKMxYm75w2+qhAQZ+4X+1+ATZ+QFKeOZD5riHng==", + "requires": { + "component-emitter": "1.2.1", + "debug": "~3.1.0", + "isarray": "2.0.1" + }, + "dependencies": { + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=" + }, + "isarray": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", + "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=" + } + } + }, "sockjs": { "version": "0.3.19", "resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.19.tgz", @@ -9794,6 +10013,11 @@ "upper-case": "^1.0.3" } }, + "to-array": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", + "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=" + }, "to-arraybuffer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", @@ -10852,6 +11076,11 @@ "async-limiter": "~1.0.0" } }, + "xmlhttprequest-ssl": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz", + "integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4=" + }, "xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", @@ -11038,6 +11267,11 @@ "camelcase": "^5.0.0", "decamelize": "^1.2.0" } + }, + "yeast": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", + "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=" } } } diff --git a/package.json b/package.json index a7207b1a..7333665a 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,9 @@ "agnoster": "file:resources/js/libs/agnoster", "font-awesome": "^4.7.0", "js-modules": "file:resources/js/libs/js-modules", + "laravel-echo": "^1.7.0", "postcss-import": "^12.0.1", + "socket.io-client": "^2.3.0", "tailwindcss": "^1.2.0", "vue-inputmask": "^0.2.1", "vuex": "^3.1.3" diff --git a/resources/js/app.js b/resources/js/app.js index a12ffb96..28e5c666 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -4,6 +4,8 @@ import { Checkbox } from 'js-modules'; import { InertiaApp } from '@inertiajs/inertia-vue' import store from './store.js'; import 'font-awesome/css/font-awesome.css'; +import Echo from 'laravel-echo'; +window.io = require('socket.io-client'); Vue.use(modules); Vue.use(init); @@ -12,6 +14,11 @@ Vue.component('checkbox', Checkbox); const app = document.getElementById('app') +window.Echo = new Echo({ + broadcaster: 'socket.io', + host: window.location.hostname+':'+document.querySelector('meta[name=socketport]').getAttribute('content'), +}); + new Vue({ render: h => h(InertiaApp, { props: { diff --git a/resources/js/layouts/App.vue b/resources/js/layouts/App.vue index 3b8d8e9b..51b21f03 100644 --- a/resources/js/layouts/App.vue +++ b/resources/js/layouts/App.vue @@ -1,5 +1,5 @@