This commit is contained in:
kroutony 2022-05-04 10:41:51 +08:00
parent e85df8de0a
commit bc09cf9f24
3 changed files with 100 additions and 140 deletions

View File

@ -14,7 +14,7 @@ private function createOrEdit(Project $project)
{ {
$statuses = __('enums.project_status'); $statuses = __('enums.project_status');
$clients = Client::all()->pluck('name', 'id'); $clients = Client::all()->pluck('name', 'id');
$projects = collect(['' => '無'])->merge(Project::all()->pluck('title', 'id')); $projects = collect(['' => '無'])->union(Project::all()->pluck('title', 'id'));
return view('project.edit', ['project' => $project, 'projectStatuses' => $statuses, 'clients' => $clients, 'projects' => $projects]); return view('project.edit', ['project' => $project, 'projectStatuses' => $statuses, 'clients' => $clients, 'projects' => $projects]);
} }
@ -34,8 +34,7 @@ public function index(Request $request)
$builder->where('client_id', $clientId); $builder->where('client_id', $clientId);
} }
$projects = $builder->get(); $projects = $builder->get();
$statuses[''] = '所有狀態'; $statuses = collect(['' => '所有狀態'])->union(__('enums.project_status'));
$statuses += __('enums.project_status');
return view('project.index', ['projects' => $projects, 'statuses' => $statuses]); return view('project.index', ['projects' => $projects, 'statuses' => $statuses]);
} }

View File

@ -2,36 +2,39 @@
@section('content') @section('content')
<div class="container"> <div class="container">
<div class="row"> <div class="row justify-content">
<div class="col"> <div class="col">
<strong>名稱</strong> <table class="table table-bordered table-hover table-sm table-striped">
</div> <tbody>
<div class="col">
{{ $client->name }}
</div>
</div>
<div class="row">
<div class="col">
<strong>專案</strong>
<a href="{{ route('adm.project.index', ['client_id' => $client->id]) }}" class="btn btn-sm btn-outline-primary">
<i class="bi bi-eye"></i>
</a>
</div>
<div class="col">
<table class="table table-striped">
<thead>
<tr> <tr>
<th>名稱</th> <th>名稱</th>
<th>金額</th> <td>{{ $client->name }}</td>
</tr> </tr>
</thead>
<tbody>
@foreach($client->projects as $project)
<tr> <tr>
<td>{{ $project->title }}</td> <th>專案
<td>{{ $project->price }}</td> <a href="{{ route('adm.project.index', ['client_id' => $client->id]) }}" class="btn btn-sm btn-outline-primary">
<i class="bi bi-eye"></i>
</a>
</th>
<td>
<table class="table table-striped">
<thead>
<tr>
<th>名稱</th>
<th>金額</th>
</tr>
</thead>
<tbody>
@foreach($client->projects as $project)
<tr>
<td>{{ $project->title }}</td>
<td>{{ $project->price }}</td>
</tr>
@endforeach
</tbody>
</table>
</td>
</tr> </tr>
@endforeach
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@ -1,120 +1,78 @@
@extends('layouts.app') @extends('layouts.app')
@section('content') @section('content')
<div class="container"> <div class="container">
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col"> <div class="col">
<div class="row"> <table class="table table-bordered table-hover table-sm table-striped">
<div class="col"> <tbody>
<strong>名稱</strong> <tr>
</div> <th>名稱</th>
<div class="col"> <td>{{ $project->title }}</td>
{{ $project->title }} </tr>
</div> <tr>
</div> <th>狀態</th>
<div class="row"> <td>{{ __('enums.project_status.' . $project->status) }}</td>
<div class="col"> </tr>
<strong>狀態</strong> <tr>
</div> <th>客戶</th>
<div class="col"> <td>{{ $project->client->name }}</td>
{{ __('enums.project_status.' . $project->status) }} </tr>
</div> <tr>
</div> <th>描述</th>
<div class="row"> <td>{!! nl2br($project->description) !!}</td>
<div class="col"> </tr>
<strong>客戶</strong> <tr>
</div> <th>起始日</th>
<div class="col"> <td>{{ $project->begin_at }}</td>
{{ $project->client->name }} </tr>
</div> <tr>
</div> <th>結束日</th>
<div class="row"> <td>{{ $project->end_at }}</td>
<div class="col"> </tr>
<strong>描述</strong> <tr>
</div> <th>金額</th>
<div class="col"> <td>{{ $project->price }}</td>
{!! nl2br($project->description) !!} </tr>
</div> <tr>
</div> <th>建立日期</th>
<div class="row"> <td>{{ $project->created_at }}</td>
<div class="col"> </tr>
<strong>起始日</strong> <tr>
</div> <th>更新日期</th>
<div class="col"> <td>{{ $project->updated_at }}</td>
{{ $project->begin_at }} </tr>
</div> <tr>
</div> <th>未收款項</th>
<div class="row"> <td>@if($project->unpaid_amount) {{ $project->unpaid_amount }} @endif</td>
<div class="col"> </tr>
<strong>結束日</strong> <tr>
</div> <th>已收款項 <a href="{{ route('adm.payment.create', ['project_id' => $project->id]) }}"
<div class="col"> class="btn btn-sm btn-outline-success"><i class="bi bi-plus"></i></a></th>
{{ $project->end_at }} <td>
</div> <table class="table">
</div> <thead>
<div class="row"> <tr>
<div class="col"> <th>類型</th>
<strong>金額</strong> <th>金額</th>
</div> <th>日期</th>
<div class="col"> </tr>
{{ $project->price }} </thead>
</div> <tbody>
</div> @foreach($project->payments as $payment)
<div class="row"> <tr>
<div class="col"> <td>{{ __('enums.payment_type.' . $payment->type) }}</td>
<strong>建立日期</strong> <td>{{ $payment->amount }}</td>
</div> <td>{{ $payment->created_at }}</td>
<div class="col"> </tr>
{{ $project->created_at }} @endforeach
</div> </tbody>
</div> </table>
<div class="row"> </td>
<div class="col"> </tr>
<strong>更新日期</strong> </tbody>
</div> </table>
<div class="col">
{{ $project->updated_at }}
</div>
</div>
<div class="row">
<div class="col">
<strong>未收款項</strong>
</div>
<div class="col">
@if($project->unpaid_amount) {{ $project->unpaid_amount }} @endif
</div>
</div>
<div class="row">
<div class="col">
<strong>已收款項</strong>
<a href="{{ route('adm.payment.create', ['project_id' => $project->id]) }}" class="btn btn-sm btn-outline-success"><i class="bi bi-plus"></i></a>
</div>
<div class="col">
<table class="table">
<thead>
<tr>
<th>類型</th>
<th>金額</th>
<th>日期</th>
</tr>
</thead>
<tbody>
@foreach($project->payments as $payment)
<tr>
<td>{{ __('enums.payment_type.' . $payment->type) }}</td>
<td>{{ $payment->amount }}</td>
<td>{{ $payment->created_at }}</td>
</tr>
@endforeach
</tbody>
</table>
<ul>
</ul>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
@endsection @endsection