This commit is contained in:
philipp lang 2022-02-12 15:33:16 +01:00
parent 71a0ee6b1d
commit 5632ed60e2
8 changed files with 35 additions and 16 deletions

View File

@ -3,22 +3,24 @@
namespace App\Member; namespace App\Member;
use App\Confession; use App\Confession;
use App\User;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use Zoomyboy\LaravelNami\Nami; use Zoomyboy\LaravelNami\Nami;
use Zoomyboy\LaravelNami\NamiUser;
class UpdateJob implements ShouldQueue class UpdateJob implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $memberId; public int $memberId;
public $member; public Member $member;
public $user; public NamiUser $user;
public function __construct(Member $member, $user) public function __construct(Member $member, NamiUser $user)
{ {
$this->memberId = $member->id; $this->memberId = $member->id;
$this->user = $user; $this->user = $user;

View File

@ -6,11 +6,14 @@ use App\Http\Controllers\Controller;
use App\Http\Views\MemberView; use App\Http\Views\MemberView;
use App\Member\Member; use App\Member\Member;
use App\Member\MemberResource; use App\Member\MemberResource;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Inertia\Response;
class PaymentController extends Controller class PaymentController extends Controller
{ {
public function index(Request $request, Member $member) { public function index(Request $request, Member $member): Response
{
session()->put('menu', 'member'); session()->put('menu', 'member');
session()->put('title', "Zahlungen für Mitglied {$member->fullname}"); session()->put('title', "Zahlungen für Mitglied {$member->fullname}");
@ -20,7 +23,8 @@ class PaymentController extends Controller
return \Inertia::render('member/VIndex', $payload); return \Inertia::render('member/VIndex', $payload);
} }
public function store(Request $request, Member $member) { public function store(Request $request, Member $member): RedirectResponse
{
$member->createPayment($request->validate([ $member->createPayment($request->validate([
'nr' => 'required|numeric', 'nr' => 'required|numeric',
'subscription_id' => 'required|exists:subscriptions,id', 'subscription_id' => 'required|exists:subscriptions,id',
@ -30,7 +34,8 @@ class PaymentController extends Controller
return redirect()->back(); return redirect()->back();
} }
public function edit(Member $member, Request $request, Payment $payment) { public function edit(Member $member, Request $request, Payment $payment): Response
{
session()->put('menu', 'member'); session()->put('menu', 'member');
session()->put('title', "Zahlungen für Mitglied {$member->fullname}"); session()->put('title', "Zahlungen für Mitglied {$member->fullname}");
@ -40,7 +45,8 @@ class PaymentController extends Controller
return \Inertia::render('member/VIndex', $payload); return \Inertia::render('member/VIndex', $payload);
} }
public function update(Request $request, Member $member, Payment $payment) { public function update(Request $request, Member $member, Payment $payment): RedirectResponse
{
$payment->update($request->validate([ $payment->update($request->validate([
'nr' => 'required|numeric', 'nr' => 'required|numeric',
'subscription_id' => 'required|exists:subscriptions,id', 'subscription_id' => 'required|exists:subscriptions,id',
@ -50,7 +56,8 @@ class PaymentController extends Controller
return redirect()->back(); return redirect()->back();
} }
public function destroy(Request $request, Member $member, Payment $payment) { public function destroy(Request $request, Member $member, Payment $payment): RedirectResponse
{
$payment->delete(); $payment->delete();
return redirect()->back(); return redirect()->back();

View File

@ -2,6 +2,7 @@
namespace App\Payment; namespace App\Payment;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
@ -17,7 +18,8 @@ class Status extends Model
]; ];
public static function default() { public static function default(): int
{
return static::where('is_bill', true)->where('is_remember', true)->first()->id; return static::where('is_bill', true)->where('is_remember', true)->first()->id;
} }
@ -27,9 +29,10 @@ class Status extends Model
} }
// ---------------------------------- Scopes ----------------------------------- // ---------------------------------- Scopes -----------------------------------
public function scopeNeedsPayment($q) { public function scopeNeedsPayment(Builder $query): Builder
return $q->where(function($q) { {
$q->where('is_bill', true)->orWhere('is_remember', true); return $query->where(function(Builder $query): Builder {
return $query->where('is_bill', true)->orWhere('is_remember', true);
}); });
} }
} }

View File

@ -5,6 +5,9 @@ namespace Database\Factories;
use App\Fee; use App\Fee;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Fee>
*/
class FeeFactory extends Factory class FeeFactory extends Factory
{ {

View File

@ -16,7 +16,7 @@ class SubscriptionFactory extends Factory
return [ return [
'name' => $this->faker->word, 'name' => $this->faker->word,
'amount' => $this->faker->numberBetween(1000, 50000), 'amount' => $this->faker->numberBetween(1000, 50000),
'fee_id' => Fee::factory()->create()->id, 'fee_id' => Fee::factory()->createOne()->id,
]; ];
} }

View File

@ -6,6 +6,9 @@ use Illuminate\Support\Facades\Schema;
class CreateSettingsTable extends Migration class CreateSettingsTable extends Migration
{ {
/**
* @return void
*/
public function up() public function up()
{ {
Schema::create('settings', function (Blueprint $table): void { Schema::create('settings', function (Blueprint $table): void {

View File

@ -41,7 +41,7 @@ class IndexTest extends TestCase
$response = $this->get('/member'); $response = $this->get('/member');
$this->assertComponent('member/Index', $response); $this->assertComponent('member/VIndex', $response);
$this->assertInertiaHas('::firstname::', $response, 'data.data.0.firstname'); $this->assertInertiaHas('::firstname::', $response, 'data.data.0.firstname');
} }

View File

@ -16,7 +16,8 @@ abstract class TestCase extends BaseTestCase
use CreatesApplication; use CreatesApplication;
use TestsInertia; use TestsInertia;
public function fakeAuthUser() { public function fakeAuthUser(): void
{
app(FakeBackend::class) app(FakeBackend::class)
->fakeLogin('123') ->fakeLogin('123')
->addSearch(123, ['entries_vorname' => '::firstname::', 'entries_nachname' => '::lastname::', 'entries_gruppierungId' => 1000]); ->addSearch(123, ['entries_vorname' => '::firstname::', 'entries_nachname' => '::lastname::', 'entries_gruppierungId' => 1000]);