diff --git a/.rnd b/.rnd
new file mode 100644
index 0000000000000000000000000000000000000000..8aa16cfcdb5cb2710c78dbfa194deaaa34a286d1
Binary files /dev/null and b/.rnd differ
diff --git a/app/GroupHistory.php b/app/GroupHistory.php
new file mode 100644
index 0000000000000000000000000000000000000000..4fb7400cc57d6067689b6755105ed15eb11e4d16
--- /dev/null
+++ b/app/GroupHistory.php
@@ -0,0 +1,55 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Builder;
+class GroupHistory extends Model
+{
+    //
+    protected $table = 'group_history';
+    protected $primaryKey = ['group_id', 'tanggal'];
+    protected $fillable = [
+        'group_id', 'score_sisa', 'tanggal'
+    ];
+    public $incrementing = false;
+
+    /**
+     * Set the keys for a save update query.
+     *
+     * @param  \Illuminate\Database\Eloquent\Builder  $query
+     * @return \Illuminate\Database\Eloquent\Builder
+     */
+    protected function setKeysForSaveQuery(Builder $query)
+    {
+        $keys = $this->getKeyName();
+        if(!is_array($keys)){
+            return parent::setKeysForSaveQuery($query);
+        }
+
+        foreach($keys as $keyName){
+            $query->where($keyName, '=', $this->getKeyForSaveQuery($keyName));
+        }
+
+        return $query;
+    }
+
+    /**
+     * Get the primary key value for a save query.
+     *
+     * @param mixed $keyName
+     * @return mixed
+     */
+    protected function getKeyForSaveQuery($keyName = null)
+    {
+        if(is_null($keyName)){
+            $keyName = $this->getKeyName();
+        }
+
+        if (isset($this->original[$keyName])) {
+            return $this->original[$keyName];
+        }
+
+        return $this->getAttribute($keyName);
+    }
+}
diff --git a/app/Http/Controllers/GroupHistoryController.php b/app/Http/Controllers/GroupHistoryController.php
new file mode 100644
index 0000000000000000000000000000000000000000..121d6682691c3eb08e009aa68f90121d7a45630e
--- /dev/null
+++ b/app/Http/Controllers/GroupHistoryController.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+class GroupHistoryController extends Controller
+{
+    //
+    public function getHistory($groupId) {
+        $history = DB::table('group_history')
+        ->select('score_sisa','tanggal')
+        ->where([
+            'group_id' => $groupId
+        ])
+        ->orderBy('tanggal', 'asc')
+        ->get();
+
+        return response(json_encode([
+            'data' => $history->toArray(),
+            'statusMessage' => 'success'
+        ]), 200);
+    }
+}
diff --git a/app/Tasks.php b/app/Tasks.php
index 2ecce701fa57c1a1d7899a5215eb0329a41c8733..364c3a9a5a7a0ba98faf0a00bb6d490c5b38c8e8 100644
--- a/app/Tasks.php
+++ b/app/Tasks.php
@@ -3,7 +3,9 @@
 namespace App;
 
 use Illuminate\Database\Eloquent\Model;
-
+use App\GroupHistory;
+use Illuminate\Support\Facades\Config;
+use Illuminate\Support\Facades\DB;
 class Tasks extends Model
 {
 
@@ -20,4 +22,82 @@ class Tasks extends Model
     public function pic() {
         return $this->hasOne('App\TasksMember', 'task_id');
     }
+
+
+    public static function boot() {
+        parent::boot();
+        static::created(function (Tasks $item) {
+            if ($item->kanban_status !== Config::get('constants.KANBAN_STATUS.PRODUCT_BACKLOG') && $item->kanban_status !== Config::get('constants.KANBAN_STATUS.DONE')) {
+                $groupHistory = GroupHistory::where([
+                    'group_id' => $item->group_id,
+                    'tanggal' => date("Y-m-d")
+                ])->first();
+                if (is_null($groupHistory)) {
+                    $groupWorkHour = DB::table('tasks')
+                    ->select('group_id', DB::raw('SUM(work_hour) as total_work_hour'))
+                    ->where([
+                        ['group_id' , '=', $item->group_id],
+                        ['kanban_status', '<>', Config::get('constants.KANBAN_STATUS.PRODUCT_BACKLOG')],
+                        ['kanban_status', '<>', Config::get('constants.KANBAN_STATUS.DONE')]
+                    ])
+                    ->groupBy('group_id')->get()->first();
+                    $score_sisa = 0;
+                    if (!is_null($groupWorkHour)) {
+                        $score_sisa = $groupWorkHour->total_work_hour;
+                    }
+                    $score_sisa = $score_sisa < 0 ? 0 : $score_sisa;
+                    GroupHistory::create([
+                        'group_id' => $item->group_id,
+                        'tanggal' => date("Y-m-d"),
+                        'score_sisa' => $score_sisa 
+                    ]);
+                } else {
+                    $score_sisa = $groupHistory->score_sisa + $item->work_hour;
+                    $score_sisa = $score_sisa < 0 ? 0 : $score_sisa;
+                    $groupHistory->score_sisa = $score_sisa;
+                    $groupHistory->save();
+                }
+            }
+        });
+        static::updating(function (Tasks $item) {
+            $taskNow = Tasks::where([
+                'id' => $item->id
+            ])->first();
+            if ( !is_null($taskNow) && $taskNow->kanban_status != Config::get('constants.KANBAN_STATUS.DONE') && $item->kanban_status == Config::get('constants.KANBAN_STATUS.DONE')) {
+                $groupHistory = GroupHistory::where([
+                    'group_id' => $item->group_id,
+                    'tanggal' => '2019-03-24'
+                ])->first();
+                if (is_null($groupHistory)) {
+                    $groupWorkHour = DB::table('tasks')
+                    ->select('group_id', DB::raw('SUM(work_hour) as total_work_hour'))
+                    ->where([
+                        ['group_id' , '=', $item->group_id],
+                        ['kanban_status', '<>', Config::get('constants.KANBAN_STATUS.PRODUCT_BACKLOG')],
+                        ['kanban_status', '<>', Config::get('constants.KANBAN_STATUS.DONE')]
+                    ])
+                    ->groupBy('group_id')->get()->first();
+                    $score_sisa = 0;
+                    if (!is_null($groupWorkHour)) {
+                        $score_sisa = $groupWorkHour->total_work_hour - $item->work_hour;
+                    }
+                    $score_sisa = $score_sisa < 0 ? 0 : $score_sisa;
+                    GroupHistory::create([
+                        'group_id' => $item->group_id,
+                        'tanggal' => '2019-03-24',
+                        'score_sisa' => $score_sisa
+                    ]);
+                } else {
+                    $score_sisa = $groupHistory->score_sisa - $item->work_hour;
+                    $score_sisa = $score_sisa < 0 ? 0 : $score_sisa;
+                    $groupHistory->score_sisa = $score_sisa;
+                    $groupHistory->save();
+                }
+            }
+        });
+    }
+
+    // public function loggingInsertHistory(Tasks $item){
+        
+    // }
 }
diff --git a/database/migrations/2019_02_24_054218_create_group_history_table.php b/database/migrations/2019_02_24_054218_create_group_history_table.php
new file mode 100644
index 0000000000000000000000000000000000000000..f695dcb0ab92bea6f9e6de11bc81acb60908754d
--- /dev/null
+++ b/database/migrations/2019_02_24_054218_create_group_history_table.php
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateGroupHistoryTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('group_history', function (Blueprint $table) {
+            $table->unsignedInteger('group_id');
+            $table->unsignedInteger('score_sisa');
+            $table->date('tanggal');
+            $table->primary(['group_id', 'tanggal']);
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('group_history');
+    }
+}
diff --git a/routes/api.php b/routes/api.php
index 03b7208eb6e49a2a43e1252a786fc3df70e271e4..b6edc4878712aef3f1d519333954c3ac76d84a10 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -54,6 +54,8 @@ Route::get('/group/{groupId}/members', 'GroupsMemberController@show'); //Bisa am
 Route::put('/group/{groupId}/member/{userId}', 'GroupsMemberController@update');
 Route::delete('/group/{groupId}/member/{userId}', 'GroupsMemberController@delete');
 
+//Get History Group
+Route::get('/group/{groupId}/history', 'GroupHistoryController@getHistory'); //Bisa ambil seluruh member dari suatu group
 
 // Route::group(['middleware' => 'auth:api'], function()
 // {