Commit 238c82b7 authored by beardedwarrior's avatar beardedwarrior

added the additional fields to the projects

parent cf1f9603
......@@ -51,10 +51,6 @@ class Project extends Model
return $this->deposits->sum('amount');
}
public function getUriAttribute() {
return 'monero:'.env('WALLET_ADDRESS').'tx_payment_id='.$this->payment_id;
}
public function getPercentageFundedAttribute() {
return round($this->amount_received / $this->target_amount * 100);
}
......@@ -63,7 +59,12 @@ class Project extends Model
return $this->deposits->count() ?? 0;
}
public function getQrcodeAttribute() {
public function generateQrcode() {
return QrCode::format('png')->size(500)->generate($this->uri);
}
public function getQrCodeSrcAttribute() {
$encoded = base64_encode($this->generateQrcode());
return "data:image/png;base64, {$encoded}";
}
}
......@@ -8,7 +8,11 @@ $factory->define(\App\Project::class, function (Faker $faker) {
return [
'title' => $faker->sentence(),
'payment_id' => $faker->sha256,
'address' => $faker->sha256,
'address_uri' => "monero:{$faker->sha256}",
'qr_code' => $faker->file(),
'target_amount' => $faker->randomFloat(2, 0, 2000),
'raised_amount' => $faker->randomFloat(2, 0, 2000),
'state' => $state,
'merge_request_id' => $faker->randomNumber(6),
'gitlab_username' => $faker->userName,
......
......@@ -18,7 +18,10 @@ class CreateProjectsTable extends Migration
$table->string('title');
$table->string('payment_id')->nullable();
$table->string('address')->nullable();
$table->string('address_uri')->nullable();
$table->string('qr_code')->nullable();
$table->string('target_amount')->nullable();
$table->string('raised_amount')->nullable();
$table->string('state')->default('OPENED');
$table->string('filename')->nullable();
$table->unsignedInteger('merge_request_id')->unique();
......
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