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;
use App\Confession;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Zoomyboy\LaravelNami\Nami;
use Zoomyboy\LaravelNami\NamiUser;
class UpdateJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $memberId;
public $member;
public $user;
public int $memberId;
public Member $member;
public NamiUser $user;
public function __construct(Member $member, $user)
public function __construct(Member $member, NamiUser $user)
{
$this->memberId = $member->id;
$this->user = $user;

View File

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

View File

@ -2,6 +2,7 @@
namespace App\Payment;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
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;
}
@ -27,9 +29,10 @@ class Status extends Model
}
// ---------------------------------- Scopes -----------------------------------
public function scopeNeedsPayment($q) {
return $q->where(function($q) {
$q->where('is_bill', true)->orWhere('is_remember', true);
public function scopeNeedsPayment(Builder $query): Builder
{
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 Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Fee>
*/
class FeeFactory extends Factory
{

View File

@ -16,7 +16,7 @@ class SubscriptionFactory extends Factory
return [
'name' => $this->faker->word,
'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
{
/**
* @return void
*/
public function up()
{
Schema::create('settings', function (Blueprint $table): void {

View File

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

View File

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