Browse Source

Fixed add user's child feature

pull/3/head
Nafies Luthfi 9 years ago
parent
commit
466ee8ee3c
  1. 4
      app/Http/Controllers/FamilyActionsController.php
  2. 2
      resources/views/home.blade.php

4
app/Http/Controllers/FamilyActionsController.php

@ -37,7 +37,7 @@ class FamilyActionsController extends Controller
return back(); return back();
} }
public function addChild(Request $request)
public function addChild(Request $request, User $user)
{ {
$this->validate($request, [ $this->validate($request, [
'add_child_name' => 'required|string|max:255', 'add_child_name' => 'required|string|max:255',
@ -49,8 +49,6 @@ class FamilyActionsController extends Controller
$child->gender_id = $request->get('add_child_gender_id'); $child->gender_id = $request->get('add_child_gender_id');
$child->save(); $child->save();
$user = auth()->user();
if ($user->gender_id == 1) if ($user->gender_id == 1)
$child->setFather($user); $child->setFather($user);
else else

2
resources/views/home.blade.php

@ -28,7 +28,7 @@
@if ($currentUser->father_id) @if ($currentUser->father_id)
{{ $currentUser->father->profileLink() }} {{ $currentUser->father->profileLink() }}
@else @else
{{ Form::open(['route' => ['family-actions.set-father', $currentUser->id]]) }}
{{ Form::open(['route' => ['family-actions.set-father', $currentUser->id, $currentUser->id]]) }}
<div class="input-group"> <div class="input-group">
{{ Form::text('set_father', null, ['class' => 'form-control input-sm']) }} {{ Form::text('set_father', null, ['class' => 'form-control input-sm']) }}
<span class="input-group-btn"> <span class="input-group-btn">

Loading…
Cancel
Save