<?php
/** @var \App\Models\Payment $payment */
?>
@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-6">
                <form
                    action="{{ $payment->id ? route('adm.payment.update', [$payment->id]) : route('adm.payment.store') }}"
                    method="post">
                    @csrf
                    @if($payment->id)
                        @method('PUT')
                        <div class="row mb-3">
                            <div class="col">
                                <h1>編輯: {{ $payment->project->title }} - payment id:{{ $payment->id }}</h1>
                            </div>
                        </div>
                    @endif
                    <x-success-alert></x-success-alert>
                    <x-validation-alert></x-validation-alert>
                    <x-model-form-control-group :model="$payment" attr="project_id" type="select" label="專案" :options="$projects" :required="true"></x-model-form-control-group>
                    <x-model-form-control-group :model="$payment" attr="amount" label="金額" :required="true"></x-model-form-control-group>
                    <x-model-form-control-group :model="$payment" attr="description" type="text_area" label="描述"></x-model-form-control-group>
                    <x-model-form-control-group :model="$payment" attr="status" type="select" label="狀態" :options="$paymentStatuses" :required="true"></x-model-form-control-group>
                    <x-model-form-control-group :model="$payment" attr="type" type="select" label="類別" :options="$paymentTypes" :required="true"></x-model-form-control-group>
                    <button type="submit" class="btn btn-success">
                        @if($payment->id)
                            Update
                        @else
                            Create
                        @endif
                    </button>
                </form>
                <a href="{{ route('adm.project.show', [$payment->project_id]) }}">回專案</a>
            </div>
        </div>
    </div>
@endsection
