From a64fdeb6f65780da8a22800df486f5c385ee0323 Mon Sep 17 00:00:00 2001
From: Muhammad Nizami <nizami_muhammad@yahoo.co.id>
Date: Tue, 17 May 2016 08:18:49 +0700
Subject: [PATCH] add log

---
 app/Models/Pencatatan.php                     |   3 +
 app/Models/Penduduk.php                       |   2 +
 app/Models/Permohonan.php                     |   6 +-
 app/User.php                                  |   3 +
 composer.json                                 |   3 +-
 config/app.php                                |   3 +
 config/auditing.php                           |  47 ++++++++
 .../2014_10_12_000000_create_users_table.php  |   1 +
 .../2015_08_01_104512_create_log_table.php    |  35 ++++++
 pencatatan_perkawinan_db.sql                  |  82 +++++++++++++-
 resources/views/layouts/base.blade.php        | 106 +-----------------
 11 files changed, 184 insertions(+), 107 deletions(-)
 create mode 100644 config/auditing.php
 create mode 100644 database/migrations/2015_08_01_104512_create_log_table.php

diff --git a/app/Models/Pencatatan.php b/app/Models/Pencatatan.php
index 875a288..fea13cc 100644
--- a/app/Models/Pencatatan.php
+++ b/app/Models/Pencatatan.php
@@ -4,9 +4,12 @@ namespace App\Models;
 
 use App\User;
 use Illuminate\Database\Eloquent\Model;
+use OwenIt\Auditing\AuditingTrait;
 
 class Pencatatan extends Model
 {
+	use AuditingTrait;
+	
     const STATUS_BELUM_PERNAH_MENIKAH = 0;
     const STATUS_PERNAH_MENIKAH = 1;
 
diff --git a/app/Models/Penduduk.php b/app/Models/Penduduk.php
index 0204d49..f2a1905 100644
--- a/app/Models/Penduduk.php
+++ b/app/Models/Penduduk.php
@@ -4,9 +4,11 @@ namespace App\Models;
 
 use App\User;
 use Illuminate\Database\Eloquent\Model;
+use OwenIt\Auditing\AuditingTrait;
 
 class Penduduk extends Model
 {
+	use Auditingtrait;
 	
 	protected $connection = 'mysqlcore';
 	
diff --git a/app/Models/Permohonan.php b/app/Models/Permohonan.php
index 7759a8f..fd863ad 100644
--- a/app/Models/Permohonan.php
+++ b/app/Models/Permohonan.php
@@ -4,9 +4,13 @@ namespace App\Models;
 
 use App\User;
 use Illuminate\Database\Eloquent\Model;
+use OwenIt\Auditing\AuditingTrait;
 
 class Permohonan extends Model
 {
+
+	use AuditingTrait;
+	
     const STATUS_NOT_COMPLETED = 0;
     const STATUS_PENDING = 1;
     const STATUS_APPROVED = 2;
@@ -51,4 +55,4 @@ class Permohonan extends Model
     {
         return "/" . self::SURAT_RW_DIR . $this->id;
     }
-}
\ No newline at end of file
+}
diff --git a/app/User.php b/app/User.php
index 987b427..303e6cc 100644
--- a/app/User.php
+++ b/app/User.php
@@ -4,9 +4,12 @@ namespace App;
 
 use App\Models\Permohonan;
 use Illuminate\Foundation\Auth\User as Authenticatable;
+use OwenIt\Auditing\AuditingTrait;
 
 class User extends Authenticatable
 {
+	use AuditingTrait;
+	
     const ROLE_USER = 0;
     const ROLE_PENCATAT = 1;
     const ROLE_ADMIN = 2;
diff --git a/composer.json b/composer.json
index 9439eaa..668b7aa 100644
--- a/composer.json
+++ b/composer.json
@@ -8,7 +8,8 @@
         "php": ">=5.5.9",
         "laravel/framework": "5.2.*",
         "laravelcollective/html": "5.2.*",
-        "illuminate/html": "5.*"
+        "illuminate/html": "5.*",
+        "owen-it/laravel-auditing": "^2.2"
     },
     "require-dev": {
         "fzaninotto/faker": "~1.4",
diff --git a/config/app.php b/config/app.php
index 1b3617e..7caa406 100644
--- a/config/app.php
+++ b/config/app.php
@@ -155,6 +155,9 @@ return [
         App\Providers\AuthServiceProvider::class,
         App\Providers\EventServiceProvider::class,
         App\Providers\RouteServiceProvider::class,
+        
+		// ...
+		OwenIt\Auditing\AuditingServiceProvider::class,
 
     ],
 
diff --git a/config/auditing.php b/config/auditing.php
new file mode 100644
index 0000000..68ceeb9
--- /dev/null
+++ b/config/auditing.php
@@ -0,0 +1,47 @@
+<?php
+
+/*
+ * This file is part of laravel-auditing.
+ *
+ * @author Antério Vieira <anteriovieira@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Authentication Model
+    |--------------------------------------------------------------------------
+    |
+    | When using the "Eloquent" authentication driver, we need to know which
+    | Eloquent model should be used to retrieve your users. Of course, it
+    | is often just the "User" model but you may use whatever you like.
+    |
+    */
+
+    'model' => App\User::class,
+
+    /*
+    |--------------------------------------------------------------------------
+    | Database Connection
+    |--------------------------------------------------------------------------
+    |
+    | Here is the the database connection for the auditing log.
+    |
+    */
+    'connection' => null,
+
+    /*
+    |--------------------------------------------------------------------------
+    | Table
+    |--------------------------------------------------------------------------
+    |
+    | Here is the the table associated with the auditing model.
+    |
+    */
+
+    'table' => 'logs',
+];
diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php
index 59aa01a..e0d230a 100644
--- a/database/migrations/2014_10_12_000000_create_users_table.php
+++ b/database/migrations/2014_10_12_000000_create_users_table.php
@@ -17,6 +17,7 @@ class CreateUsersTable extends Migration
             $table->string('name');
             $table->string('email')->unique();
             $table->string('password');
+            $table->integer('role');
             $table->rememberToken();
             $table->timestamps();
         });
diff --git a/database/migrations/2015_08_01_104512_create_log_table.php b/database/migrations/2015_08_01_104512_create_log_table.php
new file mode 100644
index 0000000..0151d97
--- /dev/null
+++ b/database/migrations/2015_08_01_104512_create_log_table.php
@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+
+class CreateLogTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('logs', function ($table) {
+            $table->increments('id');
+            $table->integer('user_id')->nullable();
+            $table->string('owner_type');
+            $table->integer('owner_id');
+            $table->text('old_value')->nullable();
+            $table->text('new_value')->nullable();
+            $table->string('type');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::drop('logs');
+    }
+}
diff --git a/pencatatan_perkawinan_db.sql b/pencatatan_perkawinan_db.sql
index e41fe36..8974b99 100644
--- a/pencatatan_perkawinan_db.sql
+++ b/pencatatan_perkawinan_db.sql
@@ -11,6 +11,82 @@ SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
 SET time_zone = "+00:00";
 
 
+
+DROP TABLE IF EXISTS `logs`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `logs` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `user_id` int(11) DEFAULT NULL,
+  `owner_type` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
+  `owner_id` int(11) NOT NULL,
+  `old_value` text COLLATE utf8_unicode_ci,
+  `new_value` text COLLATE utf8_unicode_ci,
+  `type` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
+  `created_at` timestamp NULL DEFAULT NULL,
+  `updated_at` timestamp NULL DEFAULT NULL,
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `logs`
+--
+
+LOCK TABLES `logs` WRITE;
+/*!40000 ALTER TABLE `logs` DISABLE KEYS */;
+/*!40000 ALTER TABLE `logs` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `migrations`
+--
+
+DROP TABLE IF EXISTS `migrations`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `migrations` (
+  `migration` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
+  `batch` int(11) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `migrations`
+--
+
+LOCK TABLES `migrations` WRITE;
+/*!40000 ALTER TABLE `migrations` DISABLE KEYS */;
+INSERT INTO `migrations` VALUES ('2014_10_12_000000_create_users_table',1),('2014_10_12_100000_create_password_resets_table',1),('2015_08_01_104512_create_log_table',1);
+/*!40000 ALTER TABLE `migrations` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `password_resets`
+--
+
+DROP TABLE IF EXISTS `password_resets`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `password_resets` (
+  `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
+  `token` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
+  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  KEY `password_resets_email_index` (`email`),
+  KEY `password_resets_token_index` (`token`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `password_resets`
+--
+
+LOCK TABLES `password_resets` WRITE;
+/*!40000 ALTER TABLE `password_resets` DISABLE KEYS */;
+/*!40000 ALTER TABLE `password_resets` ENABLE KEYS */;
+UNLOCK TABLES;
+
+
 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
 /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
@@ -92,6 +168,8 @@ CREATE TABLE IF NOT EXISTS `users` (
   `password` varchar(128) NOT NULL,
   `remember_token` varchar(128) DEFAULT NULL,
   `role` int(11) DEFAULT '0',
+  `created_at` timestamp NULL DEFAULT NULL,
+  `updated_at` timestamp NULL DEFAULT NULL,
   `name` varchar(128) DEFAULT NULL
 ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
 
@@ -104,7 +182,9 @@ INSERT INTO `users` (`id`, `email`, `password`, `remember_token`, `role`, `name`
 (6, 'vincent.s.the@gmail.com', 'c2d628ba98ed491776c9335e988e2e3b', 'Yz8Ipe5VWeGgOlRpuZ1vLucEEQQ08UvqfAE3xvTrLkZHkH8YM0xnRrb161Mb', 0, 'Vincent Sebastian'),
 (8, 'qwe@qwe.qwe', 'efe6398127928f1b2e9ef3207fb82663', NULL, 1, 'qwe'),
 (9, 'admin@admin.com', '21232f297a57a5a743894a0e4a801fc3', NULL, 2, 'admin'),
-(10, 'coba@coba.com', 'c3ec0f7b054e729c5a716c8125839829', NULL, 0, 'coba');
+(10, 'coba@coba.com', 'c3ec0f7b054e729c5a716c8125839829', NULL, 0, 'coba'),
+(11, 'admin@dukcapil.bandung.go.id', '21232f297a57a5a743894a0e4a801fc3', NULL, 2, 'Nama Admin Dukcapil Bandung'),
+(12, 'petugas@dukcapil.bandung.go.id', '21232f297a57a5a743894a0e4a801fc3', NULL, 1, 'Nama Petugas Pencatatan Perkawinan Dukcapil Bandung');
 
 --
 -- Indexes for dumped tables
diff --git a/resources/views/layouts/base.blade.php b/resources/views/layouts/base.blade.php
index 8f0cba7..bc2aea6 100644
--- a/resources/views/layouts/base.blade.php
+++ b/resources/views/layouts/base.blade.php
@@ -35,8 +35,7 @@
             </button>
             <!-- brand -->
             <a href="#/" class="navbar-brand text-lt">
-                <img src="{{ URL::asset('assets/img/logo-small.png') }}" alt="." class="small-logo hide">
-                <img src="{{ URL::asset('assets/img/logo.png') }}" alt="." class="large-logo">
+                PERKAWINANBDG
             </a>
             <!-- / brand -->
           </div>
@@ -50,117 +49,16 @@
             </div>
             <!-- / buttons -->
 
-            <!-- link and dropdown -->
-            <ul class="nav navbar-nav hidden-sm">
-                <li>
-                    <a href="#">HOME</a>
-                </li>
-                <li class="dropdown">
-                    <a href="#" data-toggle="dropdown" class="dropdown-toggle">
-                        <i class="fa fa-fw fa-plus visible-xs-inline-block"></i>
-                        <span>PAGES</span> <span class="caret"></span>
-                    </a>
-                    <ul class="dropdown-menu" role="menu">
-
-                        <li>
-                            <a href="#">
-                                <span class="badge bg-danger pull-right">5</span>
-                                <span>Form Elements</span>
-                            </a>
-                        </li>
-
-                        <li>
-                            <a href="#">
-                                <span class="badge bg-info pull-right">15</span>
-                                <span>Form Validation</span>
-                            </a>
-                        </li>
-
-                        <li>
-                            <a href="#">
-                                <span>Form Wizard</span>
-                            </a>
-                        </li>
-
-                    </ul>
-                </li>
-                <li>
-                    <a href="#">PROJECT</a>
-                </li>
-            </ul>
             <!-- / link and dropdown -->
 
             <!-- nabar right -->
             <ul class="nav navbar-nav navbar-right">
-                <li class="dropdown">
-                    <a href="#" data-toggle="dropdown" class="dropdown-toggle">
-                        <i class="icon-bdg_alert text14"></i>
-                        <span class="visible-xs-inline">Notifikasi</span>
-                        <span class="badge badge-sm up bg-danger pull-right-xs">2</span>
-                    </a>
-                    <!-- dropdown -->
-                    <div class="dropdown-menu w-xl animated fadeIn">
-                        <div class="panel bg-white">
-                            <div class="panel-heading b-light bg-light">
-                                <strong>Kamu Punya <span>2</span> Notifikasi</strong>
-                            </div>
-                            <div class="list-group">
-                                <a href class="list-group-item">
-                    <span class="pull-left m-r thumb-sm">
-                      <img src="{{ URL::asset('assets/img/01.jpg') }}" alt="..." class="img-circle">
-                    </span>
-                    <span class="clear block m-b-none">
-                      Pembangunan Taman daerah Bandung Barat<br>
-                      <small class="text-muted">10 minutes ago</small>
-                    </span>
-                                </a>
-                                <a href class="list-group-item">
-                    <span class="clear block m-b-none">
-                      Revitalisasi Sungai Cikapundung<br>
-                      <small class="text-muted">1 hour ago</small>
-                    </span>
-                                </a>
-                            </div>
-                            <div class="panel-footer text-sm">
-                                <a href class="pull-right"><i class="icon-bdg_setting3"></i></a>
-                                <a href="#notes" data-toggle="class:show animated fadeInRight">Lihat Semua Notifikasi</a>
-                            </div>
-                        </div>
-                    </div>
-                    <!-- / dropdown -->
-                </li>
-                <li class="dropdown">
-                    <a href="#" data-toggle="dropdown" class="dropdown-toggle">
-                        <i class="icon-bdg_search text14"></i>
-                    </a>
-                    <!-- dropdown -->
-                    <div class="search_wrapper pull-right w-xl animated fadeIn">
-                        <form action="">
-                            <i class="pull-left glyphicon glyphicon-search"></i>
-                            <input type="text" class="pull-left" placeholder="Type Here">
-                            <a href="#" class="remove-search"><i class="pull-right icon-bdg_cross"></i></a>
-                        </form>
-                    </div>
-                    <!-- / dropdown -->
-                </li>
                 <li class="dropdown">
                     <a href="#" data-toggle="dropdown" class="bg-blue profile-header dropdown-toggle clear" data-toggle="dropdown">
-              <span class="thumb-sm avatar pull-left m-t-n-sm m-b-n-sm m-r-sm">
-                <img src="{{ URL::asset('assets/img/01.jpg') }}" alt="...">
-              </span>
-                        <span class="hidden-sm hidden-md m-r-xl">Ridwan Kamil</span> <i class="text14 icon-bdg_setting3 pull-right"></i>
+                                      <span class="hidden-sm hidden-md m-r-xl"> Akun </span> <i class="text14 icon-bdg_setting3 pull-right"></i>
                     </a>
                     <!-- dropdown -->
                     <ul class="dropdown-menu animated fadeIn w-ml">
-                        <li>
-                            <a href>
-                                <span class="badge bg-danger pull-right">30%</span>
-                                <span>Settings</span>
-                            </a>
-                        </li>
-                        <li>
-                            <a href>Profile</a>
-                        </li>
                         <li>
                             <a href>
                                 <span class="label bg-info pull-right">new</span>
-- 
GitLab