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

@section('content')
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-6">
                <form
                    action="{{ $project->id ? route('adm.project.update', [$project->id]) : route('adm.project.store') }}"
                    method="post">
                    @csrf
                    @if($project->id)
                        @method('PUT')
                        <div class="row mb-3">
                            <div class="col">
                                <h1>編輯: {{ $project->title }} {{ $project->id }}</h1>
                            </div>
                        </div>
                    @endif
                    <x-success-alert></x-success-alert>
                    <x-validation-alert></x-validation-alert>
                    <x-model-form-control-group :model="$project" attr="title" label="名稱" :required="true"></x-model-form-control-group>
                    <x-model-form-control-group :model="$project" attr="description" type="text_area" label="描述"></x-model-form-control-group>
                    <x-model-form-control-group :model="$project" attr="status" type="select" label="狀態" :options="$projectStatuses" :required="true"></x-model-form-control-group>
                    <x-model-form-control-group :model="$project" attr="begin_at" type="input" input-type="date" label="開始日"></x-model-form-control-group>
                    <x-model-form-control-group :model="$project" attr="end_at" type="input" input-type="date" label="結束日"></x-model-form-control-group>
                    <x-model-form-control-group :model="$project" attr="price" type="input" input-type="number" label="金額" :required="true"></x-model-form-control-group>
                    <x-model-form-control-group :model="$project" attr="client_id" type="select" label="客戶" :options="$clients" :required="true"></x-model-form-control-group>
                    <x-model-form-control-group :model="$project" attr="parent_project_id" type="select" label="父專案" :options="$projects"></x-model-form-control-group>
                    @if($project->id)
                    <a href="{{ route('adm.project.show', [$project->id]) }}" class="btn btn-primary">
                        <i class="bi bi-arrow-left"></i>
                    </a>
                    @endif
                    <button type="submit" class="btn btn-success">
                        @if($project->id)
                            Update
                        @else
                            Create
                        @endif
                    </button>
                </form>
            </div>
        </div>
    </div>
@endsection
