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
May 04, 2019
by
Florian Shllaku
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypto front end and swap button done
parent
bda474aa
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
91 additions
and
73 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
...
@@ -12,7 +12,7 @@ class updatecrypto extends Command
*
*
* @var string
* @var string
*/
*/
protected
$signature
=
'up
date
:crypto'
;
protected
$signature
=
'up:crypto'
;
/**
/**
* The console command description.
* The console command description.
...
@@ -47,7 +47,7 @@ class updatecrypto extends Command
...
@@ -47,7 +47,7 @@ class updatecrypto extends Command
$res
=
$client
->
request
(
'GET'
,
'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest'
,
[
$res
=
$client
->
request
(
'GET'
,
'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest'
,
[
'query'
=>
[
'query'
=>
[
'limit'
=>
'
100
'
,
'limit'
=>
'
39
'
,
'convert'
=>
'EUR'
'convert'
=>
'EUR'
],
],
'Filter'
=>
[
'data'
]
'Filter'
=>
[
'data'
]
...
...
app/CryptoListing.php
0 → 100644
View file @
7fadc840
<?php
namespace
App
;
use
Illuminate\Database\Eloquent\Model
;
class
CryptoListing
extends
Model
{
protected
$table
=
'crypto'
;
}
app/Http/Controllers/Controller.php
View file @
7fadc840
...
@@ -15,7 +15,7 @@ class Controller extends BaseController
...
@@ -15,7 +15,7 @@ class Controller extends BaseController
class
CryptoController
extends
Controller
class
CryptoController
extends
Controller
{
{
public
function
convert
(
$convertFrom
,
$convertFromValue
,
$convertTo
)
public
static
function
convert
(
$convertFrom
,
$convertFromValue
,
$convertTo
)
{
{
$dbCryptoTable
=
'crypto'
;
$dbCryptoTable
=
'crypto'
;
$convertFromRate
=
DB
::
table
(
$dbCryptoTable
)
->
where
(
'symbol'
,
$convertFrom
)
->
value
(
'rate'
);
$convertFromRate
=
DB
::
table
(
$dbCryptoTable
)
->
where
(
'symbol'
,
$convertFrom
)
->
value
(
'rate'
);
...
...
app/Providers/DynamicClassProvider.php
View file @
7fadc840
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
App\Providers
;
namespace
App\Providers
;
use
App\CurrencyListing
;
use
App\CurrencyListing
;
use
App\CryptoListing
;
use
Illuminate\Support\ServiceProvider
;
use
Illuminate\Support\ServiceProvider
;
class
DynamicClassProvider
extends
ServiceProvider
class
DynamicClassProvider
extends
ServiceProvider
...
@@ -10,10 +11,20 @@
...
@@ -10,10 +11,20 @@
{
{
view
()
->
composer
(
'*'
,
function
(
$view
){
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
\ No newline at end of file
resources/views/crypto.blade.php
View file @
7fadc840
...
@@ -6,36 +6,42 @@
...
@@ -6,36 +6,42 @@
<label for="
FormControlSelect1
">Convert From</label>
<label for="
FormControlSelect1
">Convert From</label>
<div class="
input
-
group
">
<div class="
input
-
group
">
<br>
<br>
<select class="
form
-
control
" id="
FormControlSelect1
">
<form action="
/
crypto
" method="
GET
">
<option>BTC</option>
<input type="
number
" step="
0.01
" min="
0
" id="
Amount
" name="
Amount
" class="
form
-
control
form
-
control
-
lg
mx
-
3
" value="">
<option>ETH</option>
<select class="
form
-
control
" id="
From
" name="
From
">
<option>XRP</option>
@foreach (
$cryptos
as
$item
)
<option>ADA</option>
<option class="
color
" value="
{{
$item
->
symbol
}}
">{{
$item->name
}} - {{
$item->symbol
}}</option>
<option>LTC</option>
@endforeach
<option>DASH</option>
</select>
<option>USDT</option>
<br> <br>
</select>
<select class="
form
-
control
" id="
To
" name="
To
">
</div>
@foreach (
$cryptos
as
$item
)
<input type="
number
" class="
form
-
control
form
-
control
-
lg
mx
-
3
" value="">
<option class="
color
" value="
{{
$item
->
symbol
}}
">{{
$item->name
}} - {{
$item->symbol
}}</option>
<label for="
FormControlSelect1
">To</label>
@endforeach
<div class="
input
-
group
">
</select>
<br> <br>
<br> <br>
<select class="
form
-
control
" id="
FormControlSelect1
">
<span id="
result
" value=""></span>
<option>BTC</option>
<br> <br>
<option>ETH</option>
<button class="
btn
btn
--
pill
" type="
submit
">Convert!</button>
<option>XRP</option>
</form>
<option>ADA</option>
<?php
<option>LTC</option>
if( isset(
$_GET["From"]
) && isset(
$_GET["Amount"]
) && isset(
$_GET["To"]
))
<option>DASH</option>
{
<option>USDT</option>
</select>
if (!empty(
$_GET["From"]
) && !empty(
$_GET["Amount"]
) && !empty(
$_GET["To"]
)) {
</div>
$rez
= \App\Http\Controllers\CryptoController::convert(
$_GET["From"],$_GET["Amount"],$_GET["To"]
);
<input type="
number
" class="
form
-
control
form
-
control
-
lg
mx
-
3
" value="">
if (
$rez
== null) {
<br> <br>
//Something went wrong and function wasnt run
<div class="
btn
">
echo "
Something
went
wrong
!
";
<button class="
btn
btn
--
pill
" type="
submit
">Convert!</button>
}
</div>
echo
$rez
;
}
}
?>
</div>
</div>
</div>
</div>
@include('footer')
@include('footer')
@endsection
@endsection
\ No newline at end of file
resources/views/currency.blade.php
View file @
7fadc840
...
@@ -7,13 +7,15 @@
...
@@ -7,13 +7,15 @@
<div class="
input
-
group
">
<div class="
input
-
group
">
<br>
<br>
<form action="
/
currency
" method="
GET
">
<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
">
<select class="
form
-
control
" id="
From
" name="
From
">
@foreach (
$currencies
as
$item
)
@foreach (
$currencies
as
$item
)
<option class="
color
" value="
{{
$item
->
iso
}}
">{{
$item->name
}} - {{
$item->iso
}}</option>
<option class="
color
" value="
{{
$item
->
iso
}}
">{{
$item->name
}} - {{
$item->iso
}}</option>
@endforeach
@endforeach
</select>
</select>
<br> <br>
<br>
<input type="
button
" id="
go
" onclick="
swapValues
()
" value="
Swap
">
<br>
<select class="
form
-
control
" id="
To
" name="
To
">
<select class="
form
-
control
" id="
To
" name="
To
">
@foreach (
$currencies
as
$item
)
@foreach (
$currencies
as
$item
)
<option class="
color
" value="
{{
$item
->
iso
}}
">{{
$item->name
}} - {{
$item->iso
}}</option>
<option class="
color
" value="
{{
$item
->
iso
}}
">{{
$item->name
}} - {{
$item->iso
}}</option>
...
@@ -25,46 +27,32 @@
...
@@ -25,46 +27,32 @@
<button class="
btn
btn
--
pill
" type="
submit
">Convert!</button>
<button class="
btn
btn
--
pill
" type="
submit
">Convert!</button>
</form>
</form>
<?php
<?php
if( isset(
$_GET["Amount"]
))
if( isset(
$_GET["From"]
))
{
{
$value
=
$_GET['Amount']
;
$value
=
$_GET['Amount']
;
$one
=
$_GET['From']
;
$two
=
$_GET['To']
;
$arrFrom
= (DB::table('currency')->select('rates')->where('iso', '=',
$_GET['From']
)->get())->pluck('rates');
//
$From
= DB::table('currency')->where('iso',
$_GET['From']
)->pluck('rates');
$From
=
$arrFrom[0]
;
$arrTo
= (DB::table('currency')->select('rates')->where('iso', '=',
$_GET['To']
)->get())->pluck('rates');
//
$From
= DB::select('Select rates from currency')->where('iso', '=', "
{
$one
}
")->get();
$To
=
$arrTo[0]
;
$users
= (DB::table('currency')->select('rates')->where('iso', '=',
$one
)->get())->pluck('rates');
$rez
= (
$value
/
$From
) *
$To
;
$From
=
$users[0]
;
echo
$rez
;
}
$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();
//
$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>
</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>
...
...
vendor/composer/autoload_classmap.php
View file @
7fadc840
...
@@ -9,6 +9,7 @@ return array(
...
@@ -9,6 +9,7 @@ return array(
'App\\Admin'
=>
$baseDir
.
'/app/Admin.php'
,
'App\\Admin'
=>
$baseDir
.
'/app/Admin.php'
,
'App\\Console\\Commands\\updatecrypto'
=>
$baseDir
.
'/app/Console/Commands/updatecrypto.php'
,
'App\\Console\\Commands\\updatecrypto'
=>
$baseDir
.
'/app/Console/Commands/updatecrypto.php'
,
'App\\Console\\Kernel'
=>
$baseDir
.
'/app/Console/Kernel.php'
,
'App\\Console\\Kernel'
=>
$baseDir
.
'/app/Console/Kernel.php'
,
'App\\CryptoListing'
=>
$baseDir
.
'/app/CryptoListing.php'
,
'App\\CurrencyListing'
=>
$baseDir
.
'/app/CurrencyListing.php'
,
'App\\CurrencyListing'
=>
$baseDir
.
'/app/CurrencyListing.php'
,
'App\\Exceptions\\Handler'
=>
$baseDir
.
'/app/Exceptions/Handler.php'
,
'App\\Exceptions\\Handler'
=>
$baseDir
.
'/app/Exceptions/Handler.php'
,
'App\\Http\\Controllers\\Auth\\ForgotPasswordController'
=>
$baseDir
.
'/app/Http/Controllers/Auth/ForgotPasswordController.php'
,
'App\\Http\\Controllers\\Auth\\ForgotPasswordController'
=>
$baseDir
.
'/app/Http/Controllers/Auth/ForgotPasswordController.php'
,
...
...
vendor/composer/autoload_static.php
View file @
7fadc840
...
@@ -415,6 +415,7 @@ class ComposerStaticInitaaf7a2d0aa0540e4f74d52dc30d67caa
...
@@ -415,6 +415,7 @@ class ComposerStaticInitaaf7a2d0aa0540e4f74d52dc30d67caa
'App\\Admin'
=>
__DIR__
.
'/../..'
.
'/app/Admin.php'
,
'App\\Admin'
=>
__DIR__
.
'/../..'
.
'/app/Admin.php'
,
'App\\Console\\Commands\\updatecrypto'
=>
__DIR__
.
'/../..'
.
'/app/Console/Commands/updatecrypto.php'
,
'App\\Console\\Commands\\updatecrypto'
=>
__DIR__
.
'/../..'
.
'/app/Console/Commands/updatecrypto.php'
,
'App\\Console\\Kernel'
=>
__DIR__
.
'/../..'
.
'/app/Console/Kernel.php'
,
'App\\Console\\Kernel'
=>
__DIR__
.
'/../..'
.
'/app/Console/Kernel.php'
,
'App\\CryptoListing'
=>
__DIR__
.
'/../..'
.
'/app/CryptoListing.php'
,
'App\\CurrencyListing'
=>
__DIR__
.
'/../..'
.
'/app/CurrencyListing.php'
,
'App\\CurrencyListing'
=>
__DIR__
.
'/../..'
.
'/app/CurrencyListing.php'
,
'App\\Exceptions\\Handler'
=>
__DIR__
.
'/../..'
.
'/app/Exceptions/Handler.php'
,
'App\\Exceptions\\Handler'
=>
__DIR__
.
'/../..'
.
'/app/Exceptions/Handler.php'
,
'App\\Http\\Controllers\\Auth\\ForgotPasswordController'
=>
__DIR__
.
'/../..'
.
'/app/Http/Controllers/Auth/ForgotPasswordController.php'
,
'App\\Http\\Controllers\\Auth\\ForgotPasswordController'
=>
__DIR__
.
'/../..'
.
'/app/Http/Controllers/Auth/ForgotPasswordController.php'
,
...
...
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