Add billKind

This commit is contained in:
philipp lang 2021-04-11 18:17:40 +02:00
parent 0602d86e69
commit 18e8b38a34
9 changed files with 71 additions and 57 deletions

11
app/Bill/BillKind.php Normal file
View File

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

View File

@ -5,12 +5,13 @@ namespace App\Member;
use App\Events\MemberCreated; use App\Events\MemberCreated;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
use App\Bill\BillKind;
class Member extends Model class Member extends Model
{ {
use Notifiable; 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']; public $dates = ['joined_at', 'birthday'];
@ -83,4 +84,16 @@ class Member extends Model
{ {
return $this->belongsTo(App\Fee::class); 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;
}
});
}
} }

View File

@ -10,6 +10,7 @@ use App\Region;
use App\Country; use App\Country;
use App\Nationality; use App\Nationality;
use App\Confession; use App\Confession;
use App\Bill\BillKind;
class MemberController extends Controller class MemberController extends Controller
{ {
@ -18,7 +19,7 @@ class MemberController extends Controller
session()->put('title', 'Mitglieder'); session()->put('title', 'Mitglieder');
return \Inertia::render('member/Index', [ 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'); session()->put('title', 'Mitglied bearbeiten');
return \Inertia::render('member/Edit', [ return \Inertia::render('member/Edit', [
'billKinds' => BillKind::get()->pluck('name', 'id'),
'genders' => Gender::get()->pluck('name', 'id'), 'genders' => Gender::get()->pluck('name', 'id'),
'countries' => Country::get()->pluck('name', 'id'), 'countries' => Country::get()->pluck('name', 'id'),
'regions' => Region::where('is_null', false)->get()->pluck('name', 'id'), 'regions' => Region::where('is_null', false)->get()->pluck('name', 'id'),

View File

@ -41,6 +41,8 @@ class MemberResource extends JsonResource
'other_country' => $this->other_country, 'other_country' => $this->other_country,
'confession_id' => $this->confession_id, 'confession_id' => $this->confession_id,
'letter_address' => $this->letter_address, 'letter_address' => $this->letter_address,
'bill_kind_id' => $this->bill_kind_id,
'bill_kind_name' => optional($this->billKind)->name,
]; ];
} }
} }

70
composer.lock generated
View File

@ -206,43 +206,6 @@
}, },
"time": "2021-04-07T01:06:46+00:00" "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", "name": "doctrine/inflector",
"version": "2.0.3", "version": "2.0.3",
@ -2946,20 +2909,19 @@
}, },
{ {
"name": "psy/psysh", "name": "psy/psysh",
"version": "v0.10.7", "version": "v0.10.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/bobthecow/psysh.git", "url": "https://github.com/bobthecow/psysh.git",
"reference": "a395af46999a12006213c0c8346c9445eb31640c" "reference": "e4573f47750dd6c92dca5aee543fa77513cbd8d3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/a395af46999a12006213c0c8346c9445eb31640c", "url": "https://api.github.com/repos/bobthecow/psysh/zipball/e4573f47750dd6c92dca5aee543fa77513cbd8d3",
"reference": "a395af46999a12006213c0c8346c9445eb31640c", "reference": "e4573f47750dd6c92dca5aee543fa77513cbd8d3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"dnoegel/php-xdg-base-dir": "0.1.*",
"ext-json": "*", "ext-json": "*",
"ext-tokenizer": "*", "ext-tokenizer": "*",
"nikic/php-parser": "~4.0|~3.0|~2.0|~1.3", "nikic/php-parser": "~4.0|~3.0|~2.0|~1.3",
@ -3016,9 +2978,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/bobthecow/psysh/issues", "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", "name": "ralouphie/getallheaders",
@ -6025,11 +5987,7 @@
"dist": { "dist": {
"type": "path", "type": "path",
"url": "./packages/laravel-nami", "url": "./packages/laravel-nami",
"reference": "a317215554e093e7499d823d136d6e0a81e4d505" "reference": "5827a5c9cccf439a3ac51b1bd154dc1c2803c5ce"
},
"require-dev": {
"guzzlehttp/guzzle": "^6.3.1|^7.0",
"orchestra/testbench": "^5.3"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -6046,7 +6004,9 @@
}, },
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {
"Zoomyboy\\LaravelNami\\Tests\\": "tests/" "Zoomyboy\\LaravelNami\\Tests\\": "tests/",
"orchestra/testbench": "^5.3",
"guzzlehttp/guzzle": "^6.3.1|^7.0"
} }
}, },
"authors": [ "authors": [
@ -6199,16 +6159,16 @@
}, },
{ {
"name": "facade/ignition", "name": "facade/ignition",
"version": "2.8.2", "version": "2.8.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/facade/ignition.git", "url": "https://github.com/facade/ignition.git",
"reference": "cb7f790e6306caeb4a9ffe21e59942b7128cc630" "reference": "a8201d51aae83addceaef9344592a3b068b5d64d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/facade/ignition/zipball/cb7f790e6306caeb4a9ffe21e59942b7128cc630", "url": "https://api.github.com/repos/facade/ignition/zipball/a8201d51aae83addceaef9344592a3b068b5d64d",
"reference": "cb7f790e6306caeb4a9ffe21e59942b7128cc630", "reference": "a8201d51aae83addceaef9344592a3b068b5d64d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -6272,7 +6232,7 @@
"issues": "https://github.com/facade/ignition/issues", "issues": "https://github.com/facade/ignition/issues",
"source": "https://github.com/facade/ignition" "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", "name": "facade/ignition-contracts",

View File

@ -3,6 +3,7 @@
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use App\Bill\BillKind;
class CreateMembersTable extends Migration class CreateMembersTable extends Migration
{ {
@ -13,6 +14,14 @@ class CreateMembersTable extends Migration
*/ */
public function up() 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) { Schema::create('members', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('firstname'); $table->string('firstname');
@ -40,6 +49,7 @@ class CreateMembersTable extends Migration
$table->foreignId('nationality_id')->constrained(); $table->foreignId('nationality_id')->constrained();
$table->foreignId('fee_id')->constrained(); $table->foreignId('fee_id')->constrained();
$table->text('letter_address')->nullable(); $table->text('letter_address')->nullable();
$table->foreignId('bill_kind_id')->nullable()->constrained();
$table->timestamps(); $table->timestamps();
}); });
@ -53,5 +63,6 @@ class CreateMembersTable extends Migration
public function down() public function down()
{ {
Schema::dropIfExists('members'); Schema::dropIfExists('members');
Schema::dropIfExists('bill_kinds');
} }
} }

View File

@ -10,6 +10,9 @@
<testsuite name="Feature"> <testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory> <directory suffix="Test.php">./tests/Feature</directory>
</testsuite> </testsuite>
<testsuite name="Nami">
<directory suffix="Test.php">./packages/laravel-nami/tests</directory>
</testsuite>
</testsuites> </testsuites>
<filter> <filter>
<whitelist processUncoveredFilesFromWhitelist="true"> <whitelist processUncoveredFilesFromWhitelist="true">

View File

@ -66,6 +66,11 @@
<f-text id="fax" v-model="inner.fax" label="Fax"></f-text> <f-text id="fax" v-model="inner.fax" label="Fax"></f-text>
</div> </div>
</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 class="grid grid-cols-2 gap-3 p-4" v-if="menuTitle == 'Sonstiges'">
<div> <div>
<f-text id="other_country" v-model="inner.other_country" label="Andere Staatsangehörigkeit"></f-text> <f-text id="other_country" v-model="inner.other_country" label="Andere Staatsangehörigkeit"></f-text>
@ -93,6 +98,7 @@ export default {
menu: [ menu: [
{ title: 'Stammdaten' }, { title: 'Stammdaten' },
{ title: 'Kontakt' }, { title: 'Kontakt' },
{ title: 'System' },
{ title: 'Sonstiges' }, { title: 'Sonstiges' },
] ]
}; };
@ -106,6 +112,7 @@ export default {
countries: {}, countries: {},
nationalities: {}, nationalities: {},
confessions: {}, confessions: {},
billKinds: {},
}, },
methods: { methods: {

View File

@ -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">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">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">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">Geburtstag</div>
<div class="px-6 text-gray-200 font-semibold py-3 border-gray-600 border-b">Eintritt</div> <div class="px-6 text-gray-200 font-semibold py-3 border-gray-600 border-b">Eintritt</div>
</header> </header>
@ -25,6 +26,10 @@
<div class="py-1 px-6"> <div class="py-1 px-6">
<v-bool v-model="member.nami_id !== null"></v-bool> <v-bool v-model="member.nami_id !== null"></v-bool>
</div> </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.birthday_human}`"></div>
<div class="py-1 px-6" v-text="`${member.joined_at_human}`"></div> <div class="py-1 px-6" v-text="`${member.joined_at_human}`"></div>
</inertia-link> </inertia-link>