Xibel

Xibel

Member Since 10 Months Ago

Experience Points
750
Total
Experience

4,250 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
5
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
750 XP
Oct
30
1 week ago
Activity icon

Replied to How To Pass Paramater To StreamedResponse

Answer is 4 years old but still valid. Thank you!

Oct
22
3 weeks ago
Activity icon

Replied to To Pivot Or Not To Pivot

Thank you both for your answer. I like the solution from @afitriali more. I have setup those relationships in my models.

The issue I had was how to get to the pair information that is connected to all trades of the auth user. I was able to dump all trades with all pairs but I was not able to get only the pair names. So I ended in using the method toArray() so I can use the dot notation and using foreach with the data_get helper.

To get the pairnames of all trades of the current auth user is as follows:

$trades = auth()->user()->trades()->with('pair')->get()->toArray();

foreach ($trades as $item)
        {
            Log::Info(data_get($item, 'pair.symbol'));
        }

The result:

[2019-10-22 12:10:48] local.INFO: FUNBTC
[2019-10-22 12:10:48] local.INFO: BCNBTC
[2019-10-22 12:10:48] local.INFO: PAXTUSD

Now I am able to access all trade information and all pair information of that trade. Thanks again!

Oct
16
3 weeks ago
Activity icon

Started a new Conversation To Pivot Or Not To Pivot

I am fighting a lot with eloquent setup of my tables and models. I need to make a design decision before I continue coding. I have read many articles but I can't find any satisfying answer. Maybe you guys can help me.

I am designing a cryptomonitor website where Users have Trades. The Trades contain information about the purchase date, price and fee. The Trades table has a connection to a Pair table where the coins are stored and where the price is updated every second.

table Users

  • id
  • name

table Trades

  • id
  • user_id
  • pair_id
  • amount
  • price

table Pairs

  • id
  • coin_name

The above structure would assume that this needs a Pivot approach. So I set relation in the User model as:

public function pairs()
    {
        return $this->belongsToMany('App\Pair', 'trades', 'user_id', 'pair_id')
        ->withPivot('amount', 'price')
        ->withTimestamps();
    }

The issue now is when I would like to get all amounts of each trade a user has made I would use:

$user = User::find(auth()->id());
    foreach ($user->pairs as $pair)
    {
        Log::Info($pair->pivot->amount);
    }

No word about Trades. Only Pairs and Users. I would like to have a more approach with Trades.

A user hasMany trades, a trade belongsTo a user. (I hope these are correct).

A trade belongTo pair, a pair belongsToMany trades. (I hope these are correct).

The table setup would stay the same with above approach. Only the relationships will have to change and I cannot use the Pivot methods.

But now I want to have the coin_name of Trade 3 for User 1 and there comes the frustration. I have no clue how to handle this. Are there any examples for this three table approach?

Oct
06
1 month ago
Activity icon

Replied to How To Redis Mget Replace Key Numbers With Key Names

Excellent!

The mget method will always return an equal array key amount. So even when there is no value for a key, the value will be returned null. And that makes sure that your input array for keys will always return an equal amount of returned values. That way you can be sure that the combine will allign the correct keys to values.

Activity icon

Started a new Conversation How To Redis Mget Replace Key Numbers With Key Names

I write a product:price list to Redis. Example: apple:2,10 orange:3,40 milk:1,99.

When I mget a few products like:

$result = Redis::mget('apple','milk');

I get an array back with numbers as keys:

array:2 [
  0 => "2,10"
  1 => "1,99"
]

I would like to replace the 0 and 1 with apple and milk again so I can run @foreach in the view blade. How can I do this?

Jul
09
4 months ago
Activity icon

Replied to Where To Place Redis Data Pull, Model Or Controller?

That sounds 'logic'. Where do I place this piece of logic? In a service provider or a helper file?

I mean the physical location to place this piece of code? I am new to Laravel and I want to learn the best way to place functionality at the most 'logic' and save place.

Thanks for your help btw.

Jul
07
4 months ago
Activity icon

Started a new Conversation Where To Place Redis Data Pull, Model Or Controller?

My Laravel app receives data every second from an webAPI. I put this data in the database and my users pull this data every second from the database. Because the data changes every second I cannot us the Redis as a 1 minute cache. However I got al lot of reads from the database. So what I want to do is to write the received webAPI data to the DB (for history) and to Redis. The users will always read the Redis first and if not found than from the database.

Now my question. I have model files which are almost empty. I use them to set Eloquent relations. Where do I put the Redis reads? Do I put this in the controller or in the model?