Commit fadeb1b9 authored by beardedwarrior's avatar beardedwarrior

add soft attribute for amount received, add more index display

parent ee8d07de
......@@ -9,12 +9,21 @@ use Illuminate\Http\Request;
class FundingController extends Controller
{
/**
* Generates the interstitial
* Shows all projects
*
* @param $invoice
* @param null $currency
* @param bool $moneroOnly
* @param bool $shopifySite
* @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
*/
public function index()
{
$projects = Project::all();
return view('projects.index')
->with('projects', $projects);
}
/**
* Shows the project based on the payment id
*
* @param $paymentId
*
* @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
*/
......@@ -27,7 +36,7 @@ class FundingController extends Controller
$contributions = $project->deposits->count();
$amountReceived = $project->deposits->sum('amount');
$percentage = round($amountReceived / $project->target_amount * 100);
return view('ffs')
return view('projects.show')
->with('project', $project)
->with('contributions', $contributions)
->with('percentage', $percentage)
......
......@@ -13,4 +13,8 @@ class Project extends Model
{
return $this->hasMany(Deposit::class, 'payment_id', 'payment_id');
}
public function getAmountReceivedAttribute() {
return $this->deposits->sum('amount');
}
}
......@@ -17,7 +17,7 @@ class CreateDepositsTable extends Migration
$table->increments('id');
$table->string('payment_id');
$table->string('amount');
$table->unsignedInteger('time_received');
$table->dateTime('time_received');
$table->string('tx_id');
$table->unsignedInteger('block_received');
$table->timestamps();
......
......@@ -11,6 +11,6 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
// $this->call(UsersTableSeeder::class);
$this->call(ProjectsTableSeeder::class);
}
}
<table>
<thead class="flip-content">
<tr>
<th>Payment ID</th>
<th>Status</th>
<th>Funding Received</th>
<th>Required</th>
</tr>
</thead>
<tbody>
@foreach ($projects as $project)
<tr>
<td><a href='{!! url('/projects/'.$project->payment_id); !!}'>{{ $project->payment_id }}</a></td>
<td>{{$project->status}}</td>
<td>{{$project->amountReceived}} XMR</td>
<td>{{$project->target_amount}} XMR</td>
</tr>
@endforeach
</tbody>
</table>
\ No newline at end of file
......@@ -14,5 +14,5 @@
Route::get('/', function () {
return view('welcome');
});
Route::get('project/{paymentId}', ['as' => 'ffs', 'uses' => FundingController::class.'@show']);
Route::get('projects', ['as' => 'ffs', 'uses' => FundingController::class.'@index']);
Route::get('projects/{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