Skip to content
Snippets Groups Projects
Commit fadeb1b9 authored by beardedwarrior's avatar beardedwarrior
Browse files

add soft attribute for amount received, add more index display

parent ee8d07de
No related branches found
No related tags found
No related merge requests found
...@@ -9,12 +9,21 @@ use Illuminate\Http\Request; ...@@ -9,12 +9,21 @@ use Illuminate\Http\Request;
class FundingController extends Controller class FundingController extends Controller
{ {
/** /**
* Generates the interstitial * Shows all projects
* *
* @param $invoice * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
* @param null $currency */
* @param bool $moneroOnly public function index()
* @param bool $shopifySite {
$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 * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
*/ */
...@@ -27,7 +36,7 @@ class FundingController extends Controller ...@@ -27,7 +36,7 @@ class FundingController extends Controller
$contributions = $project->deposits->count(); $contributions = $project->deposits->count();
$amountReceived = $project->deposits->sum('amount'); $amountReceived = $project->deposits->sum('amount');
$percentage = round($amountReceived / $project->target_amount * 100); $percentage = round($amountReceived / $project->target_amount * 100);
return view('ffs') return view('projects.show')
->with('project', $project) ->with('project', $project)
->with('contributions', $contributions) ->with('contributions', $contributions)
->with('percentage', $percentage) ->with('percentage', $percentage)
......
...@@ -13,4 +13,8 @@ class Project extends Model ...@@ -13,4 +13,8 @@ class Project extends Model
{ {
return $this->hasMany(Deposit::class, 'payment_id', 'payment_id'); 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 ...@@ -17,7 +17,7 @@ class CreateDepositsTable extends Migration
$table->increments('id'); $table->increments('id');
$table->string('payment_id'); $table->string('payment_id');
$table->string('amount'); $table->string('amount');
$table->unsignedInteger('time_received'); $table->dateTime('time_received');
$table->string('tx_id'); $table->string('tx_id');
$table->unsignedInteger('block_received'); $table->unsignedInteger('block_received');
$table->timestamps(); $table->timestamps();
......
...@@ -11,6 +11,6 @@ class DatabaseSeeder extends Seeder ...@@ -11,6 +11,6 @@ class DatabaseSeeder extends Seeder
*/ */
public function run() 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 @@ ...@@ -14,5 +14,5 @@
Route::get('/', function () { Route::get('/', function () {
return view('welcome'); return view('welcome');
}); });
Route::get('projects', ['as' => 'ffs', 'uses' => FundingController::class.'@index']);
Route::get('project/{paymentId}', ['as' => 'ffs', 'uses' => FundingController::class.'@show']); Route::get('projects/{paymentId}', ['as' => 'ffs', 'uses' => FundingController::class.'@show']);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment