Commit 8304a44a authored by beardedwarrior's avatar beardedwarrior

added more detail to the project page, percentage, number of contributions and total requested

parent ded0e69b
...@@ -21,7 +21,16 @@ class FundingController extends Controller ...@@ -21,7 +21,16 @@ class FundingController extends Controller
public function show($paymentId) public function show($paymentId)
{ {
$project = Project::where('payment_id', $paymentId)->first(); $project = Project::where('payment_id', $paymentId)->first();
if (!$project) {
abort(404);
}
$contributions = $project->deposits->count();
$amountReceived = $project->deposits->sum('amount');
$percentage = round($amountReceived / $project->target_amount * 100);
return view('ffs') return view('ffs')
->with('amount_received', $project->deposts->sum('amount')); ->with('project', $project)
->with('contributions', $contributions)
->with('percentage', $percentage)
->with('amount_received', $amountReceived);
} }
} }
...@@ -11,6 +11,6 @@ class Project extends Model ...@@ -11,6 +11,6 @@ class Project extends Model
*/ */
public function deposits() public function deposits()
{ {
return $this->hasMany(Deposit::class); return $this->hasMany(Deposit::class, 'payment_id', 'payment_id');
} }
} }
{{amount_received}} XMR {{$amount_received}} / XMR {{$project->target_amount}} Target
\ No newline at end of file
{{$contributions}} contributions made. {{$percentage}}%
\ No newline at end of file
...@@ -15,4 +15,4 @@ Route::get('/', function () { ...@@ -15,4 +15,4 @@ Route::get('/', function () {
return view('welcome'); return view('welcome');
}); });
Route::get('project/{paymentId}', ['as' => 'ffs', 'uses' => \App\Http\Controllers\FundingController::class.'@show']); Route::get('project/{paymentId}', ['as' => 'ffs', 'uses' => FundingController::class.'@show']);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment