Browse Source

Add user birth order

Add birth_order to users table
Birth order is order of someone's birth number
among of their siblings
pull/13/head
Nafies Luthfi 7 years ago
parent
commit
488b6150c4
  1. 1
      app/Http/Controllers/UsersController.php
  2. 23
      app/Http/Requests/Users/UpdateRequest.php
  3. 2
      app/User.php
  4. 5
      database/migrations/2014_10_12_000000_create_users_table.php
  5. 1
      resources/lang/en/user.php
  6. 1
      resources/lang/id/user.php
  7. 7
      resources/views/users/edit.blade.php
  8. 8
      resources/views/users/partials/profile.blade.php
  9. 46
      tests/Feature/UsersProfileTest.php

1
app/Http/Controllers/UsersController.php

@ -130,6 +130,7 @@ class UsersController extends Controller
$user->gender_id = $request->get('gender_id');
$user->dob = $request->get('dob');
$user->dod = $request->get('dod');
$user->birth_order = $request->get('birth_order');
if ($request->get('dod')) {
$user->yod = substr($request->get('dod'), 0, 4);

23
app/Http/Requests/Users/UpdateRequest.php

@ -26,17 +26,18 @@ class UpdateRequest extends FormRequest
public function rules()
{
return [
'nickname' => 'required|string|max:255',
'name' => 'required|string|max:255',
'gender_id' => 'required|numeric',
'dob' => 'nullable|date|date_format:Y-m-d',
'dod' => 'nullable|date|date_format:Y-m-d',
'yod' => 'nullable|date_format:Y',
'phone' => 'nullable|string|max:255',
'address' => 'nullable|string|max:255',
'city' => 'nullable|string|max:255',
'email' => 'nullable|string|max:255',
'password' => 'nullable|min:6|max:15',
'nickname' => 'required|string|max:255',
'name' => 'required|string|max:255',
'gender_id' => 'required|numeric',
'dob' => 'nullable|date|date_format:Y-m-d',
'dod' => 'nullable|date|date_format:Y-m-d',
'yod' => 'nullable|date_format:Y',
'phone' => 'nullable|string|max:255',
'address' => 'nullable|string|max:255',
'city' => 'nullable|string|max:255',
'email' => 'nullable|string|max:255',
'password' => 'nullable|min:6|max:15',
'birth_order' => 'nullable|numeric|min:1',
];
}

2
app/User.php

@ -23,7 +23,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'id',
'id', 'birth_order',
'nickname', 'gender_id', 'name',
'email', 'password',
'address', 'phone',

5
database/migrations/2014_10_12_000000_create_users_table.php

@ -1,8 +1,8 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
@ -22,6 +22,7 @@ class CreateUsersTable extends Migration
$table->uuid('mother_id')->nullable();
$table->uuid('parent_id')->nullable();
$table->date('dob')->nullable();
$table->unsignedTinyInteger('birth_order')->nullable();
$table->date('dod')->nullable();
$table->date('yod')->nullable();
$table->string('email')->unique()->nullable();

1
resources/lang/en/user.php

@ -17,6 +17,7 @@ return [
'grand_father' => 'Grand Father',
'nieces' => 'Nieces',
'marriages' => 'Marriages',
'birth_order' => 'Birth Order',
// Actions
'edit' => 'Edit Profile',

1
resources/lang/id/user.php

@ -17,6 +17,7 @@ return [
'grand_father' => 'Kakek',
'nieces' => 'Keponakan',
'marriages' => 'Pernikahan',
'birth_order' => 'Anak ke',
// Actions
'edit' => 'Edit Profil',

7
resources/views/users/edit.blade.php

@ -70,6 +70,11 @@
<div class="col-md-6">{!! FormField::text('dob', ['label' => trans('user.dob'), 'placeholder' => trans('app.example').' 1959-07-20']) !!}</div>
</div>
<div class="row">
<div class="col-md-4">
{!! FormField::text('birth_order', ['label' => trans('user.birth_order'), 'type' => 'number', 'min' => 1]) !!}
</div>
</div>
<div class="row">
<div class="col-md-6">{!! FormField::text('yod', ['label' => trans('user.yod'), 'placeholder' => trans('app.example').' 2003']) !!}</div>
<div class="col-md-6">{!! FormField::text('dod', ['label' => trans('user.dod'), 'placeholder' => trans('app.example').' 2003-10-17']) !!}</div>
</div>
@ -78,7 +83,7 @@
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ trans('app.address') }} & {{ trans('app.contact') }}</h3></div>
<div class="panel-heading"><h3 class="panel-title">{{ trans('app.address') }} &amp; {{ trans('app.contact') }}</h3></div>
<div class="panel-body">
{!! FormField::textarea('address', ['label' => trans('app.address')]) !!}
{!! FormField::text('city', ['label' => trans('app.city'), 'placeholder' => trans('app.example').' Jakarta']) !!}

8
resources/views/users/partials/profile.blade.php

@ -7,9 +7,7 @@
<tbody>
<tr>
<th class="col-sm-4">{{ trans('user.name') }}</th>
<td class="col-sm-8">
{{ $user->profileLink() }}
</td>
<td class="col-sm-8">{{ $user->profileLink() }}</td>
</tr>
<tr>
<th>{{ trans('user.nickname') }}</th>
@ -23,6 +21,10 @@
<th>{{ trans('user.dob') }}</th>
<td>{{ $user->dob }}</td>
</tr>
<tr>
<th>{{ trans('user.birth_order') }}</th>
<td>{{ $user->birth_order }}</td>
</tr>
@if ($user->dod)
<tr>
<th>{{ trans('user.dod') }}</th>

46
tests/Feature/UsersProfileTest.php

@ -27,31 +27,33 @@ class UsersProfileTest extends TestCase
$this->seePageIs(route('users.edit', $user->id));
$this->submitForm(trans('app.update'), [
'nickname' => 'Nama Panggilan',
'name' => 'Nama User',
'gender_id' => 1,
'dob' => '1959-06-09',
'dod' => '2003-10-17',
'yod' => '',
'address' => 'Jln. Angkasa, No. 70',
'city' => 'Nama Kota',
'phone' => '081234567890',
'email' => '',
'password' => '',
'nickname' => 'Nama Panggilan',
'name' => 'Nama User',
'gender_id' => 1,
'dob' => '1959-06-09',
'dod' => '2003-10-17',
'yod' => '',
'address' => 'Jln. Angkasa, No. 70',
'city' => 'Nama Kota',
'phone' => '081234567890',
'email' => '',
'password' => '',
'birth_order' => 3,
]);
$this->seeInDatabase('users', [
'nickname' => 'Nama Panggilan',
'name' => 'Nama User',
'gender_id' => 1,
'dob' => '1959-06-09',
'dod' => '2003-10-17',
'yod' => '2003',
'address' => 'Jln. Angkasa, No. 70',
'city' => 'Nama Kota',
'phone' => '081234567890',
'email' => null,
'password' => null,
'nickname' => 'Nama Panggilan',
'name' => 'Nama User',
'gender_id' => 1,
'dob' => '1959-06-09',
'dod' => '2003-10-17',
'yod' => '2003',
'address' => 'Jln. Angkasa, No. 70',
'city' => 'Nama Kota',
'phone' => '081234567890',
'email' => null,
'password' => null,
'birth_order' => 3,
]);
}

Loading…
Cancel
Save