diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index f880473..f51fdb7 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -34,7 +34,7 @@ class HomeController extends Controller $malePersonList = User::where('gender_id', 1)->pluck('nickname', 'id'); $femalePersonList = User::where('gender_id', 2)->pluck('nickname', 'id'); - return view('home', [ + return view('users.show', [ 'currentUser' => $user, 'usersMariageList' => $usersMariageList, 'malePersonList' => $malePersonList, diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index a8e6760..91c7794 100644 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -54,7 +54,7 @@ class UsersController extends Controller $malePersonList = User::where('gender_id', 1)->pluck('nickname', 'id'); $femalePersonList = User::where('gender_id', 2)->pluck('nickname', 'id'); - return view('home', [ + return view('users.show', [ 'currentUser' => $user, 'usersMariageList' => $usersMariageList, 'malePersonList' => $malePersonList, diff --git a/app/User.php b/app/User.php index 7f71c01..ae22fe7 100644 --- a/app/User.php +++ b/app/User.php @@ -92,8 +92,7 @@ class User extends Authenticatable public function profileLink() { - $linkText = $this->name ?: $this->nickname; - return link_to_route('users.show', $linkText, [$this->id]); + return link_to_route('users.show', $this->name, [$this->id]); } public function wifes() diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php deleted file mode 100644 index 14daab1..0000000 --- a/resources/views/home.blade.php +++ /dev/null @@ -1,160 +0,0 @@ -@extends('layouts.app') - -@section('content') -
-
-
-
-
Profile : {{ $currentUser->name ?: $currentUser->nickname }}
- -
- - - - - - - - - - - - - - - - - - - - - - - -
Nama Panggilan{{ $currentUser->nickname }}
Nama{{ $currentUser->profileLink() }}
Jenis Kelamin{{ $currentUser->gender }}
Ayah - @if ($currentUser->father_id) - {{ $currentUser->father->profileLink() }} - @else - {{ Form::open(['route' => ['family-actions.set-father', $currentUser->id]]) }} - {!! FormField::select('set_father_id', $malePersonList, ['label' => false]) !!} -
- {{ Form::text('set_father', null, ['class' => 'form-control input-sm']) }} - - {{ Form::submit('update', ['class' => 'btn btn-info btn-sm', 'id' => 'set_father_button']) }} - -
- {{ Form::close() }} - @endif -
Ibu - @if ($currentUser->mother_id) - {{ $currentUser->mother->profileLink() }} - @else - {{ Form::open(['route' => ['family-actions.set-mother', $currentUser->id]]) }} - {!! FormField::select('set_mother_id', $femalePersonList, ['label' => false]) !!} -
- {{ Form::text('set_mother', null, ['class' => 'form-control input-sm']) }} - - {{ Form::submit('update', ['class' => 'btn btn-info btn-sm', 'id' => 'set_mother_button']) }} - -
- {{ Form::close() }} - @endif -
-
-
-
-
-
-
Keluarga
- -
- - - @if ($currentUser->gender_id == 1) - - - - - @else - - - - - @endif - -
Isteri - @if ($currentUser->wifes->isEmpty() == false) -
    - @foreach($currentUser->wifes as $wife) -
  • {{ $wife->profileLink() }}
  • - @endforeach -
- @else - {{ Form::open(['route' => ['family-actions.add-wife', $currentUser->id]]) }} - {!! FormField::select('set_wife_id', $femalePersonList, ['label' => false]) !!} -
- {{ Form::text('set_wife', null, ['class' => 'form-control input-sm']) }} - - {{ Form::submit('update', ['class' => 'btn btn-info btn-sm', 'id' => 'set_wife_button']) }} - -
- {{ Form::close() }} - @endif -
Suami - @if ($currentUser->husbands->isEmpty() == false) -
    - @foreach($currentUser->husbands as $husband) -
  • {{ $husband->profileLink() }}
  • - @endforeach -
- @else - {{ Form::open(['route' => ['family-actions.add-husband', $currentUser->id]]) }} - {!! FormField::select('set_husband_id', $malePersonList, ['label' => false]) !!} -
- {{ Form::text('set_husband', null, ['class' => 'form-control input-sm']) }} - - {{ Form::submit('update', ['class' => 'btn btn-info btn-sm', 'id' => 'set_husband_button']) }} - -
- {{ Form::close() }} - @endif -
- Anak-Anak -
    - @foreach($currentUser->childs as $child) -
  • - {{ $child->profileLink() }} ({{ $child->gender }}) -
  • - @endforeach -
  • - {{ Form::open(['route' => ['family-actions.add-child', $currentUser->id]]) }} -
    -
    - {!! FormField::text('add_child_name', ['label' => 'Nama Anak']) !!} -
    -
    - {!! FormField::radios('add_child_gender_id', [1 => 'Laki-laki', 2 => 'Perempuan'], ['label' => 'Jenis Kelamin Anak']) !!} -
    -
    - {!! FormField::select('add_child_parent_id', $usersMariageList, ['label' => 'Dari Pernikahan']) !!} -
    -
    - {{ Form::submit('Tambah Anak', ['class' => 'btn btn-success btn-sm']) }} - {{ Form::close() }} -
  • -
-
-
-
-
- @if (count($errors) > 0) -
- -
- @endif -
-@endsection diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index d4745b4..260606c 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -28,7 +28,7 @@ - + {{ config('app.name', 'Laravel') }} diff --git a/resources/views/users/partials/childs.blade.php b/resources/views/users/partials/childs.blade.php new file mode 100644 index 0000000..9e59320 --- /dev/null +++ b/resources/views/users/partials/childs.blade.php @@ -0,0 +1,35 @@ +
+
+
+ {{ link_to_route('users.show', 'Tambah Anak', [$user->id, 'action' => 'add_child'], ['class' => 'btn btn-success btn-xs']) }} +
+

Anak-Anak

+
+ + +
\ No newline at end of file diff --git a/resources/views/users/partials/parent-spouse.blade.php b/resources/views/users/partials/parent-spouse.blade.php new file mode 100644 index 0000000..ac6725e --- /dev/null +++ b/resources/views/users/partials/parent-spouse.blade.php @@ -0,0 +1,91 @@ +
+

Keluarga

+ + + + + + + + + + + + @if ($user->gender_id == 1) + + + + + @else + + + + + @endif + +
Ayah + @if ($user->father_id) + {{ $user->father->profileLink() }} + @else + {{ Form::open(['route' => ['family-actions.set-father', $user->id]]) }} + {!! FormField::select('set_father_id', $malePersonList, ['label' => false]) !!} +
+ {{ Form::text('set_father', null, ['class' => 'form-control input-sm']) }} + + {{ Form::submit('update', ['class' => 'btn btn-info btn-sm', 'id' => 'set_father_button']) }} + +
+ {{ Form::close() }} + @endif +
Ibu + @if ($user->mother_id) + {{ $user->mother->profileLink() }} + @else + {{ Form::open(['route' => ['family-actions.set-mother', $user->id]]) }} + {!! FormField::select('set_mother_id', $femalePersonList, ['label' => false]) !!} +
+ {{ Form::text('set_mother', null, ['class' => 'form-control input-sm']) }} + + {{ Form::submit('update', ['class' => 'btn btn-info btn-sm', 'id' => 'set_mother_button']) }} + +
+ {{ Form::close() }} + @endif +
Isteri + @if ($user->wifes->isEmpty() == false) +
    + @foreach($user->wifes as $wife) +
  • {{ $wife->profileLink() }}
  • + @endforeach +
+ @else + {{ Form::open(['route' => ['family-actions.add-wife', $user->id]]) }} + {!! FormField::select('set_wife_id', $femalePersonList, ['label' => false]) !!} +
+ {{ Form::text('set_wife', null, ['class' => 'form-control input-sm']) }} + + {{ Form::submit('update', ['class' => 'btn btn-info btn-sm', 'id' => 'set_wife_button']) }} + +
+ {{ Form::close() }} + @endif +
Suami + @if ($user->husbands->isEmpty() == false) +
    + @foreach($user->husbands as $husband) +
  • {{ $husband->profileLink() }}
  • + @endforeach +
+ @else + {{ Form::open(['route' => ['family-actions.add-husband', $user->id]]) }} + {!! FormField::select('set_husband_id', $malePersonList, ['label' => false]) !!} +
+ {{ Form::text('set_husband', null, ['class' => 'form-control input-sm']) }} + + {{ Form::submit('update', ['class' => 'btn btn-info btn-sm', 'id' => 'set_husband_button']) }} + +
+ {{ Form::close() }} + @endif +
+
\ No newline at end of file diff --git a/resources/views/users/partials/profile.blade.php b/resources/views/users/partials/profile.blade.php new file mode 100644 index 0000000..9e9a61b --- /dev/null +++ b/resources/views/users/partials/profile.blade.php @@ -0,0 +1,45 @@ +
+

Profil

+ + + + + + + + + + + + + + + + + + + @if ($user->dod) + + + + + @endif + @if ($user->email) + + + + + @endif + + + + + + + + + +
Nama + {{ $user->profileLink() }} +
Nama Panggilan{{ $user->nickname }}
Jenis Kelamin{{ $user->gender }}
Tanggal Lahir{{ $user->dob }}
Meninggal{{ $user->dod }}
Email{{ $user->email }}
Telp{{ $user->phone }}
Alamat{!! nl2br($user->address) !!}
+
\ No newline at end of file diff --git a/resources/views/users/show.blade.php b/resources/views/users/show.blade.php new file mode 100644 index 0000000..6be1ada --- /dev/null +++ b/resources/views/users/show.blade.php @@ -0,0 +1,16 @@ +@extends('layouts.app') + +@section('content') +
+ +
+
+ @include('users.partials.profile', ['user' => $currentUser]) +
+
+ @include('users.partials.parent-spouse', ['user' => $currentUser]) + @include('users.partials.childs', ['user' => $currentUser]) +
+
+
+@endsection diff --git a/tests/Feature/ManageUserFamiliesTest.php b/tests/Feature/ManageUserFamiliesTest.php index 626f9b5..6cee777 100644 --- a/tests/Feature/ManageUserFamiliesTest.php +++ b/tests/Feature/ManageUserFamiliesTest.php @@ -54,6 +54,7 @@ class ManageUserFamiliesTest extends TestCase $user = $this->loginAsUser(['gender_id' => 1]); $this->visit(route('profile')); $this->seePageIs(route('profile')); + $this->click('Tambah Anak'); $this->seeElement('input', ['name' => 'add_child_name']); $this->seeElement('input', ['name' => 'add_child_gender_id']); $this->seeElement('select', ['name' => 'add_child_parent_id']); @@ -85,6 +86,7 @@ class ManageUserFamiliesTest extends TestCase $this->visit(route('profile')); $this->seePageIs(route('profile')); + $this->click('Tambah Anak'); $this->seeElement('input', ['name' => 'add_child_name']); $this->seeElement('input', ['name' => 'add_child_gender_id']); $this->seeElement('select', ['name' => 'add_child_parent_id']); diff --git a/tests/Feature/UsersProfileTest.php b/tests/Feature/UsersProfileTest.php index 5a16cbd..9ed0fa1 100644 --- a/tests/Feature/UsersProfileTest.php +++ b/tests/Feature/UsersProfileTest.php @@ -15,6 +15,6 @@ class UsersProfileTest extends TestCase { $user = factory(User::class)->create(); $this->visit(route('users.show', $user->id)); - $this->see('Profile : ' . $user->nickname); + $this->see($user->name); } }