AquinoBR

AquinoBR

Member Since 8 Months Ago

Experience Points 1,150
Experience
Level
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

04 May
7 months ago

AquinoBR left a reply on Send Email To Multiple Users

Thanks, I'll do it this way.

AquinoBR started a new conversation Send Email To Multiple Users

I'm having trouble sending my marketing emails through a Company and then I want to send directly through Laravel. Is there a way to send a message to multiple users?

03 May
7 months ago

AquinoBR left a reply on Laravel 5.6 Ajax Call 419 (unknown Status)

Thanks for the tip, do you think I'd better leave without or with www?

AquinoBR left a reply on Laravel 5.6 Ajax Call 419 (unknown Status)

Thank you @Cronix, your answer solved my problem.

url: '/ ico / like'

I used it like this and now it works for www. and also without. Thank you!!!

AquinoBR left a reply on Laravel 5.6 Ajax Call 419 (unknown Status)

I think I had an idea, the page https://icogreen.site/ico/like does not exist it is a POST method. Can I add the header to it?

So I think it solves the problem by passing the token over the page

AquinoBR left a reply on Laravel 5.6 Ajax Call 419 (unknown Status)

Yes! I have this on the page you can test by clicking 'thumbs up' on that link https://www.icogreen.site/ico/RIPT

AquinoBR started a new conversation Laravel 5.6 Ajax Call 419 (unknown Status)

Hello, I am making a call via Ajax to post a function. But it is returning error 419 and I already tried some tutorials on the internet and they did not solve. Yesterday was working and today stopped. Any solution?

<form id="formLike">
                                    @csrf
                                    <input type="hidden" name="symbol_like" value="{{ $icoJson->symbol }}">
                                    <input type="hidden" name="id_like" value="{{ $icoJson->id }}">
                    <input type="hidden" name="ip_like" value="@php echo $_SERVER['REMOTE_ADDR']; @endphp">
                                    <button type="submit" class="btn btn-success" style="font-size: 14px; margin-right: -20px;"> <i class="fas fa-thumbs-up"></i> {{ $icoJson->like }} </button>
                                </form>

Route

$this->post('ico/like', '[email protected]')->name('like');

Controller

public function like(Request $request)
    {
        $like = new Like();
        $response = $like->create($request->all());

        if ($response['success']){
            return response()->json(['success' => $response['message']]);

        } else {
            return response()->json(['error' => $response['message']]);
        }
    }

Model

public function create($response) : Array
    {
        DB::beginTransaction();

        $ip = \Request::ip();
        $like = Like::where('symbol', $response['symbol_like'])->where('ip', $ip)->count();
        $dislike = \App\Models\Dislike::where('symbol', $response['symbol_like'])->where('ip', $ip)->count();

        if($like == null && $dislike == null){
            $ico = \App\Models\Ico::find($response['id_like']);
            $confirm = $ico->likes()->create([
                'ico_id'    => $response['id_like'],
                'symbol'    => $response['symbol_like'],
                'ip'        => $ip,
            ]);

            $ico->like += 1;
            $saveLike = $ico->save();

            if ($confirm && $saveLike) {
                DB::commit();
                return [
                    'success' => true,
                    'message' => 'Vote computed!'
                ];

            } else {
                DB::rollback();
                return [
                    'success' => false,
                    'message' => 'Failed to compute vote!'
                ];
            }

        } else { 
            return [
                'success' => false,
                'message' => 'You have already voted!'
            ];
        }               
    }

Javascript

$('#formLike').submit(function( event ) {
    event.preventDefault();
    $.ajax({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        },
        url: 'https://icogreen.site/ico/like',
        type: 'post',
        data: $('#formLike').serialize(),
        cache: false,
        processData: false,
        timeout: 8000,
        dataType: 'json',
        success: function( _response ){

            if(_response.success != null){
                var message = '<div class="col-sm-12"><div class="alert  alert-success alert-dismissible"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> '+ _response.success +' </div></div>';
                $('#Rating').html(message);
                $('#formLike').trigger('reset');
            }else{
                var message = '<div class="col-sm-12"><div class="alert  alert-danger alert-dismissible"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> '+ _response.error +' </div></div>';
                $('#Rating').html(message);
                $('#formLike').trigger('reset');
            }

        },
        error: function( _response ){
            var message = '<div class="col-sm-12"><div class="alert  alert-danger alert-dismissible"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> '+ _response.error +' </div></div>';
            $('#Rating').html(message);
        }
    });
});
29 Apr
7 months ago

AquinoBR left a reply on Return Success Message

@Vilfago Thank you! Resolved.

AquinoBR left a reply on Return Success Message

One last thing, if you can help. I have seen that now the message is not disappearing after refreshing the page.

AquinoBR left a reply on Return Success Message

Thank you my friends for your attention and patience. I found the problem, it was in the alert css.

@bobbybouwmann It worked out right now I checked your code and removing the css appeared.

Thank you all!

AquinoBR left a reply on Return Success Message

@Snapey

_token WNGfHJBUdT1brdYd18ou4OIM8q3gq2VXaCaVXS2M

_previous array:1 [ "url" => "http://localhost:8080/icogreen/public/ico/IGC" ]

_flash array:2 [ "old" => array:1 [ 0 => "success" ] "new" => [] ]

success Your message has been sent successfully!

Print http://prntscr.com/jbj5qe

Now I'm returning to mesangem, the problem is in the alert display

AquinoBR left a reply on Return Success Message

@bobbybouwmann

I added {,} ... yes everything is working the message is being sent successfully and returns to page. Only the success or error message does not appear.

AquinoBR left a reply on Return Success Message

@rin4ik You have not returned any messages. One note is that the user is not logged in.

AquinoBR started a new conversation Return Success Message

I have a form on the site and after sending the message I want to present a message of success or failure. But the message is not coming back.

condition in function


if ($mail)
            return redirect()
                        ->back()
                        ->with('success', 'Your message has been sent successfully!');

            return redirect()
                        ->back()
                        ->withInput()
                        ->with('error', 'There was a failure while sending the message!');

alert include

@if ($errors->any())
    <div class="col-sm-12">
        <div class="alert  alert-warning alert-dismissible fade show" role="alert">
            @foreach ($errors->all() as $error)
                <span><p>{{ $error }}</p></span>
            @endforeach
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
        </div>
    </div>
@endif

@if (session('success'))
    <div class="col-sm-12">
        <div class="alert  alert-success alert-dismissible fade show" role="alert">
            {{ session('success') }}
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
        </div>
    </div>
@endif

@if (session('error'))
    <div class="col-sm-12">
        <div class="alert  alert-danger alert-dismissible fade show" role="alert">
            {{ session('error') }}
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
        </div>
    </div>
@endif
27 Apr
7 months ago

AquinoBR started a new conversation MySQL Latest Search Results

I'm trying to get the last 10 results in descending order of a mysql search. But I do not know how to set the last 10 only

public function index()
    {
        $donates = Donate::where('status', 'Approved')
                                    ->orderBy('id', 'DESC');
                //last 10
        dd($donates);

    }
```
03 Apr
8 months ago

AquinoBR started a new conversation Do 3 Unified Checks

I have a form with 3 input file, but Laravel is giving me this problem: https://laracasts.com/discuss/channels/laravel/failed-to-return-error-message-validatepostsizephp

So I will check before sending the files, the maximum size will be 2000x2000, I got this code and modified, but it is giving error because one passes the other. I want to know how I can unify the 3 checks in just 1.

$("#personal").change(function() { 
  var fr = new FileReader;
  fr.onload = function() {
    var imgPersonal = new Image;
    imgPersonal.onload = function() {
      if (imgPersonal.width > 2000 &&  this.height > 2000) {
        $("#submitDocs").attr("disabled", true); 
      } else {
        $("#submitDocs").removeAttr("disabled");
      }
    };
    imgPersonal.src = fr.result;
  };
  fr.readAsDataURL(this.files[0]);
});

$("#self").change(function() { 
  var fr = new FileReader;
  fr.onload = function() {
    var imgSelf = new Image;
    imgPersonal.onload = function() {
      if (imgSelf.width > 2000 &&  this.height > 2000) {
        $("#submitDocs").attr("disabled", true);
      } else {
          $("#submitDocs").removeAttr("disabled");
        }
      }
    };
    imgSelf.src = fr.result;
  };
  fr.readAsDataURL(this.files[0]);
});

$("#address").change(function() { 
  var fr = new FileReader;
  fr.onload = function() {
    var imgAddress = new Image;
    imgPersonal.onload = function() {
      if (imgAddress.width > 2000 &&  this.height > 2000) {
        $("#submitDocs").attr("disabled", true); 
      } else {
          $("#submitDocs").removeAttr("disabled");
        } 
      }
    };
    imgAddress.src = fr.result;
  };
  fr.readAsDataURL(this.files[0]);
});
31 Mar
8 months ago

AquinoBR started a new conversation Failed To Return Error Message - ValidatePostSize.php

Hi, I'm getting this error when I send a larger image than I accepted on the validator.

Some solution for version 5.6 I saw that in the previous versions many people had this problem.

Illuminate \ Http \ Exceptions \ PostTooLargeException
No message
28 Mar
8 months ago

AquinoBR left a reply on How To Use FirstOrCreate For Unlogged Users

Resolved!


$users = \App\User::get();
                $user = $users->where('addressbtc', $recipientCheck);
                $userId = $user[0]->id;//user id
                $bitcoins = \App\Models\Bitcoin::get();
                $bitcoin = $bitcoins->where('user_id', $userId)->first();
                $userFind = \App\User::find($userId); //resolved...
                $balanceBTC = $userFind->balanceBTC()->firstOrCreate(['user_id' => $userId]);
                //$response = $balanceBTC->depositBTC($amountCheck, $txidCheck, $userId, $bitcoin);

                dd($balanceBTC);

AquinoBR left a reply on How To Use FirstOrCreate For Unlogged Users

This is the real example I am developing.

public function depositBTCCheck(Historic $historics)
    {
        $user = auth()->user();
        $addressbtc = $user->addressbtc;
        $apiKey = config('larablockio.apiKeyBTC');
        $obj = new LaraBlockIo($apiKey);
        $checkdeposit = $obj->getReceivedTransactions();
        $checkdepositItem = collect($checkdeposit->data->txs);
        $checkdepositTotal = $checkdepositItem->count();
        $checkdepositArray = $checkdepositItem->toArray();
            
        for($i=0; $i<$checkdepositTotal;$i++) {
            //datos array
            $txidCheck = $checkdepositArray[$i]->txid;
            $confirmationsCheck = $checkdepositArray[$i]->confirmations;
            $recipientCheck = $checkdepositArray[$i]->amounts_received[0]->recipient;
            $amountCheck = $checkdepositArray[$i]->amounts_received[0]->amount;
            //check txid DB
            $historic = $historics->select('status')->where('status', $txidCheck);
            
            if ($historic == false) {
                
            } else {
                $users = \App\User::get();
                $user = $users->where('addressbtc', $recipientCheck);
                $userId = $user[0]->id;//user id
                $bitcoins = \App\Models\Bitcoin::get();
                $bitcoin = $bitcoins->where('user_id', $userId)->first();

                $balanceBTC = auth()->user()->balanceBTC()->firstOrCreate(['user_id' => $userId]);
                $response = $balanceBTC->depositBTC($amountCheck, $txidCheck, $userId, $bitcoin);

                dd($response);
            }
        }
    }

I'm looking for user_id through other data that comes from an array in constant manipulation.

the $ userId variable takes the id in the user's loop that is being checked and passes through the checker to see if it already has a register or not. My problem is when it comes to verifying this registration. the above example takes the user_id from the array, but creates using the user_id of the logged in user.

AquinoBR left a reply on How To Use FirstOrCreate For Unlogged Users

The above example is working buddy, but it creates for the logged in user. The table only uses the user_id the only field that I should pass value. I did it this way but it went wrong.

$ balanceBTC = auth () -> user () -> balanceBTC () -> firstOrCreate (['user_id' => '2']);

The user logged in has user_id 1, but the problem is that when it creates it it creates in user_id 1 and not in 2 as I want. I think the problem comes from that part. auth () -> user () -> why here get the data of the logged in user and do not want this.

AquinoBR started a new conversation How To Use FirstOrCreate For Unlogged Users

I'm creating an automated check to check out new deposits on my site. However in the example below checking for the logged in user it works.

public function depositBRLCreate (CreateDepositBRLValidation $ request)
    {

        $ balanceBRL = auth () -> user () -> balanceBRL () -> firstOrCreate ([]);
        $ response = $ balanceBRL-> depositBRL ($ request-> all ());

        if ($ response ['success'])
            return redirect ()
                    -> route ('deposit.brl.confirm')
                    -> with ('success', $ response ['message']);

        return redirect ()
                    -> back ()
                    -> with ('error', $ response ['message']);
    }

Here it checks if the logged in user has balance in the table (bitcoin) if it does not exist, it creates a default balance in table 0 with the user's user_id and default id.

However I want to do this check to create firstOrCreate for the user that the data will come by an array. example

Phill user has id 5 and has no balance created in the table. I want to know how to do it on verification if it does not create a balance for it.

AquinoBR left a reply on Code Update For PHP 7

@smagic39

My dear, I am progressing with your tip, Now I stopped in an error that must be something easy, but I can not solve it is this:

In the database has a table called Bitcoin, where it has a model, it has the following columns [id, user_id, name, amount] I am using the commented line in the code below to check if there is any data with the user_id pulling in the array , if it does not exist then create a new record with "firstOrCreate". The problem is not passing the creation of this record to another user without being logged in. How can I do to create the data without being logged in by the user, but what is pulled by the array?

public function depositBTCCheck(Historic $historics)
    {
        $user = auth()->user();
        $addressbtc = $user->addressbtc;
        $apiKey = config('larablockio.apiKeyBTC');
        $obj = new LaraBlockIo($apiKey);
        $checkdeposit = $obj->getReceivedTransactions();
        $checkdepositItem = collect($checkdeposit->data->txs);
        $checkdepositTotal = $checkdepositItem->count();
        $checkdepositArray = $checkdepositItem->toArray();
            
        for($i=0; $i<$checkdepositTotal;$i++) {
            //datos array
            $txidCheck = $checkdepositArray[$i]->txid;
            $confirmationsCheck = $checkdepositArray[$i]->confirmations;
            $recipientCheck = $checkdepositArray[$i]->amounts_received[0]->recipient;
            $amountCheck = $checkdepositArray[$i]->amounts_received[0]->amount;
            //check txid DB
            $historic = $historics->select('status')->where('status', $txidCheck);
            
            if ($historic == false) {
                
            } else {
                $users = \App\User::get();
                $user = $users->where('addressbtc', $recipientCheck);
                $userId = 2;//user id by deposit
                $bitcoins = \App\Models\Bitcoin::get();
                $bitcoin = $bitcoins->where('user_id', $userId)->first();
                $balanceBTC = $bitcoin->balanceBTC()->firstOrCreate([]);//<-error
        //"Call to a member function balanceBTC() on null"
                dd($balanceBTC);
            }
        }
    }

User.php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use App\PasswordSecurity;
use App\Models\Bitcoin;


class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'lname', 'email', 'password', 'image', 'numbercel',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token', 'pin',
    ];

    public function passwordSecurity()
    {
        return $this->hasOne(PasswordSecurity::class);
    }

    public function balanceBTC()
    {
        return $this->hasOne(Bitcoin::class);
    }


27 Mar
8 months ago

AquinoBR left a reply on Code Update For PHP 7

@smagic39 I'll try with your tip.

@biishmar The problem that does not have time to study the entire framework, the project is already in development and I have deadline to finish it. Then I'll take it easy.

AquinoBR started a new conversation Code Update For PHP 7

Some time ago in a system I created, I did a unified deposit check, it just checked if an address made the deposit and then added the balance amount and the history.

Now I'm creating another system, however, using Laravel 5.6 and I'm rewriting some codes, but I do not know how to do all of the caches instead of just 1. I need to know how to do a coding with FOR or FOREACH to check all at once.

Old page.

<?php
require_once 'vlogin.php';
require_once 'config/configDB.php';
require_once 'api/block_io.php';
require_once 'certific.php';
$apiKey = '';
$pin = '';
$version = 2;
$block_io = new BlockIo($apiKey, $pin, $version);

try {
  $addressBtcLabel = $block_io->get_address_by_label(array('label' => $nick));
    $addressDepositBtc = $addressBtcLabel->data->address;

    $checkdeposit = $block_io->get_transactions(array('type' => 'received', 'addresses' => $addressDepositBtc));

    if ($checkdeposit->status = "success" && $checkdeposit->data->txs[0]->confirmations >= 2) {
    //criação de variaveis menores
    $statusCheck = $checkdeposit->status;
    $txidCheck = $checkdeposit->data->txs[0]->txid;
    $confirmationsCheck = $checkdeposit->data->txs[0]->confirmations;
    $recipientCheck = $checkdeposit->data->txs[0]->amounts_received[0]->recipient;
    $amountCheck = $checkdeposit->data->txs[0]->amounts_received[0]->amount;

    // verifica se o txid já existe no banco de dados
    $queryTxid = "SELECT COUNT(txid) as SOMA FROM depositBtc WHERE txid='$txidCheck'";
    $cTxid = mysqli_query($conn, $queryTxid) or die(mysqli_error());
    $consultTxid = mysqli_fetch_assoc($cTxid);
    $txidverific = $consultTxid['SOMA'];

    //atualiza a balança do jogador
    if ($txidverific == 0) {
    $upbalance = $balance + $amountCheck;
    $queryCredit = "UPDATE players SET balance = '$upbalance' WHERE nick = '$nick'";
    $conectCredit = mysqli_query($conn, $queryCredit);

    //cria um deposito no banco de dados
    $today = date('Y-m-d H:i:s');
    $queryDeposit = "INSERT INTO depositBtc (idDeposit, datetoday, txid, amount, status, nick, confirmations, recipient) VALUES ('','$today','$txidCheck','$amountCheck','confirmed','$nick','$confirmationsCheck','$recipientCheck')";
    $conectDeposit = mysqli_query($conn, $queryDeposit);

    //create notificationsModal
    $queryNotifyDeposit = "INSERT INTO notify (id, nick, notify, datetoday) VALUES ('','$nick','Hello ".$nick."! Added ".$amountCheck." LCOIN in your balance.','$today')";
    $conectNotifyDeposit = mysqli_query($conn, $queryNotifyDeposit);

    } else {
    echo "";
    }

    } else {
    echo "";
    }

  } catch (Exception $e) {
    echo "";
  }

The old page looks for a specific array and performs the functions of updating the balance, history and sending notification.

I want to know how I can do to create a loop in the entire array and not in item [0].

{#272 ▼
  +"status": "success"
  +"data": {#274 ▼
    +"network": "DOGETEST"
    +"txs": array:26 [▼
      0 => {#289 ▼
        +"txid": "43183135ae536e339fc82eafed9cde68b6fb89e5475675cc9a62c6539ad41908"
        +"from_green_address": true
        +"time": 1522183284
        +"confirmations": 4
        +"amounts_received": array:1 [▼
          0 => {#284 ▼
            +"recipient": "2N6chEr7VY3qqysPCgftAQzBHj4msXWjEbc"
            +"amount": "4.10000000"
          }
        ]
        +"senders": array:1 [▶]
        +"confidence": 1.0
        +"propagated_by_nodes": null
      }
      1 => {#288 ▶}
      2 => {#283 ▶}
      3 => {#287 ▶}
      4 => {#291 ▶}
      5 => {#293 ▶}
      6 => {#295 ▶}
      7 => {#297 ▶}
      8 => {#299 ▶}
      9 => {#301 ▶}
      10 => {#303 ▶}
      11 => {#305 ▶}
      12 => {#307 ▶}
      13 => {#309 ▶}
      14 => {#311 ▶}
      15 => {#313 ▶}
      16 => {#315 ▶}
      17 => {#317 ▶}
      18 => {#319 ▶}
      19 => {#321 ▶}
      20 => {#323 ▶}
      21 => {#325 ▶}
      22 => {#327 ▶}
      23 => {#329 ▶}
      24 => {#331 ▶}
      25 => {#333 ▶}
    ]
  }
}

I started creating a function in the controller to replace the old page with a function. I started creating and I stopped here.

public function depositBTCCheck()
    {
        $apiKey = config('larablockio.apiKeyBTC');
        $obj = new LaraBlockIo($apiKey);
        $checkdeposit = $obj->getReceivedTransactions();
        dd($checkdeposit);

        //HERE ... I WANT TO KNOW HOW TO DO THE LOOP NO ARRAY $checkdeposit
        foreach ($checkdeposit as &$value) {

            if ($checkdeposit->status = 'success' && $checkdeposit->data->txs[0]->confirmations >= 2){

            }   
        }
    }

AquinoBR started a new conversation Code Update For PHP 7

Some time ago in a system I created, I did a unified deposit check, it just checked if an address made the deposit and then added the balance amount and the history.

Now I'm creating another system, however, using Laravel 5.6 and I'm rewriting some codes, but I do not know how to do all of the caches instead of just 1. I need to know how to do a coding with FOR or FOREACH to check all at once.

Old page.

<?php
require_once 'vlogin.php';
require_once 'config/configDB.php';
require_once 'api/block_io.php';
require_once 'certific.php';
$apiKey = '';
$pin = '';
$version = 2;
$block_io = new BlockIo($apiKey, $pin, $version);

try {
  $addressBtcLabel = $block_io->get_address_by_label(array('label' => $nick));
    $addressDepositBtc = $addressBtcLabel->data->address;

    $checkdeposit = $block_io->get_transactions(array('type' => 'received', 'addresses' => $addressDepositBtc));

    if ($checkdeposit->status = "success" && $checkdeposit->data->txs[0]->confirmations >= 2) {
    //criação de variaveis menores
    $statusCheck = $checkdeposit->status;
    $txidCheck = $checkdeposit->data->txs[0]->txid;
    $confirmationsCheck = $checkdeposit->data->txs[0]->confirmations;
    $recipientCheck = $checkdeposit->data->txs[0]->amounts_received[0]->recipient;
    $amountCheck = $checkdeposit->data->txs[0]->amounts_received[0]->amount;

    // verifica se o txid já existe no banco de dados
    $queryTxid = "SELECT COUNT(txid) as SOMA FROM depositBtc WHERE txid='$txidCheck'";
    $cTxid = mysqli_query($conn, $queryTxid) or die(mysqli_error());
    $consultTxid = mysqli_fetch_assoc($cTxid);
    $txidverific = $consultTxid['SOMA'];

    //atualiza a balança do jogador
    if ($txidverific == 0) {
    $upbalance = $balance + $amountCheck;
    $queryCredit = "UPDATE players SET balance = '$upbalance' WHERE nick = '$nick'";
    $conectCredit = mysqli_query($conn, $queryCredit);

    //cria um deposito no banco de dados
    $today = date('Y-m-d H:i:s');
    $queryDeposit = "INSERT INTO depositBtc (idDeposit, datetoday, txid, amount, status, nick, confirmations, recipient) VALUES ('','$today','$txidCheck','$amountCheck','confirmed','$nick','$confirmationsCheck','$recipientCheck')";
    $conectDeposit = mysqli_query($conn, $queryDeposit);

    //create notificationsModal
    $queryNotifyDeposit = "INSERT INTO notify (id, nick, notify, datetoday) VALUES ('','$nick','Hello ".$nick."! Added ".$amountCheck." LCOIN in your balance.','$today')";
    $conectNotifyDeposit = mysqli_query($conn, $queryNotifyDeposit);

    } else {
    echo "";
    }

    } else {
    echo "";
    }

  } catch (Exception $e) {
    echo "";
  }

The old page looks for a specific array and performs the functions of updating the balance, history and sending notification.

I want to know how I can do to create a loop in the entire array and not in item [0].

{#272 ▼
  +"status": "success"
  +"data": {#274 ▼
    +"network": "DOGETEST"
    +"txs": array:26 [▼
      0 => {#289 ▶}
      1 => {#288 ▶}
      2 => {#283 ▶}
      3 => {#287 ▶}
      4 => {#291 ▶}
      5 => {#293 ▶}
      6 => {#295 ▶}
      7 => {#297 ▶}
      8 => {#299 ▶}
      9 => {#301 ▶}
      10 => {#303 ▶}
      11 => {#305 ▶}
      12 => {#307 ▶}
      13 => {#309 ▶}
      14 => {#311 ▶}
      15 => {#313 ▶}
      16 => {#315 ▶}
      17 => {#317 ▶}
      18 => {#319 ▶}
      19 => {#321 ▶}
      20 => {#323 ▶}
      21 => {#325 ▶}
      22 => {#327 ▶}
      23 => {#329 ▶}
      24 => {#331 ▶}
      25 => {#333 ▶}
    ]
  }
}

I started creating a function in the controller to replace the old page with a function. I started creating and I stopped here.

public function depositBTCCheck()
    {
        $apiKey = config('larablockio.apiKeyBTC');
        $obj = new LaraBlockIo($apiKey);
        $checkdeposit = $obj->getReceivedTransactions();
        dd($checkdeposit);

        //HERE ... I WANT TO KNOW HOW TO DO THE LOOP NO ARRAY $checkdeposit
        foreach ($checkdeposit as &$value) {

            if ($checkdeposit->status = 'success' && $checkdeposit->data->txs[0]->confirmations >= 2){

            }   
        }
    }

AquinoBR left a reply on How To Condition Pagination

@lostdreamer_nl Thank you ! Perfect

26 Mar
8 months ago

AquinoBR started a new conversation How To Condition Pagination

Below is the one page code that lists some data, however I made a condition to only sample one type in that listing, but in the page it counts all the data in the table in mysql. I want to know how the pagination shows only the data for this condition on that page.


@section('content')
<div class="content">
        @include('admin.includes.alerts')
          <div class="row">
            <div class="col-lg-12 col-xlg-12 col-md-12">
              <div class="card">
                  <ul class="nav nav-tabs profile-tab" role="tablist">
                      <li class="nav-item"> <a class="nav-link" href="htrade">Histórico de Troca</a> </li>
                      <li class="nav-item"> <a class="nav-link active" href="hdeposit">Histórico de Depósito</a> </li>
                      <li class="nav-item"> <a class="nav-link" href="hwithdraw">Histórico de Retirada</a> </li>
                  </ul>
                  <div class="tab-content">
                      <div class="tab-pane active" id="hdeposito" role="tabpanel">
                          <div class="card-block">
                            <div class="card">
                              <div class="card-header">
                                <div class="float-left"><h5 class="title">Histórico de Depósito</h5></div>
                                <div class="float-right">
                                  <form action="{{ route('hdeposit.search') }}" method="POST">
                                    {!! csrf_field() !!}
                                    <div class="input-group" style="height: 30px;">
                                      <input type="text" name="id" class="form-control" placeholder="PESQUISA POR ID">
                                      <span class="input-group-addon">
                                        <button type="submit" class="btn btn-primary"><i class="fas fa-search"></i></button>
                                      </span> 
                                      
                                    </div>
                                  </form>
                                </div>
                              </div>
                              <div class="card-body">
                                <div class="table-responsive">
                                  <table class="table table-striped tablefixed">
                                    <thead class="text-primary">
                                      <th><strong>ID</strong></th>
                                      <th><strong>Moeda</strong></th>
                                      <th><strong>Quantidade</strong></th>
                                      <th><strong>Saldo Antes</strong></th>
                                      <th><strong>Saldo Depois</strong></th>
                                      <th><strong>Status</strong></th>
                                      <th><strong>Comprovar</strong></th>
                                      <th><strong>Data</strong></th>
                                    </thead>
                                    <tbody>
                                      @forelse($historics as $historic)
                                        @if ($historic->type != 'I')
                                          @continue
                                        @endif
                                      <tr>
                                        <td>{{ $historic->id }}</td>
                                        <td>{{ $historic->name }}</td>
                                        <td>{{ number_format($historic->amount, 8, '.', ',') }}</td>
                                        <td>{{ number_format($historic->total_before, 8, '.', ',') }}</td>
                                        <td>{{ number_format($historic->total_after, 8, '.', ',') }}</td>
                                        <td>{{ $historic->status }}</td>
                                        <td>
                                          @if ($historic->status == 'Aguardando Depósito')
                                            <a class="btn btn-primary btn-sm" href="{{ route('deposit.brl.confirm') }}">Enviar Comprovante</a>
                                          @else
                                            <div class="text-center">-</div>
                                          @endif
                                        </td>
                                        <td>{{ $historic->date }}</td>
                                      </tr>
                                      @empty
                                      @endforelse
                                    </tbody>
                                  </table>
                                </div>
                                <div class="row">
                                  <div class="col-md-6">
                                <nav aria-label="Page navigation example">
                                  <ul class="pagination justify-content">
                                    <li class="page-item"><a class="page-link" href="#"><i class="fas fa-file-alt"></i></a></li>
                                    <li class="page-item"><a class="page-link" href="#"><i class="fas fa-file-excel"></i></a></li>
                                    <li class="page-item"><a class="page-link" href="#"><i class="fas fa-file-pdf"></i></a></li>
                                    <li class="page-item"><a class="page-link" href="#"><i class="fas fa-copy"></i></a></li>
                                    <li class="page-item"><a class="page-link" href="#"><i class="fas fa-print"></i></a></li>
                                  </ul>
                                </nav>
                                </div>
                                <div class="col-md-6">
                                <nav aria-label="Page navigation example">
                                  <ul class="pagination justify-content-end">
                                    <li>
                                      {!! $historics->links() !!}
                                    </li>
                                  </ul>
                                </nav>
                                </div>
                              </div>
                              </div>
                            </div>
                          </div>
                      </div>
                  </div>
              </div>
            </div>
          </div>
      </div>
@endsection
25 Mar
8 months ago

AquinoBR started a new conversation How To Call An Array Inside Another Array

@component('mail::button', ['url' => ' '])

add {{ $content['url'] }}

@component('mail::button', ['url' => '$content['url']'])
22 Mar
8 months ago

AquinoBR started a new conversation Email Failed To Send

I am having trouble sending email through Laravel, the first time I encountered this problem was while retrieving password. Now I need to send an email to the user and again I stopped at this problem. Any solution?

""" stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:\n error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed """

\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php

20 Mar
8 months ago

AquinoBR left a reply on How To Call Function With Different Constructors?

namespace Blockavel\LaraBlockIo;

class LaraBlockIo
{
    protected $apiKey;

    /**
     * The BlockIo instance
     *
     * @var BlockIo
     */
    protected $blockIo;

    /**
     * Instantiating the BlockIo Class passing the API key, the pin,
     * and the API version. Define your environment variables in the
     * Laravel in the respective .env file
     */
    public function __construct($apiKey)
    {
        $this->apiKey = $apiKey;
        $pin = '123456';
        $version = 2;
        $this->blockIo = new \BlockIo($apiKey, $pin, $version);
    }

I have succeeded, I will pass the api when creating a new class object.

AquinoBR started a new conversation How To Call Function With Different Constructors?

Hello, I'm using a package and I have a class with some functions. But in the class constructor I can only call functions for only one currency. Each currency has a different API Key, but in the constructor it only has 1 call, how do I use the 3 in the same class?

´´´php namespace Blockavel\LaraBlockIo;

class LaraBlockIo {

/**
 * The BlockIo instance
 *
 * @var BlockIo
 */
protected $blockIo;

/**
 * Instantiating the BlockIo Class passing the API key, the pin,
 * and the API version. Define your environment variables in the
 * Laravel in the respective .env file
 */
public function __construct()
{
    $apiKey = 'apiKeyBitcoin';
    $pin = '123456';
    $version = 2;
    $this->blockIo = new \BlockIo($apiKey, $pin, $version);
}

/**
 * BlockIo getter method, returns a BlockIo object.
 *
 * @return BlockIo
 */
public function getBlockIo()
{
    return $this->blockIo;
}

/**
 * Get the balance information associated with a Bitcoin Dogecoin,
 * or Litecoin account.
 *
 * @return object Contains balance information
 */
public function getBalanceInfo()
{
    return $this->blockIo->get_balance();
}

´´´

I want to know how do I add the 2 other ApiKey's from the other currencies in the constructor and how do you call them later.

18 Mar
8 months ago

AquinoBR started a new conversation How To Concatenate Within URL

I need to add a data inside the url how do I call the information inside the url?

´´´hmtl ´´´

17 Mar
8 months ago

AquinoBR left a reply on How To Call Method Inside The Controller?

@All Many thanks to all, thanks to you! God bless you all!

AquinoBR left a reply on How To Call Method Inside The Controller?

@Sergiu17 Thanks!

I think it will work, I'm trying other problems now with: "Failed: Invalid API Key provided for this API version."

But I'll try to review the API settings.

AquinoBR left a reply on How To Call Method Inside The Controller?

@mcangueiro I do not know what to do, I'm trying to create a function to create an address. Could you help me with an example application of this function please?

AquinoBR left a reply on How To Call Method Inside The Controller?

My friends, I made the changes and now I received a new error:

"Non-static method Blockavel \ LaraBlockIo \ LaraBlockIo :: createAddress () should not be called statically"

AquinoBR left a reply on How To Call Method Inside The Controller?

@mcangueiro, file config/app.php

'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        Illuminate\Bus\BusServiceProvider::class,
        Illuminate\Cache\CacheServiceProvider::class,
        Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
        Illuminate\Cookie\CookieServiceProvider::class,
        Illuminate\Database\DatabaseServiceProvider::class,
        Illuminate\Encryption\EncryptionServiceProvider::class,
        Illuminate\Filesystem\FilesystemServiceProvider::class,
        Illuminate\Foundation\Providers\FoundationServiceProvider::class,
        Illuminate\Hashing\HashServiceProvider::class,
        Illuminate\Mail\MailServiceProvider::class,
        Illuminate\Notifications\NotificationServiceProvider::class,
        Illuminate\Pagination\PaginationServiceProvider::class,
        Illuminate\Pipeline\PipelineServiceProvider::class,
        Illuminate\Queue\QueueServiceProvider::class,
        Illuminate\Redis\RedisServiceProvider::class,
        Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
        Illuminate\Session\SessionServiceProvider::class,
        Illuminate\Translation\TranslationServiceProvider::class,
        Illuminate\Validation\ValidationServiceProvider::class,
        Illuminate\View\ViewServiceProvider::class,

        /*
         * Package Service Providers...
         */
        PragmaRX\Google2FALaravel\ServiceProvider::class,

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        // App\Providers\BroadcastServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,
        Blockavel\LaraBlockIo\LaraBlockIoServiceProvider::class,

    ],

'aliases' => [

        'App' => Illuminate\Support\Facades\App::class,
        'Artisan' => Illuminate\Support\Facades\Artisan::class,
        'Auth' => Illuminate\Support\Facades\Auth::class,
        'Blade' => Illuminate\Support\Facades\Blade::class,
        'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
        'Bus' => Illuminate\Support\Facades\Bus::class,
        'Cache' => Illuminate\Support\Facades\Cache::class,
        'Config' => Illuminate\Support\Facades\Config::class,
        'Cookie' => Illuminate\Support\Facades\Cookie::class,
        'Crypt' => Illuminate\Support\Facades\Crypt::class,
        'DB' => Illuminate\Support\Facades\DB::class,
        'Eloquent' => Illuminate\Database\Eloquent\Model::class,
        'Event' => Illuminate\Support\Facades\Event::class,
        'File' => Illuminate\Support\Facades\File::class,
        'Gate' => Illuminate\Support\Facades\Gate::class,
        'Hash' => Illuminate\Support\Facades\Hash::class,
        'Lang' => Illuminate\Support\Facades\Lang::class,
        'Log' => Illuminate\Support\Facades\Log::class,
        'Mail' => Illuminate\Support\Facades\Mail::class,
        'Notification' => Illuminate\Support\Facades\Notification::class,
        'Password' => Illuminate\Support\Facades\Password::class,
        'Queue' => Illuminate\Support\Facades\Queue::class,
        'Redirect' => Illuminate\Support\Facades\Redirect::class,
        'Redis' => Illuminate\Support\Facades\Redis::class,
        'Request' => Illuminate\Support\Facades\Request::class,
        'Response' => Illuminate\Support\Facades\Response::class,
        'Route' => Illuminate\Support\Facades\Route::class,
        'Schema' => Illuminate\Support\Facades\Schema::class,
        'Session' => Illuminate\Support\Facades\Session::class,
        'Storage' => Illuminate\Support\Facades\Storage::class,
        'URL' => Illuminate\Support\Facades\URL::class,
        'Validator' => Illuminate\Support\Facades\Validator::class,
        'View' => Illuminate\Support\Facades\View::class,
        'Google2FA' => PragmaRX\Google2FALaravel\Facade::class,
        'LaraBlockIo' => 'Blockavel\LaraBlockIo\LaraBlockIoFacade',

    ],

AquinoBR left a reply on How To Call Method Inside The Controller?

@mcangueiro Yes I added in config / app.php ...

Blockavel \ LaraBlockIo \ LaraBlockIoServiceProvider :: class, 'LaraBlockIo' => 'Blockavel \ LaraBlockIo \ LaraBlockIoFacade', ...

@ Sergiu17 I added the line in Model BlockIo and the error remains the same.

AquinoBR left a reply on How To Call Method Inside The Controller?

@shez1983

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\BlockIo;


class BalanceController extends Controller
{

    public function depositBTC()
     {
        return view('admin.balance.depositBTC');
        }

     public function depositBTCCreate(Request $request, BlockIo $blockio)
    {
        $user = auth()->user();

        if ($user->addressbtc == null){

             $label = $user->id;
         //create address btc
             $newAddressInfo = $blockio->CreateAdressBtc($label);

              if ($newAddressInfo['success'])
          return redirect()
                            ->route('deposit.brl')
                            ->with('success', $newAddressInfo['message']);

    return redirect()
                          ->back()
                          ->with('error', $newAddressInfo['message']);
          
          } else {
              return redirect()
                    ->back()
                  ->with('error', 'Você já possui um endereço de depósito Bitcoin.');
          } 
  }
}

Model

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class BlockIo extends Model
{
    /**
     * Get the balance information associated with a Bitcoin Dogecoin,
     * or Litecoin account.
     *
    * @return object Contains balance information
    */
   
   public function CreateAddressBtc()
   {
       return LaraBlockIo::createAddress($label); 
   }
}

@Sergiu17 -> Erro: "Class 'App\Models\LaraBlockIo' not found"

AquinoBR started a new conversation How To Call Method Inside The Controller?

Yesterday I made a post asking how to integrate the class of BlockIo in Laravel. I was able to install via composer and do this procedure. But I can not call the external class methods inside my existing controller at all. Could someone show me how to call a method inside the controller? I think the problem is in linking the install class to the controller. Thanks for any reply.

Installed package and tutorial: https://github.com/blockavel/lara-block-io

I did all procedure until Publish Vendor.

16 Mar
8 months ago

AquinoBR left a reply on Integrate File With External Classes

@martinbean Thanks for replying, but in this way I could not implement it, I found a lot of confusion for me.

AquinoBR left a reply on Integrate File With External Classes

@bobbybouwmann

Thanks for the quick response. I've implemented the whole blockavel / lara-block-io configuration, but I'm not able to call the function inside the controller.

I created the model the same as the example, but I can not call the example function: create address in the controller I have already created. Can you help me?

Model

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class BlockIo extends Model { /** * Get the balance information associated with a Bitcoin Dogecoin, * or Litecoin account. * * @return object Contains balance information */

public function CreateAdressBtc()
{
    return LaraBlockIo::createAddress($label); 
}

}

Function in Controller

public function depositBTCCreate(Request $request, BlockIo $blockio) { $user = auth()->user();

    if ($user->addressbtc == null){

        $label = $user->id;
        How to call here? <----

} else

{ }

AquinoBR started a new conversation Integrate File With External Classes

Hello, I'm new to Laravel and I'm developing my first application, I got to the point where I need to integrate an external API to perform functions. This API comes with a file with classes to call functions but I do not know how to integrate those classes into Laravel. I have already tried via providers, creating another class within laravel, via composer and tried with require_once as I used before. None of these ways worked. Any solution?

The file is on this official site and also says to use requice_once, but I do not know how to use it in Laravel: https://block.io/api/simple/php