From 4868e52665e38e0ba3d6c4e320232188ddd9ca93 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sat, 27 Jan 2018 20:26:45 +0800 Subject: [PATCH] Add project list tab on customer detail page --- .../Controllers/Customers/ProjectsController.php | 21 ++++++++++++ resources/lang/en/customer.php | 3 ++ resources/lang/id/customer.php | 3 ++ .../views/customers/partials/nav-tabs.blade.php | 3 ++ resources/views/customers/projects.blade.php | 39 ++++++++++++++++++++++ resources/views/customers/show.blade.php | 2 +- routes/web.php | 1 + 7 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/Customers/ProjectsController.php create mode 100755 resources/views/customers/projects.blade.php diff --git a/app/Http/Controllers/Customers/ProjectsController.php b/app/Http/Controllers/Customers/ProjectsController.php new file mode 100644 index 0000000..2430c93 --- /dev/null +++ b/app/Http/Controllers/Customers/ProjectsController.php @@ -0,0 +1,21 @@ + + */ +class ProjectsController extends Controller +{ + public function index(Customer $customer) + { + $projects = $customer->projects; + + return view('customers.projects', compact('customer', 'projects')); + } +} diff --git a/resources/lang/en/customer.php b/resources/lang/en/customer.php index ef3617d..4275879 100644 --- a/resources/lang/en/customer.php +++ b/resources/lang/en/customer.php @@ -30,4 +30,7 @@ return [ 'description' => 'Customer Description', 'pic' => 'PIC', 'projects_count' => 'Projects count', + + // Relations + 'projects' => 'Project List', ]; diff --git a/resources/lang/id/customer.php b/resources/lang/id/customer.php index 5364599..411342b 100644 --- a/resources/lang/id/customer.php +++ b/resources/lang/id/customer.php @@ -30,4 +30,7 @@ return [ 'description' => 'Deskripsi Customer', 'pic' => 'PIC', 'projects_count' => 'Jml Project', + + // Relations + 'projects' => 'List Project', ]; diff --git a/resources/views/customers/partials/nav-tabs.blade.php b/resources/views/customers/partials/nav-tabs.blade.php index 0e0abe1..89ca29f 100644 --- a/resources/views/customers/partials/nav-tabs.blade.php +++ b/resources/views/customers/partials/nav-tabs.blade.php @@ -3,5 +3,8 @@
  • {!! link_to_route('customers.show', trans('customer.show'), [$customer]) !!}
  • +
  • + {!! link_to_route('customers.projects', trans('customer.projects').' ('.$customer->projects->count().')', [$customer]) !!} +

  • diff --git a/resources/views/customers/projects.blade.php b/resources/views/customers/projects.blade.php new file mode 100755 index 0000000..04ba086 --- /dev/null +++ b/resources/views/customers/projects.blade.php @@ -0,0 +1,39 @@ +@extends('layouts.customer') + +@section('title', trans('customer.projects')) + +@section('content-customer') +
    + + + + + + + + + + + + @forelse($projects as $key => $project) + + + + + + + + + + @empty + + + + @endforelse + +
    {{ trans('app.table_no') }}{{ trans('project.name') }}{{ trans('project.start_date') }}{{ trans('project.work_duration') }}{{ trans('project.project_value') }}{{ trans('app.status') }}{{ trans('app.action') }}
    {{ 1 + $key }}{{ $project->nameLink() }}{{ $project->start_date }}{{ $project->present()->workDuration }}{{ formatRp($project->project_value) }}{{ $project->present()->status }} + {!! html_link_to_route('projects.show', '', [$project->id], ['icon' => 'search', 'class' => 'btn btn-info btn-xs', 'title' => trans('app.show')]) !!} + {!! html_link_to_route('projects.edit', '', [$project->id], ['icon' => 'edit', 'class' => 'btn btn-warning btn-xs', 'title' => trans('app.edit')]) !!} +
    {{ $status }} {{ trans('project.not_found') }}
    +
    +@endsection diff --git a/resources/views/customers/show.blade.php b/resources/views/customers/show.blade.php index 4501da6..f9832d9 100755 --- a/resources/views/customers/show.blade.php +++ b/resources/views/customers/show.blade.php @@ -21,7 +21,7 @@