Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
abalsh
/
Garlix
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7fadc840
authored
6 years ago
by
Florian Shllaku
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypto front end and swap button done
parent
bda474aa
master
…
laravel
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
77 additions
and
58 deletions
app/Console/Commands/updatecrypto.php
app/CryptoListing.php
app/Http/Controllers/Controller.php
app/Providers/DynamicClassProvider.php
resources/views/crypto.blade.php
resources/views/currency.blade.php
vendor/composer/autoload_classmap.php
vendor/composer/autoload_static.php
app/Console/Commands/updatecrypto.php
View file @
7fadc840
...
...
@@ -12,7 +12,7 @@ class updatecrypto extends Command
*
* @var string
*/
protected
$signature
=
'up
date
:crypto'
;
protected
$signature
=
'up:crypto'
;
/**
* The console command description.
...
...
@@ -47,7 +47,7 @@ class updatecrypto extends Command
$res
=
$client
->
request
(
'GET'
,
'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest'
,
[
'query'
=>
[
'limit'
=>
'
100
'
,
'limit'
=>
'
39
'
,
'convert'
=>
'EUR'
],
'Filter'
=>
[
'data'
]
...
...
This diff is collapsed.
Click to expand it.
app/CryptoListing.php
0 → 100644
View file @
7fadc840
<?php
namespace
App
;
use
Illuminate\Database\Eloquent\Model
;
class
CryptoListing
extends
Model
{
protected
$table
=
'crypto'
;
}
This diff is collapsed.
Click to expand it.
app/Http/Controllers/Controller.php
View file @
7fadc840
...
...
@@ -15,7 +15,7 @@ class Controller extends BaseController
class
CryptoController
extends
Controller
{
public
function
convert
(
$convertFrom
,
$convertFromValue
,
$convertTo
)
public
static
function
convert
(
$convertFrom
,
$convertFromValue
,
$convertTo
)
{
$dbCryptoTable
=
'crypto'
;
$convertFromRate
=
DB
::
table
(
$dbCryptoTable
)
->
where
(
'symbol'
,
$convertFrom
)
->
value
(
'rate'
);
...
...
This diff is collapsed.
Click to expand it.
app/Providers/DynamicClassProvider.php
View file @
7fadc840
...
...
@@ -2,6 +2,7 @@
namespace
App\Providers
;
use
App\CurrencyListing
;
use
App\CryptoListing
;
use
Illuminate\Support\ServiceProvider
;
class
DynamicClassProvider
extends
ServiceProvider
...
...
@@ -10,10 +11,20 @@
{
view
()
->
composer
(
'*'
,
function
(
$view
){
$view
->
with
(
'currencies'
,
CurrencyListing
::
all
());
$view
->
with
(
'currencies'
,
CurrencyListing
::
all
());
});
view
()
->
composer
(
'*'
,
function
(
$view
){
$view
->
with
(
'cryptos'
,
CryptoListing
::
all
());
});
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
resources/views/crypto.blade.php
View file @
7fadc840
...
...
@@ -6,36 +6,42 @@
<label for="
FormControlSelect1
">Convert From</label>
<div class="
input
-
group
">
<br>
<select class="
form
-
control
" id="
FormControlSelect1
">
<option>BTC</option>
<option>ETH</option>
<option>XRP</option>
<option>ADA</option>
<option>LTC</option>
<option>DASH</option>
<option>USDT</option>
<form action="
/
crypto
" method="
GET
">
<input type="
number
" step="
0.01
" min="
0
" id="
Amount
" name="
Amount
" class="
form
-
control
form
-
control
-
lg
mx
-
3
" value="">
<select class="
form
-
control
" id="
From
" name="
From
">
@foreach (
$cryptos
as
$item
)
<option class="
color
" value="
{{
$item
->
symbol
}}
">{{
$item->name
}} - {{
$item->symbol
}}</option>
@endforeach
</select>
</div>
<input type="
number
" class="
form
-
control
form
-
control
-
lg
mx
-
3
" value="">
<label for="
FormControlSelect1
">To</label>
<div class="
input
-
group
">
<br> <br>
<select class="
form
-
control
" id="
FormControlSelect1
">
<option>BTC</option>
<option>ETH</option>
<option>XRP</option>
<option>ADA</option>
<option>LTC</option>
<option>DASH</option>
<option>USDT</option>
<select class="
form
-
control
" id="
To
" name="
To
">
@foreach (
$cryptos
as
$item
)
<option class="
color
" value="
{{
$item
->
symbol
}}
">{{
$item->name
}} - {{
$item->symbol
}}</option>
@endforeach
</select>
</div>
<input type="
number
" class="
form
-
control
form
-
control
-
lg
mx
-
3
" value="">
<br> <br>
<div class="
btn
">
<span id="
result
" value=""></span>
<br> <br>
<button class="
btn
btn
--
pill
" type="
submit
">Convert!</button>
</form>
<?php
if( isset(
$_GET["From"]
) && isset(
$_GET["Amount"]
) && isset(
$_GET["To"]
))
{
if (!empty(
$_GET["From"]
) && !empty(
$_GET["Amount"]
) && !empty(
$_GET["To"]
)) {
$rez
= \App\Http\Controllers\CryptoController::convert(
$_GET["From"],$_GET["Amount"],$_GET["To"]
);
if (
$rez
== null) {
//Something went wrong and function wasnt run
echo "
Something
went
wrong
!
";
}
echo
$rez
;
}
}
?>
</div>
</div>
</div>
@include('footer')
@endsection
\ No newline at end of file
This diff is collapsed.
Click to expand it.
resources/views/currency.blade.php
View file @
7fadc840
...
...
@@ -7,13 +7,15 @@
<div class="
input
-
group
">
<br>
<form action="
/
currency
" method="
GET
">
<input type="
number
" id="
Amount
" name="
Amount
" class="
form
-
control
form
-
control
-
lg
mx
-
3
" value="">
<input type="
number
"
step="
0.01
" min="
0
"
id="
Amount
" name="
Amount
" class="
form
-
control
form
-
control
-
lg
mx
-
3
" value="">
<select class="
form
-
control
" id="
From
" name="
From
">
@foreach (
$currencies
as
$item
)
<option class="
color
" value="
{{
$item
->
iso
}}
">{{
$item->name
}} - {{
$item->iso
}}</option>
@endforeach
</select>
<br> <br>
<br>
<input type="
button
" id="
go
" onclick="
swapValues
()
" value="
Swap
">
<br>
<select class="
form
-
control
" id="
To
" name="
To
">
@foreach (
$currencies
as
$item
)
<option class="
color
" value="
{{
$item
->
iso
}}
">{{
$item->name
}} - {{
$item->iso
}}</option>
...
...
@@ -25,46 +27,32 @@
<button class="
btn
btn
--
pill
" type="
submit
">Convert!</button>
</form>
<?php
if( isset(
$_GET["Amount
"]
))
if( isset(
$_GET["From
"]
))
{
$value
=
$_GET['Amount']
;
$one
=
$_GET['From']
;
$two
=
$_GET['To']
;
//
$From
= DB::table('currency')->where('iso',
$_GET['From']
)->pluck('rates');
//
$From
= DB::select('Select rates from currency')->where('iso', '=', "
{
$one
}
")->get();
$users
= (DB::table('currency')->select('rates')->where('iso', '=',
$one
)->get())->pluck('rates');
$From
=
$users
[0]
;
$arrFrom
= (DB::table('currency')->select('rates')->where('iso', '=',
$_GET['From']
)->get())->pluck('rates');
$From
=
$arrFrom
[0]
;
$renat
= (DB::table('currency')->select('rates')->where('iso', '=',
$two
)->get())->pluck('rates');
$To
=
$renat[0]
;
//
$from
= DB::table('currency')
//->select(DB::raw('count(*) as user_count, status'))
// ->where('status', '<>', 1)
// ->groupBy('status')
// ->get();
$arrTo
= (DB::table('currency')->select('rates')->where('iso', '=',
$_GET['To']
)->get())->pluck('rates');
$To
=
$arrTo[0]
;
//
$To
= DB::table('currency')->where('iso',
$_GET['To']
)->pluck('rates');
#
$To
= DB::select('Select rates from currency')->where('iso', '=', "
%
{
$two
}
%
")->get();
$rez
= (
$value
/
$From
) *
$To
;
echo
$rez
;
echo '<br>';
echo
$value
;
echo
$From
;
echo '<br>';
echo
$To
;
}
else{
echo 'Enter value';
}
?>
?>
</div>
</div>
</div>
<script>
function swapValues(){
var tmp = document.getElementById("
From
").value;
document.getElementById("
From
").value = document.getElementById("
To
").value;
document.getElementById("
To
").value = tmp;
}
</script>
...
...
This diff is collapsed.
Click to expand it.
vendor/composer/autoload_classmap.php
View file @
7fadc840
...
...
@@ -9,6 +9,7 @@ return array(
'App\\Admin'
=>
$baseDir
.
'/app/Admin.php'
,
'App\\Console\\Commands\\updatecrypto'
=>
$baseDir
.
'/app/Console/Commands/updatecrypto.php'
,
'App\\Console\\Kernel'
=>
$baseDir
.
'/app/Console/Kernel.php'
,
'App\\CryptoListing'
=>
$baseDir
.
'/app/CryptoListing.php'
,
'App\\CurrencyListing'
=>
$baseDir
.
'/app/CurrencyListing.php'
,
'App\\Exceptions\\Handler'
=>
$baseDir
.
'/app/Exceptions/Handler.php'
,
'App\\Http\\Controllers\\Auth\\ForgotPasswordController'
=>
$baseDir
.
'/app/Http/Controllers/Auth/ForgotPasswordController.php'
,
...
...
This diff is collapsed.
Click to expand it.
vendor/composer/autoload_static.php
View file @
7fadc840
...
...
@@ -415,6 +415,7 @@ class ComposerStaticInitaaf7a2d0aa0540e4f74d52dc30d67caa
'App\\Admin'
=>
__DIR__
.
'/../..'
.
'/app/Admin.php'
,
'App\\Console\\Commands\\updatecrypto'
=>
__DIR__
.
'/../..'
.
'/app/Console/Commands/updatecrypto.php'
,
'App\\Console\\Kernel'
=>
__DIR__
.
'/../..'
.
'/app/Console/Kernel.php'
,
'App\\CryptoListing'
=>
__DIR__
.
'/../..'
.
'/app/CryptoListing.php'
,
'App\\CurrencyListing'
=>
__DIR__
.
'/../..'
.
'/app/CurrencyListing.php'
,
'App\\Exceptions\\Handler'
=>
__DIR__
.
'/../..'
.
'/app/Exceptions/Handler.php'
,
'App\\Http\\Controllers\\Auth\\ForgotPasswordController'
=>
__DIR__
.
'/../..'
.
'/app/Http/Controllers/Auth/ForgotPasswordController.php'
,
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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