sirexzib

sirexzib

Member Since 2 Years Ago

Experience Points
1,600
Total
Experience

3,400 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
1
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 1
1,600 XP
Sep
16
1 year ago
Activity icon

Started a new conversation Best Way To Make An "No Registration Required" Authentication System?

I'm currently building a provably fair dice system in Laravel and it is near complete, however when looking at most of these sites they offer what they call "No Registration Required", bsaically what you do is you go to their site, enter a username then it prompts the user to enter a password but he can do so "later", I assume this is to let the user try it out their product without any hassle of registration and such.

Here is an example: https://primedice.com/ https://stake.com/

What would be the best way to do this? My direct thought was to make the email and password field not required, have a prompt when the user first visits site and ask for a username, then create the user and return it to their session.

Is there any other way to do this, is there any available examples on this?

Note: I am using laravels authentication system.

Apr
05
1 year ago
Activity icon

Started a new conversation Package For Extracting URL Meta Data And Outputting Facebook Like Block?

Is there any package available for laravel or JS libraries that can retrieve meta tags and possibly output them as blocks like on facebook?

For example this URL: https://hackernoon.com/million-dollar-trading-mistakes-for-your-entertainment-and-edification-e9bbf9675a8b

To this Preview: https://i.imgur.com/83hKS0h.png

Jan
25
1 year ago
Activity icon

Started a new conversation Any Packages Or Tutorials On How To Build A Facebook Like Status Field With Comments And Replies?

Trying to find the best way to build a status field where users can:

Post statuses Post Comments on Statuses Reply to Comments Like Statuses Embed Images and youtube videos.

Is there any good way to do this, I built something but it is not working as I wish and was looking if there is any packages for something like this or any tutorials.

Jan
05
1 year ago
Activity icon

Started a new conversation Laravel Queues And SQS?

I'm currently building a server architecture with a freelancer and we are looking at setting up SQS for my website to handle queues.

Right now we use beanstalkd on our old Digital Ocean server, though when looking at SQS it seems like it is really basic and doesnt really work as beanstalkd does?

Our jobs on our website handles importing data, so a user could for example click "Import" and it does a lot of requests to different APIs and grabs data and puts them into the database, we have around 1000 users online at all times and there are imports running 24/7.

What is recommended for this? Should I stay with using a local beanstalkd on the EC2 server or should I setup SQS?

Is there anything else I can use?

Dec
08
1 year ago
Activity icon

Started a new conversation Pass Value To Array_first? How Can This Be Achieved?

Hi, I'm trying to pass a value to the array_first function but I can't find how to do so, my goal is to do something like this:

https://i.imgur.com/OSNOXkS.png

      $holding = array_first($array, function ($key, $value, $i) {
          return $key >= $i;
      });

      var_dump($holding);

Is there any easy way to pass it to the array_first function so it can be used to compare the key with a $i value?

Dec
07
1 year ago
Activity icon

Started a new conversation Database On RDS Or Seprate Server?

I need to start scaling vertically because right now MySQL is taking way to much CPU usage on our main server (Where we have everything right now).

We currently use hosting at Digital Ocean, should I move the database to a separate server or setup an amazon RDS server?

Thanks

Nov
26
1 year ago
Activity icon

Started a new conversation Am I Using Cache Correctly When Caching With Redis?

We used to use File and database to store cached things, however recently we switched to Redis but I'm not sure if I'm doing it correctly.

Basically on a page we get the current users investments, it looks like this:

  $p_investments = Cache::remember('p_investments'.Auth::user()->id, 60, function()
  {
    return PoloInvestment::where([['userid', '=', Auth::user()->id], ['amount', '>', '0']])->get();
  });

Whenever the user changes anything with his investments we drop the cache.

Are we doing it correctly?

Because I found out this page: https://laravel.com/docs/5.5/redis#configuration

And it seems completely different, should I be using Redis::get instead?

Thanks.

Nov
21
1 year ago
Activity icon

Started a new conversation Illuminate\Queue\MaxAttemptsExceededException: A Queued Job Has Been Attempted Too Many Times. The Job May Have Previously Timed Out.

Whenever a job failed it puts this in the error logs: Illuminate\Queue\MaxAttemptsExceededException: A queued job has been attempted too many times. The job may have previously timed out.

How do I get it to not do that, this is so annoying.

In the job I have set $tries to 1 and timeout to 0.

And in laravel forge it have set my worker like this: https://i.imgur.com/mmdAUIA.png

So basicially I have set the jobs tries to 1 and then I have set the workers max tries to 1 and still it gives me that fucking error, because it retries when it shouldnt.

How do I fix it?

Nov
20
1 year ago
Activity icon

Replied to How To Scale And Optimize For Huge User Increase?

@martinbean Hey man, thanks for your response, we are caching most queries actually but I assume more can be cached and I will see what I can do. However something I haven't done since I created my laravel forge project is change in the config files? I started the project with a $5 cheapest server on DO (DigitalOcean) and now its a multicore, 16gb ram server at 160$, is there anything I can change in my my.cnf file to optimize better?

Here it is right now:

datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
bind-address = *
#
max_connections         = 300
key_buffer_size         = 256M
read_buffer_size = 1M
table_open_cache = 15000
thread_cache_size = 384
connect_timeout = 10
interactive_timeout = 7000
tmp_table_size = 256M
max_heap_table_size = 256M
query_cache_size = 0
query_cache_type = 0
innodb_buffer_pool_size = 256M
Activity icon

Started a new conversation How To Scale And Optimize For Huge User Increase?

I run a website which currently holds 23000 users, about 60-80 on at all times and peaks around 200, when we go to 100-200 the site gets really slow and it is due to the CPU usage.

Ram is always okay and everything else but CPU spikes to 99-100% on peak time and we are expecting a huge wave of new users coming very soon where we will peak at around 400-500 users and have 200 on at all times.

The reasoning for the high CPU usage is MySQL, it goes up to 122% on the peak hours and this is most likely due to a lot of queries needing to be done at all page refreshes and such.

For example this is the page that most people sit on: https://i.imgur.com/ZIhOHph.png

So I think we really need to rethink our architecture right now to be able to hold this many users.

We are currently paying $160 a month on a VPS from DigitalOcean, the VPS is setup with laravel forge.

Now I've been reading from various places that it is recommended to put the SQL on one server and have the App run on another, connecting to the SQL server.

Would this help us? Would this have some other kind of negative effect on the website?

I also read about load balancers but from what I've read you can't really setup load balancers with Laravel Forge and MySQL since we have NGINX?

Could anyone let me know what we could potentially do to improve the site and to make it hold more users?

Thank you.

Nov
14
1 year ago
Activity icon

Started a new conversation I Wrote Some Import Functions From APIs, Can You Help Me Improve It

I run a large scaled app much larger than I can handle or develop for, website grew out of control and currently has over 22000 users.

We support importing from different APIs, each import is split into 6 functions, I would appreciate if someone could tell me what I could improve in this code to make it more efficient, I am in the middle of doing a lot of optimizations to make it so we don't have to get a more expensive server.

Here are the functions, I have plenty more but I would like to see if its even possible to help me first: Due to the formatting being a pain in the ass here is the pastebins:

Import and Insert Balances & Deposits: https://pastebin.com/vivJ8tke Import and Insert Trades: https://pastebin.com/gh7Wpcp3

´´´public function importDepositsB($userid) { // This get's the API key combination if(Key::where([['userid', '=', $userid], ['exchange', '=', 'Bittrex']])->exists()) { $key = Key::where([['userid', '=', $userid], ['exchange', '=', 'Bittrex']])->first(); } else { event(new PushEvent('No API keys found, please add your Bittrex API keys.', 'error', $userid));

    // This is a cache key which makes sure that not more than 1 import is running at a time
    Cache::forget('Import-Bittrex2'.$userid);
    die("No API keys found, please add your Bittrex API keys.");
  }

  // Decrypt the API keys
  $apikey = decrypt($key->public);
  $apisecret = decrypt($key->private);

  // This gets the data from the API.
  $client = new \GuzzleHttp\Client();
  try{
  $nonce=time();
  $uri='https://bittrex.com/api/v1.1/account/getdeposithistory?apikey='.$apikey.'&nonce='.$nonce;
  $sign=hash_hmac('sha512',$uri,$apisecret);
  $res = $client->request('GET', $uri, [
  'headers' => [
  'apisign' => $sign,
  ]]);
  $response = $res->getBody();
  $deposits = json_decode($response, true);
  if($deposits['success'] == "true")
  {
    // Send a push notification to the user that the import has started
    event(new PushEvent('Your import has started!', 'success', $userid));

    // Loop through the data we received from the API.
  foreach($deposits['result'] as $d)
  {
    $ddate = strtotime($d['LastUpdated']);
    $newformat = date('Y-m-d H:i:s', $ddate);
    $newformat2 = date('Y-m-d', $ddate);

    // This renames the Currency to work properly with updates names and such.
    if($d['Currency'] == "ANS")
    {
      $d['Currency'] = "NEO";
    } elseif($d['Currency'] == "BCC") {
      $d['Currency'] = "BCH";
    } elseif($d['Currency'] == "SEC") {
      $d['Currency'] = "SAFEX";
    }

    // This makes sure that the imported data has not been processed in a previous import.
    if(!Deposit::where('txid', $userid . $d['TxId'])->exists())
    {
      // Get bitcoin price of day:
        $historical = History::getHistorical($newformat);
        $btc_usd = $historical->USD;
        $btc_eur = $historical->USD * Multiplier::where('currency', 'EUR')->select('price')->first()->price;
        $btc_gbp = $historical->USD * Multiplier::where('currency', 'GBP')->select('price')->first()->price;
        $btc_usdt = $historical->USD;
        $btc_eth = $historical->ETH;
        $value = 0;

        // This gets historical prices
        $client = new \GuzzleHttp\Client();
        $res = $client->request('GET', 'https://poloniex.com/public?command=returnChartData&currencyPair=BTC_'.$d['Currency'].'&start='.strtotime($newformat2).'&end='.strtotime($newformat2).'&period=14400');
        $response = $res->getBody();
        $prices = json_decode($response, true);

        if($d['Currency'] != "BTC")
        {
          foreach($prices as $price)
          {
            if(is_array($prices) && isset($price['open']))
            {
              $value = $price['open'];
            } else {
              $value = 0;
            }
          }
        } else {
          $value = 1;
        }



    // Insert the deposit to the database
    $deposit = new Deposit;
    $deposit->userid = $userid;
    $deposit->exchange = "Bittrex";
    $deposit->txid = $userid . $d['TxId'];
    $deposit->date = $newformat;
    $deposit->currency = $d['Currency'];
    $deposit->amount = $d['Amount'];
    $deposit->btc_price_deposit_usd = $btc_usd;
    $deposit->btc_price_deposit_eur = $btc_eur;
    $deposit->btc_price_deposit_gbp = $btc_gbp;
    $deposit->btc_price_deposit_eth = $btc_eth;
    $deposit->btc_price_deposit_usdt = $btc_usdt;
    $deposit->price = $value;
    $deposit->save();

    // This checks if a balance exists, if it doesn't we create a new balance
    if(!Balance::where([['userid', '=', $userid], ['currency', '=', $d['Currency']], ['exchange', '=', 'Bittrex']])->exists())
    {
      $balance = new Balance;
      $balance->exchange = "Bittrex";
      $balance->userid = $userid;
      $balance->currency = $d['Currency'];
      $balance->amount = $d['Amount'];
      $balance->save();
    } else
    {
      $balance = Balance::where([['userid', '=', $userid], ['currency', '=', $d['Currency']], ['exchange', '=', 'Bittrex']])->first();
      $balance->amount += $d['Amount'];
      $balance->save();
    }

    }

  }
  } else {

    // Here is some fallback stuff
    if($deposits['message'] == "APIKEY_INVALID")
    {
      Cache::forget('Import-Bittrex2'.$userid);
      event(new PushEvent('No API keys found or invalid combination.', 'error', $userid));
      abort(403);
    } else {
      Cache::forget('Import-Bittrex2'.$userid);
      event(new PushEvent($deposits['message'], 'error', $userid));
      abort(403);
    }
    }
  } catch(\GuzzleHttp\Exception\RequestException $e){
    event(new PushEvent('No API keys found or invalid combination.', 'error', $userid));
    Cache::forget('Import-Bittrex2'.$userid);
  } catch(\GuzzleHttp\Exception\ClientException $e) {
    event(new PushEvent('No API keys found or invalid combination.', 'error', $userid));
    Cache::forget('Import-Bittrex2'.$userid);
  } catch(\GuzzleHttp\Exception\BadResponseException $e) {
    event(new PushEvent('No API keys found or invalid combination.', 'error', $userid));
    Cache::forget('Import-Bittrex2'.$userid);
  } catch(\GuzzleHttp\Exception\ServerException $e) {
    event(new PushEvent('No API keys found or invalid combination.', 'error', $userid));
    Cache::forget('Import-Bittrex2'.$userid);
  }
}

´´´

´´´public function importTradesB($userid) { // User Variables $user = User::where('id', $userid)->first(); $key = Key::where([['userid', '=', $userid], ['exchange', '=', 'Bittrex']])->first(); $apikey = decrypt($key->public); $apisecret = decrypt($key->private); $client = new \GuzzleHttp\Client(); try{ $nonce=time(); $uri='https://bittrex.com/api/v1.1/account/getorderhistory?apikey='.$apikey.'&nonce='.$nonce; $sign=hash_hmac('sha512',$uri,$apisecret); $res = $client->request('GET', $uri, [ 'headers' => [ 'apisign' => $sign, ]]); $response = $res->getBody(); $trades = json_decode($response, true); } catch (\GuzzleHttp\Exception\ClientException $e) { }

  foreach($trades['result'] as $trade)
  {
    if(!BittrexTrade::where('tradeid', $userid . $trade['OrderUuid'])->exists())
    {
      $currencies = explode("-", $trade['Exchange']);

      $ddate = strtotime($trade['TimeStamp']);
      $newformat = date('Y-m-d H:i:s', $ddate);

      $t = new BittrexTrade;
      $t->userid = $userid;
      $t->tradeid = $userid . $trade['OrderUuid'];
      $t->date = $newformat;
      $t->type = $trade['OrderType'];
      $t->market = $currencies[0];
      if($currencies[1] == "ANS")
      {
        $t->currency = "NEO";
      } elseif($currencies[1] == "BCC") {
        $t->currency = "BCH";
      } elseif($currencies[1] == "SEC")
      {
        $t->currency = "SAFEX";
      }
       else {
        $t->currency = $currencies[1];
      }
      $t->price = $trade['PricePerUnit'];
      $t->amount = $trade['Quantity'] - $trade['QuantityRemaining'];
      $t->fee = $trade['Commission'];
      $t->total = $trade['Price'];
      $t->save();

    }

  }

}

´´´

Thank you very much.

Nov
08
1 year ago
Activity icon

Started a new conversation Laravel-Echo-Server Send Event From Client?

I am building a chat module now for my site and I have completed it except the sending.

So my ideal chat module would work like sending an event from the client to the server which then Laravel listens after and when it gets triggered it will handle the event and distribute out the message to both users and log it in the database.

How do I send an event from the client? And how do I listen for it? I find 0 resources or information on how this is done.

I guess I could send the message using ajax but that kinda ruins the whole socket thing and it isn't really optimal for a website with 20000 users.

Any information on how to do this?

For example my JS code could look something like this:

   $(".msg-input").keypress(function (e) {
        if($(this).val().replace(/^\s+|\s+$|\s+(?=\s)/g, "")!="") {
            if (e.which == 13) {
                if($(this).data("dest")!=""){
                    socket.emit('message', {"to":$(this).data("dest"),"msg":$(".msg-input").val() });
                    $(this).val("");
                }
            }else {
                x++;
                if(x==1) {
                    if ($(this).data("dest") != "") {
                        socket.emit('typing', {"to": $(this).data("dest")});
                        x=0;
                    }
                }
            }
        }
    });

socket.emit('message', {"to":$(this).data("dest"),"msg":$(".msg-input").val() });

The above line should send an event like one I made in laravel, like so: event(new EventName('Message here', 'userid') and then I could handle it in an listener from there.

Got any tips on how to achieve this?

Sep
29
2 years ago
Activity icon

Started a new conversation Laravel Echo Update Prices On Currencies?

Hi, I'm trying to make my application as real time as possible.

To keep this simple, I have 4 blocks on my website which tracks prices of cryptocurrencies, however these doesn't update in real-time, they update once you reload the page.

Now what I would want to do is to make it update every minute using laravel echo.

I currently have laravel echo server running for our notifications on the website which works really well, however I am not sure how to do these type of events.

Basicially I have these 4 blocks: https://i.imgur.com/mats2zo.png

Which are 4 different currencies, every user can select their own currencies and there is about 1500 to choose from.

Now we read in prices from an API every minute already using the kernel console and it updates every record in the database, but what I want is to send an event when the prices updates and update it client side aswell.

So I tried doing it by sending out a event for every currency and it worked out well, however this feels like the wrong way?

Shouldn't I just send out an array of all the prices every minute and then from there update the prices?

How would I do this the best way?

Currently my code looks like this but I'm not sure if im doing it right:

https://i.imgur.com/JaqoDp3.png

https://i.imgur.com/vszFNYY.png

Sep
19
2 years ago
Activity icon

Started a new conversation Should You Have A Second Server For Your API?

I am currently running a website with over 14 thousand users where we have about 8 thousands unique logged in users every week.

We are also in the middle of building an API so people can grab data from us/their accounts.

Now my question is, should you have your API on a second or on the main server? What I mean with this is that we don't want to slow down our main server where the website is running incase the API gets a lot of requests.

Is this something we should do or is it recommended to use something like digital ocean load balancing instead?

Aug
24
2 years ago
Activity icon

Replied to How Would I Allow Two Domains For My Project? One Regular And One Short As A Shortcut

@Cronix Oh, so it's not as simple as setting the short domain as a A record to the server and then do some laravel work to redirect it to the correct url? Even if masked?

I did this:

http://i.imgur.com/LIes15O.png

I'm waiting for DNS to update to see if it works, not sure however. I also added the short domain to the nginx config.

Activity icon

Replied to How Would I Allow Two Domains For My Project? One Regular And One Short As A Shortcut

@Snapey Well I did setup a forwarded but that doesn't let you forward to a url with a username parameter.

for example *.myd.com can only redirect to one mydomain.com/user/NOPARAMETERHERE.

So that isn't really possible.

Activity icon

Started a new conversation How Would I Allow Two Domains For My Project? One Regular And One Short As A Shortcut

Hi, Say I have the domain: www.mydomain.com And users can go to their profiles using www.mydomain.com/user/username

Now I recently got a short version of my domain called www.myd.com I would like it so you can do www.myd.com/username and it would take you to www.mydomain.com/user/username

How would you do that?

Do I need to do anything server sided or is this possible to do with DNS?

I am using laravel forge and digital ocean for my website.

Aug
23
2 years ago
Activity icon

Started a new conversation Laravel Echo Returns "Client Can Not Be Authenticated, Got HTTP Status 500" When Joining Private Channel

Been trying all day to set this up..

Currently I can connect and get events from presence channels without any issues, but when I try to join a private channel it returns me with the error:

Client can not be authenticated, got HTTP status 500

Error ->

http://i.imgur.com/P1yGGe1.png

http://i.imgur.com/EwFTjJX.png

This is my blade template

@extends('layouts.master')

@section('content')
  <ul id="messages"></ul>
  <form action="">
    <input id="m" autocomplete="off" /><button>Send</button>
  </form>
@stop

@section('footer')
<script src="{{ elixir('js/6001-9.js') }}"></script>
<script>
Echo.channel('test-channel')
    .listen(".Notification", (event) => {
    console.log(event);
});
Echo.channel('announcements')
    .listen(".Notification", (event) => {
    console.log(event);
});

Echo.private('App.User.{{Auth::user()->id}}')
    .listen('StatusUpdated', (e) => {
        console.log(e);
    });

</script>
@stop

This is my Channels.php

<?php

/*
|--------------------------------------------------------------------------
| Broadcast Channels
|--------------------------------------------------------------------------
|
| Here you may register all of the event broadcasting channels that your
| application supports. The given channel authorization callbacks are
| used to check if an authenticated user can listen to the channel.
|
*/

Broadcast::channel('App.User.{id}', function ($user, $id) {
    return (int) $user->id === (int) $id;
});
Broadcast::channel('private-App.User.{id}', function ($user, $id) {
    return (int) $user->id === (int) $id;
});

Broadcast::channel('presence-test-channel', function ($user, $id) {
    return true;
});

This is my laravel echo json config

{
    "appKey": "base64:3G5RJ0OYWYu1Bd47FlXgX1kZgzHJl6wkEswK2CWKfd4=",
    "authHost": "https://altpocket.io",
    "authEndpoint": "/broadcasting/auth",
    "clients": [
        {
            "appId": "4b42a4ac276318dc",
            "key": "ddd5816d7fe7ad10c6d9f78dcbacd136"
        }
    ],
    "database": "redis",
    "databaseConfig": {
        "redis": {
            "port": "6379",
            "host": "localhost"
        },
        "sqlite": {
            "databasePath": "/database/laravel-echo-server.sqlite"
        }
    },
    "devMode": true,
    "port": "6001",
    "protocol": "https",
    "socketio": {},
    "sslCertPath": "/etc/nginx/ssl/Altpocket.io/203319/server.crt",
    "sslKeyPath": "/etc/nginx/ssl/Altpocket.io/203319/server.key"
}

And lastly here is my echo.js file before webpack

enter image description here

Appreciate all the help I can get.

Aug
22
2 years ago
Activity icon

Started a new conversation Laravel Forge/Socket.io/Node.JS Client Not Receiving Events But Is Connected

I just finally figured out how to get events sent to the socket.io/redis server and it looks like this:

http://i.imgur.com/BKFA9gg.png

Now that it finally receives events I need them to get sent to the client.

I connected to the socket and I did so it console.logs when someone is connected and it fully works so the client is connected to the socket.io

http://i.imgur.com/QVmI2oK.png

http://i.imgur.com/KaopCxM.png

So I am connected to the socket.io/node js/redis server, however whenever I try to send any event from or to the client it never does anything.

I tried opening my console writing socket.connected and it returns false?

Here is my socket.js file (Server)

http://i.imgur.com/TBQljWO.png

And here is my client file:

<script>
    //var socket = io('http://localhost:3000');
      var socket = io.connect('https://altpocket.io/socket.io/');
      //var socket = io.connect('https://37.139.1.10:3000');

      socket.on("test-channel:Notification", function(message){
          console.log("got the event!");
      });

</script>
Activity icon

Replied to Step By Step Guide To Installing Socket.io And Broadcasting Events With Laravel 5.1

I keep getting this:

ERR_CONNECTION_TIMED_OUT

Activity icon

Replied to Step By Step Guide To Installing Socket.io And Broadcasting Events With Laravel 5.1

Hi, how do u deploy this for a live server? My server is currently live and it just wont work, following exactly what you said.

Activity icon

Started a new conversation Laravel-Ratchet Package, Websocket ERR_CONNECTION_TIMED_OUT

So I've been using Pusher for quite some time but it is really expensive when you get upwards 300 users on at all times.

So I decided to start build my own Ratchet websocket, and I used the package called laravel-ratchet.

However, when I try to connect to it in javascript (This is a live server btw) it gives me "ERR_CONNECTION_TIMED_OUT".

This is my ratchet config: https://pastebin.com/VwQMb6t5

And I connect like this: http://i.imgur.com/OomcGm0.png

I also ran the command php artisan ratchet:serve But nothing works, it doesn't connect for some reason: http://i.imgur.com/d9n34ng.png

Please help!

Aug
18
2 years ago
Activity icon

Replied to Laravel Artisan Commands From Route Times Out

Now I have tried with jobs, artisan commands and just plain code and every single time it stops after a while before it's finished. This is getting really annoying.

Activity icon

Replied to Laravel Artisan Commands From Route Times Out

@JMarcher Sure that would return all users with stats but what about those who don't have it? But then again this is not my problem, my problem is that it's not running properly when running the command from the browser.

Activity icon

Started a new conversation Laravel Artisan Commands From Route Times Out

I've been trying to solve an issue forever, I have a command I need to run but when I execute it from a GET request it times out after like 60 seconds.

So someone told me to make a CLI command or Artisan command and do it that way, and so I did but it did the exact same thing, after 60-75 seconds the page returns 502 bad gateway and the issue remains.

How do I make it so when you go the URL, it submits it to start running and it runs on the server rather than the get request? Cause when I go to the URL for the command, it loads and loads and at the same time the command runs but when the connection closes the command closes aswell.

This is my code:

== Command ==

public function handle()
{
  $users = User::all();

     foreach($users as $user){
         $invested = 0;
         $networth = 0;




         $stats = Stat::where('userid', $user->id)->first();
         $bittrex_trades = 0;
         $polo_trades = 0;

         if($bittrex_trades == 0 && $polo_trades == 0)
         {
           if($stats){
                $stats->legit = $user->getMoney();
                $stats->save();


           } else {
               $stats = new Stat;
               $stats->legit = $user->getMoney();
               $stats->userid = $user->id;
               $stats->currency = $user->currency;
               $stats->save();
           }
       }
     }
}

== Route ==

Route::get('/test1231', function () { $exitCode = Artisan::call('update:profit', ['--queue' => 'default']); });

Aug
16
2 years ago
Activity icon

Started a new conversation How To Add A Subdomain To An Already Existing Site

So I got a site up using laravel forge and digital ocean and Gandi as domain provider. I also have cloudflare installed on the domain.

Now I would like to make an subdomain for it, preferably using the same laravel project as my main domain as so: api.mydomain.com

How would I do this? I didn't enable allow wildcard subdomains when I created it, do I do it somewhere in nginx?

So far I have created an A record on both DO, Cloudflare and Gandi that points to the servers IP.

I have also done this in route:

Route::domain('api.mydomain.com')->group(function () { return "hello"; });

To make it echo "hello" when visited, but I think I have missed something because it's not working.

Thanks.

Aug
15
2 years ago
Activity icon

Started a new conversation Database Construction, How Would You Optimally Do This

Alright, to keep things as Basic as possible.

Let's say I have 5 products and I have 5 providers for each product (Every Provider Sells the product). Now they have all different prices, how would you store the prices in the database for each product?

Eventually the products will have more providers aswell.

And on top of that, when a user browse the site, the user can themselves pick which provider to show prices from.

So I have: [Products/Crypto Currencies] 1x NEO 1x XRP 1x LTC 1x SC 1x XEM

[Providers/Platform]

Poloniex Bittrex Coinbase Bitfinex FifthExample

So basically each of the products has a price on every provider, now Richard comes to my website and registers.

And then he picks to show prices from the CoinBase provider.

Currently we have a table for each provider but that feels not so good.

Thanks!

Activity icon

Replied to Is There Any More Efficient Way To Get From Db If It Exists Than This?

@martinbean While this is much better, lot's of our users choose which one they wish to use, we can't just go on the first price. Though I agree that making one table for it all is much better, since eventually we will most likely have 20 price providers.

Aug
07
2 years ago
Activity icon

Replied to Using Laravel Excel To Import A Csv Document Return Weird Formatting

I solved this now, Turns out it was UCS-2!

Activity icon

Replied to Using Laravel Excel To Import A Csv Document Return Weird Formatting

When I run mb_detect_encoding() it says its ASCII.

However when I open the file in notepad++ (The CSV file) and click convert to UTF-8 it works great to import.

What could be the issue here?

Activity icon

Started a new conversation Using Laravel Excel To Import A Csv Document Return Weird Formatting

Hey again.

I'm trying to write a function to import a bunch of data from a CSV file and then print it into the database.

It seems like the csv document that is generated is weirdly formatted because When I put it into the datbase it looks like this: http://i.imgur.com/KUklnfW.png

Any thoughts on how to solve this? I tried all php function for encoding and decoding and nothing helps.

Aug
05
2 years ago
Activity icon

Started a new conversation How Would You Get Data From An URL Like Meta And Such And Then Render In Blade?

So my website currently has a social feed which is pretty simple and it's not really advanced. What I want to do next is to add a thing when someone posts an url to like youtube, it would show something like this: http://i.imgur.com/KBpPeUu.png

Like lets say someone wants to post a youtube video like so: [youtube]youtubelinkhere[/youtube]

And then it replaces it with whats in the screenshot? I have the layout and design to that specific "Meta Block", I just don't know how to get the data from the URL?

Thanks

Aug
01
2 years ago
Activity icon

Replied to Is There Any More Efficient Way To Get From Db If It Exists Than This?

@36864 Yes thanks! I actually pasted the wrong code in my second reply, this is what I meant:

        $price = Crypto::where('symbol', $currency)->select('price_btc')->first()->price_btc;

        if($price === null)
        {
          $price = Polo::where('symbol', $currency)->select('price_btc')->first()->price_btc;
        }
        if($price === null)
        {
          $price = bittrex::where('symbol', $currency)->select('price_btc')->first()->price_btc;
        }

And regarding the model array, that seems like a nice way, but currently we have 4 models that all contain prices of different "tokens" from different exchanges.

Depending on the $api variable which the user can select themselves it will search for the price in your selected $api and use the rest of the models as fallback.

And for the last part you posted, this is a good idea, so we can store which models a price exists in, I will look into that.

Thank you.

Activity icon

Replied to Is There Any More Efficient Way To Get From Db If It Exists Than This?

Would it be better to do something like this:

        if(Crypto::where('symbol', $currency)->exists())
        {
          $price = Crypto::where('symbol', $currency)->select('price_btc')->first()->price_btc;
        } elseif(Polo::where('symbol', $currency)->exists())
        {
          $price = Polo::where('symbol', $currency)->first()->price_btc;
        } elseif(bittrex::where('symbol', $currency)->exists())
        {
          $price = bittrex::where('symbol', $currency)->first()->price_btc;
        }
Activity icon

Started a new conversation Is There Any More Efficient Way To Get From Db If It Exists Than This?

Currently going through my layout code to hopefully decrease load time and I noticed a lot of queries are being done.

      if($api == "coinmarketcap")
      {
        if(Crypto::where('symbol', $currency)->exists())
        {
          $price = Crypto::where('symbol', $currency)->first()->price_btc;
        } elseif(Polo::where('symbol', $currency)->exists())
        {
          $price = Polo::where('symbol', $currency)->first()->price_btc;
        } elseif(bittrex::where('symbol', $currency)->exists())
        {
          $price = bittrex::where('symbol', $currency)->first()->price_btc;
        }
      }

Is there any other way to do this more efficient? Currently for my "test", it checks if it exist and then gets the price.

However I feel like it would be better to just do request and then take the data from that request.

Thanks.

Jul
31
2 years ago
Activity icon

Replied to Can Anyone Give Me A Tip On What Makes This Page Load Slow

@topvillas Oh.. Well that's fantastic. Perhaps its my PC or internet (At another work station). Thanks, I'd appreciate if someone also could report to me!

Activity icon

Started a new conversation Can Anyone Give Me A Tip On What Makes This Page Load Slow

Thank you all for the help.

Activity icon

Started a new conversation Anyway To Execute This Db Fetch Faster?

Currently I am running a website for tracking investments, a user has any amount between 1-1000+ investments. The investments are spread out in different tables, each table representing an exchange where it was purchased. Currently I grab all investments that are linked to the user and send it to the blade like so:

     $summed = Cache::remember('investments', 60, function()
    {
      $poloniex = PoloInvestment::where([['userid', '=', Auth::user()->id]])->SelectRaw('*, "Poloniex" as exchange, comment as note');
      $bittrex = BittrexInvestment::where([['userid', '=', Auth::user()->id]])->SelectRaw('*, "Bittrex" as exchange, comment as note');
      return ManualInvestment::where([['userid', '=', Auth::user()->id]])->SelectRaw('*, "Manual" as exchange, comment as note')->union($poloniex)->union($bittrex)->get();
    }); 

   return view('coins.investments3', ['btc' => InvestmentController::btcPrice(), 'networth' => Auth::user()->getNetWorthNew(Auth::user()->api), 'minings' => Mining::where('userid', Auth::user()->id)->get(), 'multiplier' => Auth::user()->getMultiplier(), 'p_investments' => $summed,'balances' => Balance::where('userid', Auth::user()->id)->get()]);

Is there any way to do this faster, the load time is currently about 5-6 seconds and thats when I have about 15 investments.

I have more code to be reviewed, I am no professional coder but my website is growing beyond my expertise and I just basically need to get better. I am most likely sure that this isnt what is taking so long time but actually the code calculating the profits in the blade template, but I just thought that this might help me get better if there is any better way to do this.

If anyone wants to help me, feel free to send me a PM, all help is appreciated.

May
21
2 years ago
Activity icon

Started a new conversation Emails Using Mailgun Is Not Getting Sent At All?

I solved it, im stupid.

Apr
20
2 years ago
Activity icon

Started a new conversation Laravel Locale Question

I am currently building an app in laravel and it has some text-heavy pages and we need to support two languages.

The question I want to ask is if it is unreliable to have multiple views per language?

Lets say for example my index page, I would have one view for english and one for swedish.

Is this unreliable?

The only reason I am unsure about using locale is because it requires to have the locale in the url for the default language?

For example I want swedish as the default language and now when you browse the site in swedish the links are:

example.com/search <- Swedish

But if I were to use locale, it would look like this:

example.com/sv/search

What I want is to have is this:

example.com/search <- Swedish example.com/en/search <- English

What do you guys think?