Browse Source

Add project list tab on customer detail page

pull/6/head
Nafies Luthfi 8 years ago
parent
commit
4868e52665
  1. 21
      app/Http/Controllers/Customers/ProjectsController.php
  2. 3
      resources/lang/en/customer.php
  3. 3
      resources/lang/id/customer.php
  4. 3
      resources/views/customers/partials/nav-tabs.blade.php
  5. 39
      resources/views/customers/projects.blade.php
  6. 2
      resources/views/customers/show.blade.php
  7. 1
      routes/web.php

21
app/Http/Controllers/Customers/ProjectsController.php

@ -0,0 +1,21 @@
<?php
namespace App\Http\Controllers\Customers;
use App\Entities\Partners\Customer;
use App\Http\Controllers\Controller;
/**
* Customer Projects Controller.
*
* @author Nafies Luthfi <nafiesL@gmail.com>
*/
class ProjectsController extends Controller
{
public function index(Customer $customer)
{
$projects = $customer->projects;
return view('customers.projects', compact('customer', 'projects'));
}
}

3
resources/lang/en/customer.php

@ -30,4 +30,7 @@ return [
'description' => 'Customer Description',
'pic' => 'PIC',
'projects_count' => 'Projects count',
// Relations
'projects' => 'Project List',
];

3
resources/lang/id/customer.php

@ -30,4 +30,7 @@ return [
'description' => 'Deskripsi Customer',
'pic' => 'PIC',
'projects_count' => 'Jml Project',
// Relations
'projects' => 'List Project',
];

3
resources/views/customers/partials/nav-tabs.blade.php

@ -3,5 +3,8 @@
<li class="{{ Request::segment(3) == null ? 'active' : '' }}">
{!! link_to_route('customers.show', trans('customer.show'), [$customer]) !!}
</li>
<li class="{{ Request::segment(3) == 'projects' ? 'active' : '' }}">
{!! link_to_route('customers.projects', trans('customer.projects').' ('.$customer->projects->count().')', [$customer]) !!}
</li>
</ul>
<br>

39
resources/views/customers/projects.blade.php

@ -0,0 +1,39 @@
@extends('layouts.customer')
@section('title', trans('customer.projects'))
@section('content-customer')
<div class="panel panel-default table-responsive">
<table class="table table-condensed table-hover">
<thead>
<th>{{ trans('app.table_no') }}</th>
<th>{{ trans('project.name') }}</th>
<th class="text-center">{{ trans('project.start_date') }}</th>
<th class="text-center">{{ trans('project.work_duration') }}</th>
<th class="text-right">{{ trans('project.project_value') }}</th>
<th class="text-center">{{ trans('app.status') }}</th>
<th class="text-center">{{ trans('app.action') }}</th>
</thead>
<tbody>
@forelse($projects as $key => $project)
<tr>
<td>{{ 1 + $key }}</td>
<td>{{ $project->nameLink() }}</td>
<td class="text-center">{{ $project->start_date }}</td>
<td class="text-right">{{ $project->present()->workDuration }}</td>
<td class="text-right">{{ formatRp($project->project_value) }}</td>
<td class="text-center">{{ $project->present()->status }}</td>
<td class="text-center">
{!! 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')]) !!}
</td>
</tr>
@empty
<tr>
<td colspan="7">{{ $status }} {{ trans('project.not_found') }}</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@endsection

2
resources/views/customers/show.blade.php

@ -21,7 +21,7 @@
<div class="col-md-6">
<div class="row">
<div class="col-lg-6 col-md-12">
<a href="#" title="@lang('customer.projects_count')">
<a href="{{ route('customers.projects', $customer) }}" title="@lang('customer.projects_count')">
<div class="panel panel-info">
<div class="panel-heading">
<div class="row">

1
routes/web.php

@ -28,6 +28,7 @@ Route::group(['middleware' => ['web', 'auth']], function () {
/*
* Customers Routes
*/
Route::get('customers/{customer}/projects', ['as' => 'customers.projects', 'uses' => 'Customers\ProjectsController@index']);
Route::resource('customers', 'Partners\CustomersController');
/*

Loading…
Cancel
Save