diff --git a/app/Initialize/InitializeMembers.php b/app/Initialize/InitializeMembers.php index 404ab5ab..48068339 100644 --- a/app/Initialize/InitializeMembers.php +++ b/app/Initialize/InitializeMembers.php @@ -59,7 +59,7 @@ class InitializeMembers { 'active' => $data->status == 'Aktiv' ]; - $m = new \App\Member($attributes); + $m = new \App\Member\Member($attributes); $m->gender()->associate($gender); $m->country()->associate($country); diff --git a/app/Member.php b/app/Member/Member.php similarity index 77% rename from app/Member.php rename to app/Member/Member.php index f7458571..bee407bd 100644 --- a/app/Member.php +++ b/app/Member/Member.php @@ -1,8 +1,7 @@ 'integer', ]; - public function newCollection(array $models = []) - { - return new OwnCollection($models); + public function scopeSearch($q, $text) { + return $q->where('firstname', 'LIKE', '%'.$text.'%') + ->orWhere('lastname', 'LIKE', '%'.$text.'%') + ->orWhere('address', 'LIKE', '%'.$text.'%') + ->orWhere('zip', 'LIKE', '%'.$text.'%') + ->orWhere('city', 'LIKE', '%'.$text.'%'); } + //----------------------------------- Getters ----------------------------------- public function getFullnameAttribute() { return $this->firstname.' '.$this->lastname; @@ -65,21 +68,21 @@ class Member extends Model public function way() { - return $this->belongsTo(Way::class); + return $this->belongsTo(App\Way::class); } public function nationality() { - return $this->belongsTo(Nationality::class); + return $this->belongsTo(App\Nationality::class); } public function memberships() { - return $this->hasMany(Membership::class); + return $this->hasMany(App\Membership::class); } public function subscription() { - return $this->belongsTo(Subscription::class); + return $this->belongsTo(App\Subscription::class); } } diff --git a/app/Member/MemberController.php b/app/Member/MemberController.php new file mode 100644 index 00000000..fe355b29 --- /dev/null +++ b/app/Member/MemberController.php @@ -0,0 +1,15 @@ + MemberResource::collection(Member::search($request->query('search', null))->get()) + ]); + } +} diff --git a/app/Member/MemberResource.php b/app/Member/MemberResource.php new file mode 100644 index 00000000..99c95a72 --- /dev/null +++ b/app/Member/MemberResource.php @@ -0,0 +1,19 @@ +query('search', '')); } /** diff --git a/package-lock.json b/package-lock.json index 28a9441e..9d061cab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3124,8 +3124,7 @@ "decode-uri-component": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", - "dev": true + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=" }, "deep-equal": { "version": "1.1.1", @@ -8312,6 +8311,16 @@ "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", "dev": true }, + "query-string": { + "version": "6.12.1", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-6.12.1.tgz", + "integrity": "sha512-OHj+zzfRMyj3rmo/6G8a5Ifvw3AleL/EbcHMD27YA31Q+cO5lfmQxECkImuNVjcskLcvBRVHNAB3w6udMs1eAA==", + "requires": { + "decode-uri-component": "^0.2.0", + "split-on-first": "^1.0.0", + "strict-uri-encode": "^2.0.0" + } + }, "querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", @@ -9437,6 +9446,11 @@ } } }, + "split-on-first": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", + "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==" + }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -9540,6 +9554,11 @@ "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==", "dev": true }, + "strict-uri-encode": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", + "integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY=" + }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", diff --git a/package.json b/package.json index 7333665a..07b888b9 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "js-modules": "file:resources/js/libs/js-modules", "laravel-echo": "^1.7.0", "postcss-import": "^12.0.1", + "query-string": "^6.12.1", "socket.io-client": "^2.3.0", "tailwindcss": "^1.2.0", "vue-inputmask": "^0.2.1", diff --git a/resources/js/store/links.js b/resources/js/store/links.js index ffe62aa8..e562836f 100644 --- a/resources/js/store/links.js +++ b/resources/js/store/links.js @@ -3,6 +3,7 @@ export default { open: false, links: [ { icon: 'home', href: '/', title: 'Dashboard' }, + { icon: 'user', href: '/member', title: 'Mitglieder' }, ] }, footer: { diff --git a/resources/js/views/Member/Index.vue b/resources/js/views/Member/Index.vue new file mode 100644 index 00000000..f537b056 --- /dev/null +++ b/resources/js/views/Member/Index.vue @@ -0,0 +1,31 @@ + + + + diff --git a/routes/web.php b/routes/web.php index 454d5064..5daf3947 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,6 @@ 'App\\Http\\Controllers'], function() { Route::group(['middleware' => 'auth:web'], function () { Route::get('/', HomeController::class)->name('home'); Route::resource('initialize', InitializeController::class); + Route::resource('member', MemberController::class); });