Skip to content

Commit

Permalink
feat(admin): show campaign status, count and collected
Browse files Browse the repository at this point in the history
  • Loading branch information
tioirawan committed Jun 27, 2023
1 parent 22d40be commit c60a17d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/Http/Controllers/Admin/CampaignCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ protected function setupListOperation()
CRUD::column('partner_id');
CRUD::column('title');
CRUD::column('status');
CRUD::column('description');
CRUD::column('fund_target');
CRUD::column('funder_count');
CRUD::column('collected_per_total');
CRUD::column('return_percentage');
CRUD::column('tenor');
CRUD::column('start_date');
CRUD::column('finish_date');
CRUD::column('slug');

// CRUD::column('description');

/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/CampaignController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function __construct()
$this->middleware('auth');
$this->middleware('partner');
}

public function index()
{
//
Expand Down
11 changes: 11 additions & 0 deletions app/Models/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,15 @@ public function getReturnTargetAttribute()
{
return $this->fund_target + ($this->fund_target * $this->return_percentage / 100);
}

public function getFunderCountAttribute()
{
return $this->fundings->count('user_id');
}

public function getCollectedPerTotalAttribute()
{

return 'Rp. ' . number_format($this->fundings->sum('fund_nominal'), 0, ',', '.') . " / Rp. " . number_format($this->fund_target, 0, ',', '.');
}
}

0 comments on commit c60a17d

Please sign in to comment.