Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
monero-project
CCS Backend
Commits
40021863
Commit
40021863
authored
Oct 12, 2018
by
beardedwarrior
Browse files
updated the project resource to add the qrcode and contributions
parent
5e4e0c8e
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/FundingController.php
View file @
40021863
...
...
@@ -30,23 +30,20 @@ class FundingController extends Controller
/**
* Shows the project based on the payment id
*
* @param Request $request
* @param $paymentId
*
* @return ProjectResource|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public
function
show
(
Request
$request
,
$paymentId
)
{
$project
=
Project
::
where
(
'payment_id'
,
$paymentId
)
->
first
();
if
(
!
$project
)
{
abort
(
404
);
}
$project
=
Project
::
where
(
'payment_id'
,
$paymentId
)
->
firstOrFail
();
if
(
$request
->
wantsJson
())
{
return
new
ProjectResource
(
$project
);
}
$qrcode
=
QrCode
::
format
(
'png'
)
->
size
(
100
)
->
generate
(
$project
->
uri
);
return
view
(
'projects.show'
)
->
with
(
'project'
,
$project
)
->
with
(
'qrcode'
,
$qrcode
);
->
with
(
'project'
,
$project
);
}
}
app/Http/Resources/ProjectResource.php
View file @
40021863
...
...
@@ -20,6 +20,8 @@ class ProjectResource extends JsonResource
'amount_received'
=>
$this
->
amount_received
,
'target_amount'
=>
$this
->
target_amount
,
'percentage_funded'
=>
$this
->
percentage_funded
,
'qrcode'
=>
[
'base64'
=>
base64_encode
(
$this
->
qrcode
)],
'contributions'
=>
$this
->
contributions
,
];
}
}
app/Project.php
View file @
40021863
...
...
@@ -19,6 +19,7 @@ use SimpleSoftwareIO\QrCode\Facades\QrCode;
* @property-read string $uri
* @property-read int $percentage_funded
* @property-read int $contributions
* @property-read string $qrcode
* @method static \Illuminate\Database\Eloquent\Builder|\App\Project whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Project whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Project wherePaymentId($value)
...
...
@@ -53,7 +54,7 @@ class Project extends Model
return
$this
->
deposits
->
count
()
??
0
;
}
public
function
getQr
C
odeAttribute
()
{
public
function
getQr
c
odeAttribute
()
{
return
QrCode
::
format
(
'png'
)
->
size
(
500
)
->
generate
(
$this
->
uri
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment