From 8870937555bd35fdd4afc9361fb6fc90cdc9607a Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Mon, 3 Jul 2017 09:32:12 +0800 Subject: [PATCH] Added can directives on user edit policy --- resources/views/users/partials/childs.blade.php | 4 ++++ .../views/users/partials/parent-spouse.blade.php | 21 +++++++++++++++++++++ resources/views/users/show.blade.php | 2 ++ 3 files changed, 27 insertions(+) diff --git a/resources/views/users/partials/childs.blade.php b/resources/views/users/partials/childs.blade.php index 9e59320..3b6d899 100644 --- a/resources/views/users/partials/childs.blade.php +++ b/resources/views/users/partials/childs.blade.php @@ -1,8 +1,10 @@
+ @can ('edit', $currentUser)
{{ link_to_route('users.show', 'Tambah Anak', [$user->id, 'action' => 'add_child'], ['class' => 'btn btn-success btn-xs']) }}
+ @endcan

Anak-Anak

@@ -12,6 +14,7 @@ {{ $child->profileLink() }} ({{ $child->gender }}) @endforeach + @can('edit', $currentUser) @if (request('action') == 'add_child')
  • {{ Form::open(['route' => ['family-actions.add-child', $user->id]]) }} @@ -31,5 +34,6 @@ {{ Form::close() }}
  • @endif + @endcan
    \ 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 index 3490186..473b993 100644 --- a/resources/views/users/partials/parent-spouse.blade.php +++ b/resources/views/users/partials/parent-spouse.blade.php @@ -9,6 +9,7 @@ @if ($user->father_id) {{ $user->father->profileLink() }} @else + @can ('edit', $currentUser) {{ Form::open(['route' => ['family-actions.set-father', $user->id]]) }} {!! FormField::select('set_father_id', $malePersonList, ['label' => false]) !!}
    @@ -17,6 +18,7 @@ {{ Form::submit('update', ['class' => 'btn btn-info btn-sm', 'id' => 'set_father_button']) }}
    + @endcan {{ Form::close() }} @endif @@ -27,6 +29,7 @@ @if ($user->mother_id) {{ $user->mother->profileLink() }} @else + @can ('edit', $currentUser) {{ Form::open(['route' => ['family-actions.set-mother', $user->id]]) }} {!! FormField::select('set_mother_id', $femalePersonList, ['label' => false]) !!}
    @@ -36,12 +39,15 @@
    {{ Form::close() }} + @endcan @endif Orang Tua + + @can ('edit', $currentUser)
    @if (request('action') == 'set_parent') {{ link_to_route('users.show', 'Batal', [$user->id], ['class' => 'btn btn-default btn-xs']) }} @@ -49,9 +55,14 @@ {{ link_to_route('users.show', 'Set Orang Tua', [$user->id, 'action' => 'set_parent'], ['class' => 'btn btn-success btn-xs']) }} @endif
    + @endcan + + @if ($user->parent) {{ $user->parent->husband->name }} & {{ $user->parent->wife->name }} @endif + + @can('edit', $currentUser) @if (request('action') == 'set_parent') {{ Form::open(['route' => ['family-actions.set-parent', $user->id]]) }}
    @@ -62,12 +73,14 @@
    {{ Form::close() }} @endif + @endcan @if ($user->gender_id == 1) Isteri + @can ('edit', $currentUser)
    @if (request('action') == 'add_spouse') {{ link_to_route('users.show', 'Batal', [$user->id], ['class' => 'btn btn-default btn-xs']) }} @@ -75,6 +88,8 @@ {{ link_to_route('users.show', 'Tambah Isteri', [$user->id, 'action' => 'add_spouse'], ['class' => 'btn btn-success btn-xs']) }} @endif
    + @endcan + @if ($user->wifes->isEmpty() == false) @endif + @can('edit', $currentUser) @if (request('action') == 'add_spouse')
    {{ Form::open(['route' => ['family-actions.add-wife', $user->id]]) }} @@ -95,12 +111,14 @@ {{ Form::close() }}
    @endif + @endcan @else Suami + @can ('edit', $currentUser)
    @if (request('action') == 'add_spouse') {{ link_to_route('users.show', 'Batal', [$user->id], ['class' => 'btn btn-default btn-xs']) }} @@ -108,6 +126,7 @@ {{ link_to_route('users.show', 'Tambah Suami', [$user->id, 'action' => 'add_spouse'], ['class' => 'btn btn-success btn-xs']) }} @endif
    + @endcan @if ($user->husbands->isEmpty() == false) @endif + @can('edit', $currentUser) @if (request('action') == 'add_spouse')
    {{ Form::open(['route' => ['family-actions.add-husband', $user->id]]) }} @@ -128,6 +148,7 @@ {{ Form::close() }}
    @endif + @endcan @endif diff --git a/resources/views/users/show.blade.php b/resources/views/users/show.blade.php index 99d7ae7..2439213 100644 --- a/resources/views/users/show.blade.php +++ b/resources/views/users/show.blade.php @@ -3,7 +3,9 @@ @section('content')

    + @can ('edit', $currentUser) {{ link_to_route('users.edit', 'Edit Data', [$currentUser->id], ['class' => 'btn btn-warning']) }} + @endcan {{ link_to_route('users.chart', 'Lihat Bagan Keluarga', [$currentUser->id], ['class' => 'btn btn-default']) }} {{ link_to_route('users.tree', 'Lihat Pohon Keluarga', [$currentUser->id], ['class' => 'btn btn-default']) }}