Add Initializer

This commit is contained in:
philipp lang 2020-04-12 00:26:44 +02:00
parent 7cfe27ac57
commit 16fd910ec0
45 changed files with 1280 additions and 28 deletions

21
app/Activity.php Normal file
View File

@ -0,0 +1,21 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Activity extends Model
{
public $fillable = ['name', 'nami_id'];
public $timestamps = false;
public $casts = [
'nami_id' => 'integer'
];
public function groups() {
return $this->belongsToMany(Group::class);
}
}

12
app/Confession.php Normal file
View File

@ -0,0 +1,12 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Confession extends Model
{
public $fillable = ['name', 'nami_id', 'is_null'];
public $timestamps = false;
}

12
app/Country.php Normal file
View File

@ -0,0 +1,12 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Country extends Model
{
public $fillable = ['name', 'nami_id'];
public $timestamps = false;
}

11
app/Fee.php Normal file
View File

@ -0,0 +1,11 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Fee extends Model
{
public $fillable = ['title', 'nami_id'];
public $timestamps = false;
}

14
app/Gender.php Normal file
View File

@ -0,0 +1,14 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Gender extends Model
{
public $fillable = ['name', 'is_null', 'nami_id'];
public $casts = [
'is_null' => 'boolean'
];
}

16
app/Group.php Normal file
View File

@ -0,0 +1,16 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Group extends Model
{
public $fillable = ['name', 'nami_id'];
public $timestamps = false;
public function activities() {
return $this->belongsToMany(Activity::class);
}
}

View File

@ -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' => [

View File

@ -0,0 +1,39 @@
<?php
namespace App\Http\Middleware;
use Closure;
class RedirectIfNotInitializedMiddleware
{
public $dontRedirect = ['initialize.index', 'initialize.store'];
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if(!$this->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;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Initialize;
class InitializeActivities {
private $bar;
private $api;
public function __construct($bar, $api) {
$this->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);
});
});
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\Initialize;
class InitializeConfessions {
private $bar;
private $api;
public $nullName = 'ohne Konfession';
public function __construct($bar, $api) {
$this->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]);
});
});
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Initialize;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class InitializeController extends Controller
{
public function index() {
return \Inertia::render('Initialize/Index');
}
public function store() {
InitializeJob::dispatch(auth()->user());
return \Inertia::render('Initialize/Index');
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Initialize;
class InitializeCountries {
private $bar;
private $api;
public function __construct($bar, $api) {
$this->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]);
});
});
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\Initialize;
class InitializeFees {
private $bar;
private $api;
public function __construct($bar, $api) {
$this->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]);
});
});
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\Initialize;
class InitializeGenders {
private $bar;
private $api;
public $nullName = 'keine Angabe';
public function __construct($bar, $api) {
$this->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]);
});
});
}
}

View File

@ -0,0 +1,51 @@
<?php
namespace App\Initialize;
use App\User;
use App\Member;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Aweos\Agnoster\Progress\HasProgress;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class InitializeJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasProgress;
public $user;
public static $initializers = [
InitializeNationalities::class,
InitializeFees::class,
InitializeConfessions::class,
InitializeCountries::class,
InitializeGenders::class,
InitializeRegions::class,
InitializeActivities::class,
];
public function __construct(User $user)
{
$this->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');
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Initialize;
class InitializeMembers {
private $bar;
private $api;
public function __construct($bar, $api) {
$this->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);
});
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Initialize;
class InitializeNationalities {
private $bar;
private $api;
public function __construct($bar, $api) {
$this->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]);
});
});
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\Initialize;
class InitializeRegions {
private $bar;
private $api;
private $nullName = 'Nicht-DE (Ausland)';
public function __construct($bar, $api) {
$this->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]);
});
});
}
}

91
app/Member.php Normal file
View File

@ -0,0 +1,91 @@
<?php
namespace App;
use App\Collections\OwnCollection;
use App\Events\MemberCreated;
use App\Nami\Traits\HasNamiId;
use App\Relations\HasSameRelation;
use App\Traits\HasNamiFallbacks;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
class Member extends Model
{
use Notifiable;
use HasSameRelation;
use HasNamiId;
use HasNamiFallbacks;
public $fillable = ['firstname', 'lastname', 'nickname', 'other_country', 'birthday', 'joined_at', 'keepdata', 'sendnewspaper', 'address', 'further_address', 'zip', 'city', 'phone', 'mobile', 'business_phone', 'fax', 'email', 'email_parents', 'nami_id', 'active', 'letter_address', 'country_id', 'way_id', 'nationality_id', 'subscription_id', 'region_id', 'gender_id', 'confession_id'];
public $dates = ['joined_at', 'birthday'];
public $casts = [
'active' => '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);
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Nami;
class InitializeService {
public $api;
public function __construct(Api $api) {
$this->api = $api;
}
public function handle() {
dd(auth()->user()->getNamiService()->fees());
}
}

10
app/Nationality.php Normal file
View File

@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Nationality extends Model
{
public $fillable = ['name','nami_id'];
}

View File

@ -59,7 +59,6 @@ class RouteServiceProvider extends ServiceProvider
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}

16
app/Region.php Normal file
View File

@ -0,0 +1,16 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Region extends Model
{
public $timestamps = false;
public $fillable = ['name', 'nami_id', 'is_null'];
public $casts = [
'is_null' => 'boolean'
];
}

View File

@ -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"
},

80
composer.lock generated
View File

@ -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",

View File

@ -0,0 +1,59 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateMembersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('members', function (Blueprint $table) {
$table->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');
}
}

View File

@ -1,10 +1,10 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePasswordResetsTable extends Migration
class CreateCountriesTable extends Migration
{
/**
* Run the migrations.
@ -13,10 +13,10 @@ class CreatePasswordResetsTable extends Migration
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->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');
}
}

View File

@ -1,10 +1,10 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
class CreateGendersTable extends Migration
{
/**
* Run the migrations.
@ -13,13 +13,11 @@ class CreateUsersTable extends Migration
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->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');
}
}

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateRegionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('regions', function (Blueprint $table) {
$table->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');
}
}

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateConfessionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('confessions', function (Blueprint $table) {
$table->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');
}
}

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateWaysTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ways', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('ways');
}
}

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateNationalitiesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('nationalities', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->integer('nami_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('nationalities');
}
}

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateActivitiesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('activities', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->integer('nami_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('activities');
}
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateMembershipsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('memberships', function (Blueprint $table) {
$table->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');
}
}

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateFeesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('fees', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->integer('nami_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('fees');
}
}

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSubscriptionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('subscriptions', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('subscriptions');
}
}

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateGroupsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('groups', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('nami_id')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('groups');
}
}

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateActivityGroupTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('activity_group', function (Blueprint $table) {
$table->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');
}
}

238
package-lock.json generated
View File

@ -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="
}
}
}

View File

@ -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"

7
resources/js/app.js vendored
View File

@ -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: {

View File

@ -1,5 +1,5 @@
<template>
<div id="app" class="font-sans flex flex-col flex-grow">
<div class="app font-sans flex flex-col flex-grow">
<notification :errors="$page.errors"></notification>
<process></process>
<wrapper
@ -20,7 +20,7 @@
<script>
import Notification from 'agnoster/components/Notification.vue';
import Process from 'agnoster/components/Process.vue';
import Process from 'agnoster/components/Progress.vue';
import Wrapper from 'agnoster/components/Wrapper.vue';
import Mainnav from 'agnoster/components/Mainnav.vue';

View File

@ -0,0 +1,16 @@
<template>
<div class="p-6">
<div class="text-lg">Deine App wurde noch nicht initialisiert. Nami-Daten jetzt übernehmen?</div>
<a class="btn btn-primary mt-6 inline-block" href="#" @click.prevent="$inertia.post('/initialize', { preserveState: true, replace: false })">Jetzt initialisieren</a>
</div>
</template>
<script>
import App from '../../layouts/App';
export default {
layout: App
};
</script>

View File

@ -3,6 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<meta name="socketport" content="{{env('SOCKET_PORT')}}" />
<link href="{{ mix('/css/app.css') }}" rel="stylesheet" />
<script src="{{ mix('/js/app.js') }}" defer></script>
</head>

View File

@ -1,8 +1,14 @@
<?php
Auth::routes(['register' => false]);
use App\Http\Controllers\HomeController;
use App\Initialize\InitializeController;
Route::group(['middleware' => 'auth:web'], function () {
Route::get('/', 'HomeController')->name('home');
Route::group(['namespace' => 'App\\Http\\Controllers'], function() {
Auth::routes(['register' => false]);
});
Route::group(['middleware' => 'auth:web'], function () {
Route::get('/', HomeController::class)->name('home');
Route::resource('/initialize', InitializeController::class);
});