Charrua

Charrua

Owner at Charrua

Member Since 2 Years Ago

A Coruña

Experience Points
9,200
Total
Experience

800 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
47
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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 2
9,200 XP
Apr
07
11 hours ago
Activity icon

Started a new Conversation NotificationSent Listener Returning No Response But SMS Is Sent

Hello, I'm sending SMS notifications to around 300 users using Twilio and using laravel-notification-channels/twilio. Each notification is sent through a queued job to defer the task from the app.

For logging purposes I have created a NotificationSent event listener, this event is fired when a notification is sent, and provide some information such as the $event->response from Twilio inside an object.

The main issue is that sometimes, I get the $event->response object NULL, but the SMS is sent on Twilio, it seems that for some reason I can get the response. I don't know if this is some timeout that have the job or what could be happening.

I have found that laravel-notification-channels/twilio uses the twilio/twilio-php package, this last, uses cURL to send the HTTP requests to Twilio, and the default timeout on the CurlClient is 60 seconds. Saying that, I don't know if the job gets this timeout... I'm out of ideas.

Mar
30
1 week ago
Activity icon

Awarded Best Reply on Send Notifications To Primary And Secondary Email

I have resolved this issue using the cc method on Mailable:

public function toMail($notifiable){
    return (new Mailable($this->message))->to($notifiable->email)->cc('[email protected]');
}
Activity icon

Replied to Send Notifications To Primary And Secondary Email

I have resolved this issue using the cc method on Mailable:

public function toMail($notifiable){
    return (new Mailable($this->message))->to($notifiable->email)->cc('[email protected]');
}
Activity icon

Started a new Conversation Send Notifications To Primary And Secondary Email

Hello, I'm trying to send email notifications to primary email and a copy to a secondary email. This notifications fire in batches of 1000 users. They are general notifications.

For sending notifications I'm using the Notification facade:

Notification::send($users, new Announcement($message));

And on the notification I'm using the toMail method:

public function toMail($notifiable){
    return (new Mailable($this->message))->to($notifiable->email);
}

Any ideas on how to solve this issue? Thank you.

Mar
24
2 weeks ago
Activity icon

Started a new Conversation Laravel Passport: When To Use Personal Access Tokens?

Hello, I wanted to deeper understand when to use Personal Access Tokens on Passport.

From Laravel docs:

Sometimes, your users may want to issue access tokens to themselves without going through the typical authorization code redirect flow. Allowing users to issue tokens to themselves via your application's UI can be useful for allowing users to experiment with your API or may serve as a simpler approach to issuing access tokens in general.

I understand that the first purpose is for testing or experimenting with the API, but the second "simpler approach to issuing access tokens in general" why would I need to issue an access token if not for testing or experimenting?

If I wanted to consume an API trough an SPA, this approach is good enough? What would be the weak points?

Thank you

Mar
09
4 weeks ago
Activity icon

Started a new Conversation Processing 2500 Images With Jobs

Hello, I need to download and process 2500 images (resize, add background, etc) and save them for late use.

The current scenario is:

1- using guzzle, firing 10-20 concurrent requests and saving images to local disk and saving them to database.

2- If they are saved to database, I add a job to the queue for processing each image.

3- The job process the image using the Intervention Image and save it to another location on disk.

The main problem is that I need to download them first and then process, so double space on disk and time is needed.

I was thinking on another way and was when I get the response of the image (when requesting) send the image raw content directly to the job queue to process the image. The problem here is that the jobs table gets around 600mb (this is obvious as I'm storing the images on a string) for later processing.

Other idea was to put the request of each image inside a job. Make the job do the request and process the image, only storing the processed new image. Also if the image is stored, add the value to the database. This last idea is the only one I haven't tried.

I started this project using no jobs at all, and processing the images when I get the response, but this failed many times, so I started using jobs and no more problems at all.

Any ideas on how to improve this workflow? Thank you.

Dec
16
3 months ago
Activity icon

Replied to Trying To Get Client IP Address, Getting Server IP

Hello to all, thank you for your help. The solution was $request->ip()

The error was mine, I was using on other file $request->server('SERVER_ADDR') that's why it was returning server address IP.

Activity icon

Replied to Trying To Get Client IP Address, Getting Server IP

didn't worked :( still getting the servers IP address

Dec
14
3 months ago
Activity icon

Started a new Conversation Trying To Get Client IP Address, Getting Server IP

Hello, I have my Laravel app running on a DigitalOcean Droplet, inside a Plesk account.

I have developed a webhook to store some information from an external website. There is also a middleware that checks for a signature field. In that middleware I wanted to log the requests origin IP but I'm getting the servers IP.

I have tried different solutions but they both are returning the servers IP.

\Request::ip()

$request->server('REMOTE_ADDR')

Any ideas? Thank you.

Nov
28
4 months ago
Activity icon

Started a new Conversation Populate WordPress With External API, Laravel? Lumen? Laravel Zero?

Hello, I need to develop a tool that will consume an external API and inject data as posts everyday on a WordPress website, using the WP REST API.

This tool is the "connector" between the external API and WordPress. So I'm thinking in using Lumen or Laravel Zero (console app) or even Laravel framework.

The main issue is that I have never before do this job, so I'm wondering if you can tell me some advise.

In my head this sort of "connector tool" sounds good, but maybe is not the best solution... Any ideas? Thank you.

Nov
19
4 months ago
Activity icon

Replied to Sending SMS Notification To Multiple User Phone Numbers

Good idea, but I'm sending notifications using the Notification facade for sending 1000 notifications at once.

Notification::send($users, new Announcement($message));

Any ideas on implementing your idea and what I'm using now? Or maybe a different approach? Thank you

Nov
15
4 months ago
Activity icon

Started a new Conversation Sending SMS Notification To Multiple User Phone Numbers

Hello, each of my User model have two phone numbers on the users table, phone_num and secondary_phone_num. For SMS I'm using Twilio notifications channel

On my model I have included the method

/**
 * Route notifications for the Twilio channel.
 *
 * @return string
 */
 public function routeNotificationForTwilio(){ 

    return $this->phone_num;

}

Each time I send a notification, this sends it without any problem. But what about if I wanted to send the notification to both phone numbers?

The same applies to emails, I send also an email notification, but what if the user has more than an email and wanted to be sent the notification to both emails?

Any ideas on how to solve this issue? Thank you.

Nov
12
4 months ago
Activity icon

Awarded Best Reply on Broadcasting Collection To Pusher

Hello, I'm sorry if I missed explanation.

I wanted to send some users as a collection but limit (select) fields on each user, not send all user data on the collection.

Solved it bu using another solution from other member on this forum:


public function broadcastWith()
    {
        return [
            'pending_invoices' => $this->prepareData(),
        ];
    }

protected function prepareData()
    {
        $invoices = array();

        foreach($this->pending_invoices as $invoice){
            $invoices[] = [
                'id'   => $invoice->id,
                'company'  => $invoice->client->company,
                'date'    => $invoice->date,
            ];
        }

        return $invoices;
    }
Activity icon

Replied to Broadcasting Collection To Pusher

Hello, I'm sorry if I missed explanation.

I wanted to send some users as a collection but limit (select) fields on each user, not send all user data on the collection.

Solved it bu using another solution from other member on this forum:


public function broadcastWith()
    {
        return [
            'pending_invoices' => $this->prepareData(),
        ];
    }

protected function prepareData()
    {
        $invoices = array();

        foreach($this->pending_invoices as $invoice){
            $invoices[] = [
                'id'   => $invoice->id,
                'company'  => $invoice->client->company,
                'date'    => $invoice->date,
            ];
        }

        return $invoices;
    }
Nov
10
4 months ago
Activity icon

Started a new Conversation Broadcasting Collection To Pusher

I'm trying to broadcast a collection of "pending invoices" to pusher. Following Laravel docs I have setup my event and is broadcasting all collection fields. But I wanted to broadcast some piece of information, so I'm using broadcastWith()method.

On Laravel docs this method is used for only one User but let's say I wanted to broadcast a collection of users, what would be the best way to achieve this?

For broadcasting one user and manipulate data:

public $user;


public function __construct(User $user)
{
    $this->user = $user;
}

public function broadcastWith()
{
    return ['id' => $this->user->id];
}
Oct
25
5 months ago
Activity icon

Replied to Nested Grouping 5 Levels 🤯

Great idea, I was able to create a custom SQL query with the results I wanted. The main issue about this path at the beginning was that I have many relations on the testing_candidate but I figured it!

Thank you for your help!

Oct
23
5 months ago
Activity icon

Started a new Conversation Nested Grouping 5 Levels 🤯

Well, I have some martial arts members from a school, and need to send a belt order to the belt provider.

The issue is, each belt has different details, Belt Type, Belt Size, Belt Color, Special stripe

The idea is to generate this output

Belt type: Classic
Size => 5   Color => Blue   Special stripe => Gold      Quantity => 5
Size => 3   Color => Red    Special stripe => Black     Quantity => 2

Belt type: Black Belt
Size => 5   Color => Black  Special stripe => Gold      Quantity => 5
Size => 3   Color => Black  Special stripe => Gold      Quantity => 2

Belt type: Tiger
Size => 2   Color => Blue   Special stripe => No        Quantity => 5
Size => 1   Color => Green  Special stripe => No        Quantity => 2

If I query members, I can have information for belt type, size, color and stripe. But to generate the output, the way I'm doing it now is grouping the collection by multiple levels. This adds some difficulty because it creates a nested collection with 5 levels and is difficult for me to handle so many levels.

The actual query I'm using for grouping those members

$grouped = $members->groupBy(['belt.type', 'belt.size', '.belt.color', 'belt.stripe']);

The output I get

Collection {#864 ▼
  #items: array:2 [▼
    "Classic" => Collection {#870 ▼
      #items: array:2 [▼
        5 => Collection {#992 ▼
          #items: array:1 [▼
            "Orange" => Collection {#991 ▼
              #items: array:2 [▼
                "Black stripe" => Collection {#958 ▼
                  #items: array:1 [▼
                    0 => TestingCandidate {#953 ▶}
                  ]
                }
                "Plain" => Collection {#990 ▼
                  #items: array:1 [▼
                    0 => TestingCandidate {#956 ▶}
                  ]
                }
              ]
            }
          ]
        }
        3 => Collection {#960 ▼
          #items: array:1 [▼
            "Orange" => Collection {#963 ▼
              #items: array:1 [▼
                "Plain" => Collection {#993 ▼
                  #items: array:1 [▼
                    0 => TestingCandidate {#955 ▶}
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
    "Black Belt" => Collection {#866 ▼
      #items: array:1 [▼
        3 => Collection {#994 ▼
          #items: array:1 [▼
            "Black" => Collection {#1001 ▼
              #items: array:1 [▼
                "Black stripe" => Collection {#951 ▼
                  #items: array:1 [▼
                    0 => TestingCandidate {#954 ▶}
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

On the frontend I use something like

@foreach ()
    @foreach()
        @foreach()
            @foreach()
            ...
            @endforeach
        @endforeach
    @endforeach
@endforeach

This makes any sense to you? What do you think?