From 18e8b38a3401249efb4338319fd7dbc791ca740a Mon Sep 17 00:00:00 2001 From: philipp lang <philipp@aweos.de> Date: Sun, 11 Apr 2021 18:17:40 +0200 Subject: [PATCH] Add billKind --- app/Bill/BillKind.php | 11 +++ app/Member/Member.php | 15 +++- app/Member/MemberController.php | 4 +- app/Member/MemberResource.php | 2 + composer.lock | 70 ++++--------------- ...2020_04_12_223230_create_members_table.php | 11 +++ phpunit.xml | 3 + resources/js/views/member/Edit.vue | 7 ++ resources/js/views/member/Index.vue | 5 ++ 9 files changed, 71 insertions(+), 57 deletions(-) create mode 100644 app/Bill/BillKind.php diff --git a/app/Bill/BillKind.php b/app/Bill/BillKind.php new file mode 100644 index 00000000..fea99c2d --- /dev/null +++ b/app/Bill/BillKind.php @@ -0,0 +1,11 @@ +<?php + +namespace App\Bill; + +use Illuminate\Database\Eloquent\Model; + +class BillKind extends Model +{ + public $fillable = ['name']; + public $timestamps = false; +} diff --git a/app/Member/Member.php b/app/Member/Member.php index dbf15d10..4c3ee3db 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -5,12 +5,13 @@ namespace App\Member; use App\Events\MemberCreated; use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Notifiable; +use App\Bill\BillKind; class Member extends Model { use Notifiable; - public $fillable = ['firstname', 'lastname', 'nickname', 'other_country', 'birthday', 'joined_at', 'send_newspaper', 'address', 'further_address', 'zip', 'location', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'nami_id', 'letter_address', 'country_id', 'way_id', 'nationality_id', 'fee_id', 'region_id', 'gender_id', 'confession_id', 'letter_address']; + public $fillable = ['firstname', 'lastname', 'nickname', 'other_country', 'birthday', 'joined_at', 'send_newspaper', 'address', 'further_address', 'zip', 'location', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'nami_id', 'letter_address', 'country_id', 'way_id', 'nationality_id', 'fee_id', 'region_id', 'gender_id', 'confession_id', 'letter_address', 'bill_kind_id']; public $dates = ['joined_at', 'birthday']; @@ -83,4 +84,16 @@ class Member extends Model { return $this->belongsTo(App\Fee::class); } + + public function billKind() { + return $this->belongsTo(BillKind::class); + } + + public static function booted() { + static::updating(function($model) { + if ($model->nami_id === null) { + $model->bill_kind_id = null; + } + }); + } } diff --git a/app/Member/MemberController.php b/app/Member/MemberController.php index 2c19f127..9d2b1599 100644 --- a/app/Member/MemberController.php +++ b/app/Member/MemberController.php @@ -10,6 +10,7 @@ use App\Region; use App\Country; use App\Nationality; use App\Confession; +use App\Bill\BillKind; class MemberController extends Controller { @@ -18,7 +19,7 @@ class MemberController extends Controller session()->put('title', 'Mitglieder'); return \Inertia::render('member/Index', [ - 'data' => MemberResource::collection(Member::search($request->query('search', null))->paginate(15)) + 'data' => MemberResource::collection(Member::search($request->query('search', null))->with('billKind')->paginate(15)) ]); } @@ -27,6 +28,7 @@ class MemberController extends Controller session()->put('title', 'Mitglied bearbeiten'); return \Inertia::render('member/Edit', [ + 'billKinds' => BillKind::get()->pluck('name', 'id'), 'genders' => Gender::get()->pluck('name', 'id'), 'countries' => Country::get()->pluck('name', 'id'), 'regions' => Region::where('is_null', false)->get()->pluck('name', 'id'), diff --git a/app/Member/MemberResource.php b/app/Member/MemberResource.php index 668a5893..0677fc35 100644 --- a/app/Member/MemberResource.php +++ b/app/Member/MemberResource.php @@ -41,6 +41,8 @@ class MemberResource extends JsonResource 'other_country' => $this->other_country, 'confession_id' => $this->confession_id, 'letter_address' => $this->letter_address, + 'bill_kind_id' => $this->bill_kind_id, + 'bill_kind_name' => optional($this->billKind)->name, ]; } } diff --git a/composer.lock b/composer.lock index 18bfd098..81690c9f 100644 --- a/composer.lock +++ b/composer.lock @@ -206,43 +206,6 @@ }, "time": "2021-04-07T01:06:46+00:00" }, - { - "name": "dnoegel/php-xdg-base-dir", - "version": "v0.1.1", - "source": { - "type": "git", - "url": "https://github.com/dnoegel/php-xdg-base-dir.git", - "reference": "8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/dnoegel/php-xdg-base-dir/zipball/8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd", - "reference": "8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "~7.0|~6.0|~5.0|~4.8.35" - }, - "type": "library", - "autoload": { - "psr-4": { - "XdgBaseDir\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "implementation of xdg base directory specification for php", - "support": { - "issues": "https://github.com/dnoegel/php-xdg-base-dir/issues", - "source": "https://github.com/dnoegel/php-xdg-base-dir/tree/v0.1.1" - }, - "time": "2019-12-04T15:06:13+00:00" - }, { "name": "doctrine/inflector", "version": "2.0.3", @@ -2946,20 +2909,19 @@ }, { "name": "psy/psysh", - "version": "v0.10.7", + "version": "v0.10.8", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "a395af46999a12006213c0c8346c9445eb31640c" + "reference": "e4573f47750dd6c92dca5aee543fa77513cbd8d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/a395af46999a12006213c0c8346c9445eb31640c", - "reference": "a395af46999a12006213c0c8346c9445eb31640c", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/e4573f47750dd6c92dca5aee543fa77513cbd8d3", + "reference": "e4573f47750dd6c92dca5aee543fa77513cbd8d3", "shasum": "" }, "require": { - "dnoegel/php-xdg-base-dir": "0.1.*", "ext-json": "*", "ext-tokenizer": "*", "nikic/php-parser": "~4.0|~3.0|~2.0|~1.3", @@ -3016,9 +2978,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.10.7" + "source": "https://github.com/bobthecow/psysh/tree/v0.10.8" }, - "time": "2021-03-14T02:14:56+00:00" + "time": "2021-04-10T16:23:39+00:00" }, { "name": "ralouphie/getallheaders", @@ -6025,11 +5987,7 @@ "dist": { "type": "path", "url": "./packages/laravel-nami", - "reference": "a317215554e093e7499d823d136d6e0a81e4d505" - }, - "require-dev": { - "guzzlehttp/guzzle": "^6.3.1|^7.0", - "orchestra/testbench": "^5.3" + "reference": "5827a5c9cccf439a3ac51b1bd154dc1c2803c5ce" }, "type": "library", "extra": { @@ -6046,7 +6004,9 @@ }, "autoload-dev": { "psr-4": { - "Zoomyboy\\LaravelNami\\Tests\\": "tests/" + "Zoomyboy\\LaravelNami\\Tests\\": "tests/", + "orchestra/testbench": "^5.3", + "guzzlehttp/guzzle": "^6.3.1|^7.0" } }, "authors": [ @@ -6199,16 +6159,16 @@ }, { "name": "facade/ignition", - "version": "2.8.2", + "version": "2.8.3", "source": { "type": "git", "url": "https://github.com/facade/ignition.git", - "reference": "cb7f790e6306caeb4a9ffe21e59942b7128cc630" + "reference": "a8201d51aae83addceaef9344592a3b068b5d64d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/facade/ignition/zipball/cb7f790e6306caeb4a9ffe21e59942b7128cc630", - "reference": "cb7f790e6306caeb4a9ffe21e59942b7128cc630", + "url": "https://api.github.com/repos/facade/ignition/zipball/a8201d51aae83addceaef9344592a3b068b5d64d", + "reference": "a8201d51aae83addceaef9344592a3b068b5d64d", "shasum": "" }, "require": { @@ -6272,7 +6232,7 @@ "issues": "https://github.com/facade/ignition/issues", "source": "https://github.com/facade/ignition" }, - "time": "2021-04-08T10:42:53+00:00" + "time": "2021-04-09T20:45:59+00:00" }, { "name": "facade/ignition-contracts", diff --git a/database/migrations/2020_04_12_223230_create_members_table.php b/database/migrations/2020_04_12_223230_create_members_table.php index 68b3c6c8..3f4cbdc5 100644 --- a/database/migrations/2020_04_12_223230_create_members_table.php +++ b/database/migrations/2020_04_12_223230_create_members_table.php @@ -3,6 +3,7 @@ use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; +use App\Bill\BillKind; class CreateMembersTable extends Migration { @@ -13,6 +14,14 @@ class CreateMembersTable extends Migration */ public function up() { + Schema::create('bill_kinds', function (Blueprint $table) { + $table->id(); + $table->string('name'); + }); + + BillKind::create(['name' => 'E-Mail']); + BillKind::create(['name' => 'Post']); + Schema::create('members', function (Blueprint $table) { $table->id(); $table->string('firstname'); @@ -40,6 +49,7 @@ class CreateMembersTable extends Migration $table->foreignId('nationality_id')->constrained(); $table->foreignId('fee_id')->constrained(); $table->text('letter_address')->nullable(); + $table->foreignId('bill_kind_id')->nullable()->constrained(); $table->timestamps(); }); @@ -53,5 +63,6 @@ class CreateMembersTable extends Migration public function down() { Schema::dropIfExists('members'); + Schema::dropIfExists('bill_kinds'); } } diff --git a/phpunit.xml b/phpunit.xml index 5ef025a3..1b01326a 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -10,6 +10,9 @@ <testsuite name="Feature"> <directory suffix="Test.php">./tests/Feature</directory> </testsuite> + <testsuite name="Nami"> + <directory suffix="Test.php">./packages/laravel-nami/tests</directory> + </testsuite> </testsuites> <filter> <whitelist processUncoveredFilesFromWhitelist="true"> diff --git a/resources/js/views/member/Edit.vue b/resources/js/views/member/Edit.vue index 90592bc0..c4fcae24 100644 --- a/resources/js/views/member/Edit.vue +++ b/resources/js/views/member/Edit.vue @@ -66,6 +66,11 @@ <f-text id="fax" v-model="inner.fax" label="Fax"></f-text> </div> </div> + <div class="grid grid-cols-2 gap-3 p-4" v-if="menuTitle == 'System'"> + <div> + <f-select :options="billKinds" id="bill_kind_id" v-model="inner.bill_kind_id" label="Rechnung versenden über"></f-select> + </div> + </div> <div class="grid grid-cols-2 gap-3 p-4" v-if="menuTitle == 'Sonstiges'"> <div> <f-text id="other_country" v-model="inner.other_country" label="Andere Staatsangehörigkeit"></f-text> @@ -93,6 +98,7 @@ export default { menu: [ { title: 'Stammdaten' }, { title: 'Kontakt' }, + { title: 'System' }, { title: 'Sonstiges' }, ] }; @@ -106,6 +112,7 @@ export default { countries: {}, nationalities: {}, confessions: {}, + billKinds: {}, }, methods: { diff --git a/resources/js/views/member/Index.vue b/resources/js/views/member/Index.vue index eb464645..f44bc864 100644 --- a/resources/js/views/member/Index.vue +++ b/resources/js/views/member/Index.vue @@ -9,6 +9,7 @@ <div class="px-6 text-gray-200 font-semibold py-3 border-gray-600 border-b">Ort</div> <div class="px-6 text-gray-200 font-semibold py-3 border-gray-600 border-b">Mittendrin</div> <div class="px-6 text-gray-200 font-semibold py-3 border-gray-600 border-b">Nami</div> + <div class="px-6 text-gray-200 font-semibold py-3 border-gray-600 border-b">Rechnung</div> <div class="px-6 text-gray-200 font-semibold py-3 border-gray-600 border-b">Geburtstag</div> <div class="px-6 text-gray-200 font-semibold py-3 border-gray-600 border-b">Eintritt</div> </header> @@ -25,6 +26,10 @@ <div class="py-1 px-6"> <v-bool v-model="member.nami_id !== null"></v-bool> </div> + <div class="py-1 px-6"> + <div class="py-1 rounded-full flex text-xs items-center justify-center leading-none bg-primary-900" v-text="member.bill_kind_name" v-if="member.bill_kind_name"></div> + <div class="py-1 rounded-full flex text-xs items-center justify-center leading-none" v-else>Kein</div> + </div> <div class="py-1 px-6" v-text="`${member.birthday_human}`"></div> <div class="py-1 px-6" v-text="`${member.joined_at_human}`"></div> </inertia-link>