FundingController.php 994 Bytes
Newer Older
beardedwarrior's avatar
beardedwarrior committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php

namespace App\Http\Controllers;

use App\Deposit;
use App\Project;
use Illuminate\Http\Request;

class FundingController extends Controller
{
    /**
     * Generates the interstitial
     *
     * @param $invoice
     * @param null $currency
     * @param bool $moneroOnly
     * @param bool $shopifySite
     *
     * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
     */
    public function show($paymentId)
    {
        $project = Project::where('payment_id', $paymentId)->first();
24
25
26
27
28
29
        if (!$project) {
            abort(404);
        }
        $contributions = $project->deposits->count();
        $amountReceived = $project->deposits->sum('amount');
        $percentage = round($amountReceived / $project->target_amount * 100);
beardedwarrior's avatar
beardedwarrior committed
30
        return view('ffs')
31
32
33
34
            ->with('project', $project)
            ->with('contributions', $contributions)
            ->with('percentage', $percentage)
            ->with('amount_received', $amountReceived);
beardedwarrior's avatar
beardedwarrior committed
35
36
    }
}