Browse Source

Add marriage/couple detail page

Auto html title tag text which detect h2.page-header element content
via javascript
pull/3/head
Nafies Luthfi 8 years ago
parent
commit
f42beaddb5
  1. 14
      app/Http/Controllers/CouplesController.php
  2. 6
      database/migrations/2017_06_27_151536_create_couples_table.php
  3. 3
      resources/lang/en/couple.php
  4. 3
      resources/lang/id/couple.php
  5. 35
      resources/views/couples/partials/stat.blade.php
  6. 29
      resources/views/couples/show.blade.php
  7. 15
      resources/views/layouts/app.blade.php
  8. 4
      resources/views/layouts/user-profile-wide.blade.php
  9. 4
      resources/views/layouts/user-profile.blade.php
  10. 8
      resources/views/users/marriages.blade.php
  11. 4
      resources/views/users/search.blade.php
  12. 5
      routes/web.php

14
app/Http/Controllers/CouplesController.php

@ -0,0 +1,14 @@
<?php
namespace App\Http\Controllers;
use App\Couple;
use Illuminate\Http\Request;
class CouplesController extends Controller
{
public function show(Couple $couple)
{
return view('couples.show', compact('couple'));
}
}

6
database/migrations/2017_06_27_151536_create_couples_table.php

@ -15,9 +15,9 @@ class CreateCouplesTable extends Migration
{
Schema::create('couples', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('husband_id')->index();
$table->unsignedInteger('wife_id')->index();
$table->date('marriege_date')->nullable();
$table->unsignedInteger('husband_id');
$table->unsignedInteger('wife_id');
$table->date('marriage_date')->nullable();
$table->date('divorce_date')->nullable();
$table->timestamps();

3
resources/lang/en/couple.php

@ -3,12 +3,13 @@
return [
// Labels
'show' => 'Show Marriage Profile',
'detail' => 'Marriage Profile',
'childs_count' => 'Childs Count',
'grand_childs_count' => 'Grand Childs Count',
// Attributes
'husband' => 'Head of Family',
'wive' => 'Wife',
'wife' => 'Wife',
'marriage_date' => 'Marriage Date',
'divorce_date' => 'Divorce Date',
];

3
resources/lang/id/couple.php

@ -3,12 +3,13 @@
return [
// Labels
'show' => 'Lhat Profil Pernikahan',
'detail' => 'Profil Pernikahan',
'childs_count' => 'Jumlah Anak',
'grand_childs_count' => 'Jumlah Cucu',
// Attributes
'husband' => 'Kepala Keluarga',
'wive' => 'Isteri',
'wife' => 'Isteri',
'marriage_date' => 'Tanggal Pernikahan',
'divorce_date' => 'Tanggal Perceraian',
];

35
resources/views/couples/partials/stat.blade.php

@ -0,0 +1,35 @@
<div class="panel panel-default table-responsive hidden-xs">
<table class="table table-condensed table-bordered">
<tr>
<td class="col-xs-2 text-center">{{ trans('couple.husband') }}</td>
<td class="col-xs-2 text-center">{{ trans('couple.wife') }}</td>
<td class="col-xs-2 text-center">{{ trans('couple.childs_count') }}</td>
<td class="col-xs-2 text-center">{{ trans('couple.marriage_date') }}</td>
</tr>
<tr>
<td class="text-center lead" style="border-top: none;">{{ $couple->husband->profileLink() }}</td>
<td class="text-center lead" style="border-top: none;">{{ $couple->wife->profileLink() }}</td>
<td class="text-center lead" style="border-top: none;">{{ $couple->childs->count() }}</td>
<td class="text-center lead" style="border-top: none;">{{ $couple->marriage_date }}</td>
</tr>
</table>
</div>
<ul class="list-group visible-xs">
<li class="list-group-item">
{{ trans('couple.husband') }}
<span class="pull-right">{{ $couple->husband->profileLink() }}</span>
</li>
<li class="list-group-item">
{{ trans('couple.wife') }}
<span class="pull-right">{{ $couple->wife->profileLink() }}</span>
</li>
<li class="list-group-item">
{{ trans('couple.childs_count') }}
<span class="pull-right">{{ $couple->childs->count() }}</span>
</li>
<li class="list-group-item">
{{ trans('couple.marriage_date') }}
<span class="pull-right">{{ $couple->marriage_date }}</span>
</li>
</ul>

29
resources/views/couples/show.blade.php

@ -0,0 +1,29 @@
@extends('layouts.app')
@section('content')
<h2 class="page-header">
{{ $couple->husband->name }} & {{ $couple->wife->name }} <small>{{ trans('couple.detail') }}</small>
</h2>
@include('couples.partials.stat')
<br>
<h4 class="page-header">{{ trans('user.childs') }} & {{ trans('user.grand_childs') }}</h4 class="page-header">
<?php $no = 0; ?>
@foreach($couple->childs->chunk(4) as $chunkedChild)
<div class="">
@foreach($chunkedChild as $child)
<div class="col-md-3">
<h4><strong>{{ ++$no }}. {{ $child->profileLink() }} ({{ $child->gender }})</strong></h4>
<ul style="padding-left: 35px">
@foreach($child->childs as $grand)
<li>{{ $grand->profileLink() }} ({{ $grand->gender }})</li>
@endforeach
</ul>
</div>
@endforeach
@if (! $loop->last)
<div class="clearfix"></div><hr>
@endif
</div>
@endforeach
@endsection

15
resources/views/layouts/app.blade.php

@ -32,5 +32,20 @@
<script src="{{ asset('js/app.js') }}"></script>
@yield('ext_js')
@yield('script')
<script>
var header = $('h2.page-header').contents();
str = '';
mainText = header.filter(function () {
// return type of text
return this.nodeType === 3;
})[0];
str += mainText.data.trim();
if (mainText.nextSibling) {
// next siblings should be a small tag text
str += " - "+mainText.nextSibling.innerText;
}
$('title').prepend(str+" - ");
</script>
</body>
</html>

4
resources/views/layouts/user-profile-wide.blade.php

@ -3,9 +3,9 @@
@section('content')
</div>
<div class="container-fluid">
<h1 class="page-header">
<h2 class="page-header">
@include('users.partials.action-buttons', ['user' => $user])
{{ $user->name }} <small>@yield('subtitle')</small>
</h1>
</h2>
@yield('user-content')
@endsection

4
resources/views/layouts/user-profile.blade.php

@ -1,9 +1,9 @@
@extends('layouts.app')
@section('content')
<h1 class="page-header">
<h2 class="page-header">
@include('users.partials.action-buttons', ['user' => $user])
{{ $user->name }} <small>@yield('subtitle')</small>
</h1>
</h2>
@yield('user-content')
@endsection

8
resources/views/users/marriages.blade.php

@ -10,7 +10,7 @@
<div class="panel panel-default">
<table class="table table-condensed">
<tr><th class="col-xs-5">{{ trans('couple.husband') }}</th><td>{{ $marriage->husband->profileLink() }}</th></tr>
<tr><th>{{ trans('couple.wive') }}</th><td>{{ $marriage->wife->profileLink() }}</th></tr>
<tr><th>{{ trans('couple.wife') }}</th><td>{{ $marriage->wife->profileLink() }}</th></tr>
<tr><th>{{ trans('couple.marriage_date') }}</th><td>{{ $marriage->marriage_date }}</th></tr>
@if ($marriage->divorce_date)
<tr><th>{{ trans('couple.divorce_date') }}</th><td>{{ $marriage->divorce_date }}</th></tr>
@ -18,9 +18,9 @@
<tr><th>{{ trans('couple.childs_count') }}</th><td>{{ $marriage->childs_count }}</th></tr>
{{-- <tr><th>{{ trans('couple.grand_childs_count') }}</th><td>?</th></tr> --}}
</table>
{{-- <div class="panel-footer">
{{ link_to_route('couples.show', trans('couple.show'), [$user->id], ['class' => 'btn btn-default btn-xs']) }}
</div> --}}
<div class="panel-footer">
{{ link_to_route('couples.show', trans('couple.show'), [$marriage->id], ['class' => 'btn btn-default btn-xs']) }}
</div>
</div>
</div>
@endforeach

4
resources/views/users/search.blade.php

@ -1,12 +1,12 @@
@extends('layouts.app')
@section('content')
<h3 class="page-header">
<h2 class="page-header">
{{ trans('app.search_your_family') }}
@if (request('q'))
<small class="pull-right">{!! trans('app.user_found', ['total' => $users->total(), 'keyword' => request('q')]) !!}</small>
@endif
</h3>
</h2>
{{ Form::open(['method' => 'get','class' => '']) }}

5
routes/web.php

@ -34,6 +34,11 @@ Route::get('users/{user}/tree', 'UsersController@tree')->name('users.tree');
Route::get('users/{user}/marriages', 'UserMarriagesController@index')->name('users.marriages');
/**
* Couple/Marriages Routes
*/
Route::get('couples/{couple}', ['as'=>'couples.show', 'uses'=>'CouplesController@show']);
/**
* Backup Restore Database Routes
*/
Route::post('backups/upload', ['as'=>'backups.upload', 'uses'=>'BackupsController@upload']);

Loading…
Cancel
Save