0 Best Reply Awards

  • Member Since 1 Year Ago
  • 51 Lessons Completed
  • 0 Favorites

17th January, 2018

Bartude started a new conversation About SQL Injection • 5 months ago


Well, this came out of the blue for my dev team today. We were starting to do an autocomplete feature for our search engine in our web app, and we started seeing our mysql table of saved searched expressions by users. All of a sudden we noticed a bunch of lines like this:

'/etc/passwd' '1=1' 'drop table companies' 'or 1=1' and a couple more like that.

We knew that Laravel protects against SQL Injections by using PDO parameter binding so we never really had to think about that. We are also removing special characters(like = / , ; : etc...) from the search queries before making the connection to the database. And it indeed did nothing when that happened (so we dodged a bullet there).

But I would like to know if (and where in) Laravel has a function that checks all requests for possible sql injections, cause I would like to receive alerts whenever this type of thing happens.

28th December, 2017

Bartude started a new conversation Laravel Multiple DB On Server Mixed Connections • 5 months ago

I have a shared server with multiple Laravel apps, but the two that matter are: -Crawler (Crawls through a lot of pages on a website, therefore takes quite some time) -Job app(Normal app with auth and whatnot..)

Each of them have a separate database. Whenever the Crawler is doing it's thing (most of the times it takes up to 20 minutes to finish the whole thing, it's searching the pages and doing some queries to the database), if I try to execute any function on my Job app that requires doing a query(like logging in), I get an error basically saying that my Job app was trying to search on the Crawler database for the information.

Anybody has any idea on why this happens? Or how to avoid this? (Other than the obvious solution which is put them in separate servers )

I hope this is not confusing, but if it is, please tell me so I can explain better.

28th November, 2017

Bartude left a reply on Multiple Call To Actions On Notifications • 6 months ago

@robrogers3 That solved my problem, but it's kind of limited. In the near future I'm going to see if I can make this more dynamic, probably with an array of buttons and doing a foreach inside the email template and submit a solution to git. Since this will be my first time doing a pull request(I think this is the correct name), does anybody have something I can read to help me with this in github?

27th November, 2017

Bartude left a reply on Multiple Call To Actions On Notifications • 6 months ago

I'd already published that, but probably I didn't do it correctly:

{{-- Action Button --}}
    switch ($level) {
        case 'success':
            $color = 'green';
        case 'error':
            $color = 'red';
        case 'normal':
            $color = 'blue';
            $color = 'purple';
@component('mail::button', ['url' => $actionUrl, 'color' => $color])
{{ $actionText }}

@component('mail::button', ['url' => $actionUrl, 'color' => $color])
{{ $actionText }}

Bartude started a new conversation Multiple Call To Actions On Notifications • 6 months ago

Hey guys,

According to the documentation: I can add as many button components as I want to a notification, but it's not working. It's only adding one button and it's the last one in my notification:

public function toMail($notifiable)
        return (new MailMessage)
                    ->subject('Registration complete')
                    ->greeting('Hey ' . $this->name)
                    ->line('Here are two buttons!')
                    ->action('Buttons1', url('/button1url'))
                    ->action('Button2', url('/button2url'))
                    ->line('See you soon,');

I've published the notification view and checked the MailMessage class and I can probably solve this by modifying a bit this class to make it work, but if in the documentation it says I can add multiple buttons, there must be something I'm missing. Any ideas?

14th November, 2017

Bartude started a new conversation Redis Queue Always Processing The Same Job • 7 months ago


So I'm building a small app locally using the Twitter API (for my case I'm using an endpoint which has a 15 request max per 15 minutes limit) and a Redis Queue.

When I dispatch just one Job to the queue, that Job is being processed an infinite amount of times. I can see the Job being processed time and time again on the command line. Any idea why this might be happening?

I'm sure I'm only dispatching one Job as I do a dd after to stop it from going further. The code in general is really simple as I'm sure that's not the problem.

25th July, 2017

Bartude started a new conversation Best And Safest Way To Pass Data To Event Handlers • 10 months ago

Hey guys,

Imagine this situation.

In my view I have a table with 50 rows that are filled with data coming from a controller(using the foreach blade directive of course). Each of those rows has an edit button that calls a bootstrap modal. And inside that modal I have all of the information regarding that row so that I can edit it.

My question is: What is the best way to do this without creating a modal for each of the rows or without passing the object of that row through a data attribute? I mean, data attributes are really handy, but in this case, if somebody was to inspect the page, they would all the information of each and every row..

Is there any way to avoid doing one of these solutions?

19th July, 2017

Bartude started a new conversation Include Files Depending On User Input With Variables From Controller • 11 months ago

Hey guys,

I have a little game that has about 7 screens, and I want everything to be asynchronous so I'm using AJAX. Each of the 7 screens are on different partial files so everything is organized.

My idea is that, depending on the users choices, I need to show the next screen with data coming from a controller. How can I accomplish all this using AJAX? Example: User chooses Theme Health, then I want to show another partial that will use data related to the theme chosen. This is more or less what I want to accomplish:

<div class="screen">
    <div class="content">
        <div class="chat_container"></div>
        <div class="center-flex">
            @if($screen == 'themes')
                @include('game.themes', ['themes' => $themes])
            @elseif($screen == 'options')
                @include('game.options', ['options' => $options])

        var theme = $(this).data('name');
            url: '/game/options',
            type: 'get',
            data: {'theme': theme},
            success: function (data) {
                //And here somehow change to the options screen with the data that is returned from the AJAX call

Is it even possible to do something like this? Or do I have to include all the screens at once and pass all the data and then treat it all on the client side?

14th July, 2017

Bartude started a new conversation Notifications "Message Rejected By Local Rules" • 11 months ago

Hey guys,

I'm sending a couple of notifications (which are being added to a queue), but after I migrated my app to a different server, I started getting this error message on my failed_jobs table:

exception 'Swift_TransportException' with message 'Expected response code 250 but got code "550", with message "550 "Message rejected by local rules"

I'm guessing this has something to do with my new server. Does anybody know what it is?

12th July, 2017

Bartude started a new conversation Find Unused Methods/Routes/Views • 11 months ago

Hey guys,

I've recently started working on a really big project, that has already been developed by around 6 different developers. So I don't go crazy looking through all these methods/controllers/models/etc... Is there a package or a way that can help me find all the methods that are not being used so I can review them and then mark them for deletion?

27th June, 2017

Bartude left a reply on Multiple Languages • 11 months ago

@corymayfield I've just seen the video, and although it's a really old version of Laravel it's simple to adapt to Laravel 5.4. However, that solution is really simplistic. I would like to add the locale to url after the base URL and before any route like:

Bartude started a new conversation Multiple Languages • 11 months ago

Hey guys,

I have both a website and a backoffice for the website. I need to implement multiple languages on the website, and define differents configs for each language in the back office.

I've looked at a couple of different discussions to see how this was done, but neither were very conclusive.

I basically did this by following this discussion:

However, I've made some changes because I couldn't get it to work.


    public function map(Request $request){
        $locale = $request->segment(1);
    protected function mapWebRoutes($locale){

Language Middleware:

class Language{
    public function __construct(Application $app, Redirector $redirector, Request $request){
        $this->app = $app;
        $this->redirector = $redirector;
        $this->request = $request;
    public function handle($request, Closure $next){
        // Make sure current locale exists.
        $locale = $request->segment(1);

        if ( ! array_key_exists($locale, $this->app->config->get('app.locales'))) {
            $segments = $request->segments();
        //To always add the fallback_locale to the beginning of the routes
            array_unshift($segments, $this->app->config->get('app.fallback_locale'));

            return $this->redirector->to(implode('/', $segments));

        return $next($request);

Is this the best way? I mean, it works (I still have to add the routes from some of my packages for them to work), but I have a gut feeling there is a better way to do this.

20th June, 2017

Bartude started a new conversation Laravel Queue Takes Up Too Much Physical Memory And Processes • 1 year ago

Hey guys, I think this is the right channel.

I'm doing some crawling on a couple of websites, and I decided to add in average 50 URL's to crawl to each job. Most of the times I'm crawling around 3000, so that gives around 60 jobs to process each time. So on each job, it has to search inside 60 URL's to get the content.

Since I've put the crawling on a queue, I've noticed that there's been a huge spike in my servers physical memory usage and number of processes used. This morning I ran the queue worker to do 60 jobs, it did about 6 jobs and my physical memory went up to 355MB out of 1GB and the number of processes to 36 out of 100.

And even though this was around 3 hours ago, the number of processes won't go down neither the physical memory usage.

Is this normal?

I'm running the scheduler as a cron entry, and in my kernel.php I'm executing the queue:listen command to see if there are any jobs.

$schedule->command('queue:listen --daemon')->dailyAt('11:35')->withoutOverlapping();

14th June, 2017

Bartude left a reply on Queue Jobs And Mail Notifications • 1 year ago

@EventFellows You're right, actually some of the notifications have to happen on the Scheduler.

But how can I queue mails directly without using a job? (When you say mails, I assume you mean mails by notification) This is what I've tried: dispatch($company_user->notify(new CompanyAdScheduled($ad, $request->date, $request->time, $company_name->companyName)));

And it gives this error: ReflectionException in Container.php line 553: The parameter class is expected to be either a string or an object

Bartude started a new conversation Queue Jobs And Mail Notifications • 1 year ago

Hey guys,

I have 15 notifications of which each are executed depending on the user's action. Each one has a different body and a varied number of parameters being passed to the __constructor.

Since each notification takes some seconds to actually send the email, I want to put them in a queue.

The only way I can think of is to create 15 different Jobs files. My question is, is there a better way to do this? Or am I just overthinking and this is the best way?

13th June, 2017

Bartude left a reply on Queue Worker Not Doing Anything L5.4 • 1 year ago

I've figured it out. The problem was that it wasn't listening to the right queue. On my queue.php I defined the queue as "default", but I was pushing onto the "emails" queue.

I just removed the ->onQueue('emails') and it started working.

Bartude started a new conversation Queue Worker Not Doing Anything L5.4 • 1 year ago

Hey guys,

I'm trying to create a queue to send emails. The Jobs get added to my local DB, but the artisan command php artisan queue:work isn't doing processing anything.

Here is my connection in queue.php (I'm using my local mysql database):

'database' => [
      'driver' => 'database',
      'table' => 'jobs',
      'queue' => 'default',
      'retry_after' => 90,

Here is the method I'm calling to create the Jobs:

$email = (new SendTestEmail())->onQueue('emails');

Here is my handle method in the Job:

public function handle(){
     $user = User::find(1);
     $user->notify(new SendEmail());

Here is the payload of one of the Jobs in the DB: {"displayName":"App\\Jobs\\SendTestEmail","job":"Illuminate\\Queue\\[email protected]","maxTries":null,"timeout":null,"data":{"commandName":"App\\Jobs\\SendTestEmail","command":"O:22:\"App\\Jobs\\SendTestEmail\":4:{s:6:\"\u0000*\u0000job\";N;s:10:\"connection\";N;s:5:\"queue\";s:7:\"emails\";s:5:\"delay\";N;}"}}

Most likely I have a mistake in my connection in my queue.php file. Any ideas?

7th June, 2017

Bartude left a reply on Contacts Page Send To Pre-defined Email • 1 year ago


If I remove that, then no.

But I did a {{dd($message)}} in the view, and it was returning me a Mail object, no idea why, probably cause it's a reserved keyword.

I just changed the variable $message to $content and it didn't give me any errors and passes the information just fine to the view.

Bartude left a reply on Contacts Page Send To Pre-defined Email • 1 year ago

@tekmi Even doing it like this give me the same error:

return $this->from($this->email)
                    ->subject('Message Sent')
                    ->view('emails.newsletter')->with(['message' => 'Message Example']);

Bartude started a new conversation Contacts Page Send To Pre-defined Email • 1 year ago

Hey guys,

I have a contacts page where anyone can send messages. I would like those messages to be sent to one of my emails, like [email protected]

I created a Mail file:

    protected $email, $message;

     * Create a new message instance.
     * @return void
    public function __construct($email, $message)
        $this->email = $email;
        $this->message = $message;

     * Build the message.
     * @return $this
    public function build()
        return $this->from($this->email)
                    ->subject('Message Sent')
                    ->view('emails.newsletter')->with(['message' => $this->message]);

I am calling it like this:

use App\Mail\MessageSent;

public function sendContactsMessage(Request $request){
        Mail::to('[email protected]')->send(new MessageSent('[email protected]', 'My Message Example'));
        $request->session()->flash('message_sent', 'true');
        return Redirect::back();

In my view I have:


However I'm getting this error:

ErrorException in helpers.php line 519:
htmlspecialchars() expects parameter 1 to be string, object given (View: C:\xampp\htdocs\app\resources\views\emails\newsletter.blade.php)

Is there anything that I'm doing wrong?

6th June, 2017

Bartude left a reply on MethodNotAllowedHttpException In RouteCollection.php Line 251 Only On Live Server • 1 year ago

Ok, I've managed to find the problem and with it the solution. In my data that I was sending via the ajax post call, I was sending encoded URL of images(in the form of an array), and I have no idea why, but I think the ajax request was interpreting those URL's as the url I wanted to call in the ajax.

I just converted that array of URL's to json and it worked.

Bartude left a reply on MethodNotAllowedHttpException In RouteCollection.php Line 251 Only On Live Server • 1 year ago

I tried putting the project in another server for testing and without doing anything, it was working there. But when I put it in the designated final server, it gives me this error.

What kind of server configurations could be interfering with this?

In my testing server, the URL is like: In my designated final server, the URL is like:

The .htaccess in both are the same

31st May, 2017

Bartude started a new conversation [Socialite] Login/Register With Facebook • 1 year ago

Hey guys,

I'm reading up on the documentation, and I noticed the routes mentioned there:

Route::get('login/github', 'Auth\[email protected]');
Route::get('login/github/callback', 'Auth\[email protected]');

I was wondering, if a user presses the button that leads to the first route, if he doesn't have a record in the DB, my app will register him, right? And then if he has a record in the DB and presses the button, my app will just log him in, right?

If that's so, then they're exactly the same button.

26th May, 2017

Bartude started a new conversation MVC Where Does The DB Logic Go? • 1 year ago

Hey guys,

This may be a "stupid" question, but I just picked up a huge project that's almost finished and as I'm browing through the files to familiarize myself, I see something that confuses me.

All the DB logic (Insert, Update, Delete, Read) is in the Models. I've always thought that kind of logic goes in the Controllers, and that in Laravel the only thing that goes in the Models are the relations methods and those other "minor" stuff.

The way it is in the project, if a user submits a form in a View, it passes the data to the respective Controller, and then from there it calls the respective method to insert, update, etc... in the Model. Then from there it passes it back to the Controller and then to the View again. (View -> Controller -> Model -> Controller -> View)

Is this done properly? (I probably learned all of this in the incorrect order...)

25th May, 2017

Bartude left a reply on MethodNotAllowedHttpException In RouteCollection.php Line 251 Only On Live Server • 1 year ago

Yes, that's because I put it in the api.php file according to @Hawkleaf, and then I changed it in the ajax request. But it's still returning the same error.

Bartude left a reply on MethodNotAllowedHttpException In RouteCollection.php Line 251 Only On Live Server • 1 year ago

Here is the result of that command. I tried putting it both in api.php and web.php, still giving the same error

| Domain | Method   | URI            | Name | Action                                            | Middleware   |
|        | GET|HEAD | /              |      | Closure                                           | web          |
|        | POST     | api/imagessave |      | App\Http\Controllers\[email protected] | api          |
|        | GET|HEAD | api/user       |      | Closure                                           | api,auth:api |
|        | GET|HEAD | image/delete   |      | App\Http\Controllers\[email protected]  | web          |

24th May, 2017

Bartude started a new conversation MethodNotAllowedHttpException In RouteCollection.php Line 251 Only On Live Server • 1 year ago

Hey guys,

I'm trying to do a simple jQuery AJAX POST request to my controller, but it's returning me the following error MethodNotAllowedHttpException in RouteCollection.php line 251

Here is my AJAX:

                    headers: {
                        'X-CSRF-TOKEN': "{!! csrf_token() !!}"

                    var html = $(".before_text").val();
                    var storage_type = $('input[name=storage_type]:checked').val();
                    var num_days = $('.num_days_input').val();

                        url: '/imagessave',
                        type: 'POST',
                        data: {'src_array' : src_array, 'storage_type' : storage_type, 'num_days' : num_days},
                        datatype: 'array',
                        success: function (data) {
                            // console.log(data);
                            $('.num_images_saved').html('<h1>Num Images Converted: '+ data[0]);
                            var count = 1;
                            for(var i=1; i<data.length; i++){
                                html = html.replace(src_array[i-1], String(data[i]));

                            src_array = [];

                        error: function(msg){

Here is my route Route::post('/imagessave', '[email protected]');

On my localhost it doesn't give any error, but when it goes live it gives the error. Any idea?

23rd May, 2017

Bartude started a new conversation Multiple Notifications VS One Dynamic Notification • 1 year ago

This may be a stupid question, but which is better? To have 20 different notification files or just one dynamic Notification file?

Some of them are going to be run with a cron job at the same time, so I don't know if that influences anything if it's only one dynamic Notification.

12th April, 2017

Bartude left a reply on Same Database Maintain Login Across Multiple Apps • 1 year ago

@gustav1105 They are all different instances of Laravel with a shared DB.

Basically it's the main website, then I'm going to have several different games, each one with their own instance of Laravel, which I will then access like so: And so on...

They mainly share the same DB, because it's in the backoffice that I add different elements to all the different games.

Bartude left a reply on Same Database Maintain Login Across Multiple Apps • 1 year ago

@gustav1105 I would completely agree with you, if the several application were on different domains. But it's like @Borisu said, I'm going to access each application as such.

Main website: First App: Second App: And so on...

I'm doing it like this, because in the future I will probably need to erase or take down temporarily one of the apps, and this way it's much easier.

@gustav1105 Are you still of the same opinion? It's because my knowledge of Laravel isn't that deep, and if I go down the Laravel Passport road, It's going to be harder and take longer than I have planned.

Bartude left a reply on Same Database Maintain Login Across Multiple Apps • 1 year ago

@Hawkleaf Is it necessary to go that far? I mean with tokens and what not.

Isn't the "simplest" way to share the sessions? And then whenever someone tries to access an app, in the middleware(?), I check in the session if somebody is already logged in, and if they are, I automatically log them in and redirect them to where they're going.

And the way I have it, all the apps share the same DB, therefore it's the central DB for everything and all the apps access it.

Bartude started a new conversation Same Database Maintain Login Across Multiple Apps • 1 year ago

Hey guys,

I've seen various similar discussions here, but couldn't find any that fit my needs.

I have one domain, which is going to have a couple of Laravel 5.4 apps. All of them are connected to the same database, meaning they all share the users table.

I would like to know how to, for example, when a user logs in on one of the apps, if he/she goes to another app on the same domain, they will be automatically logged in.

I think I need to use Sessions, but I'm not really sure where I would have to apply it. Any help?

10th October, 2016

Bartude started a new conversation Laravel & AngularJS Authentication • 1 year ago

Hey guys, I'm going to start to develop an app that has Laravel for the back-office and then connects via API to the front-office that is going to use AngularJS. I found some tutorials but they are more or less old and I don't really know how they adapt to Laravel 5.3. My idea is to create an API in laravel that will serve as a back-office for many apps that I will create in the future, so that a user by logging in to one app, will have access to the rest of the apps that are connected to the API. I found that the best way was to use JWT tokens for authentication(for example Satellizer), but I have one question.

Do I have to do a login system in the back-office for the admin using the make:auth command and then implement the JWT tokens for the front-office for regular users? Or do I simply implement the JWT tokens and create roles in the User table, and then the login page for both the admin and user will be the same, despite the layouts and content presented will be completely different?

30th September, 2016

Bartude left a reply on Laravel Live Search Box • 1 year ago

Hey, thanks for the links. I've been trying to do something from scratch, but I don't think I understand well enough how to do the connection bewtween JS and the controller.

This is my JS code:

function search(str) {
    var xhttp;
    /*if (str.length == 0) {
        document.getElementById("results").innerHTML = "";
    xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            document.getElementById("results").innerHTML = this.responseText;
    };"GET", "./search/"+str, true);

This is my route:

Route::get('search/{$txt}', '[email protected]');

And this is my function in the controller:

public function search($searchText){
        $orders = $this->getOrders($id);
        $results = array();
        $cont = 0;

        foreach ($orders as $key => $value) {
            foreach ($value as $type => $info) {
                foreach ($info as $name => $data) {
                    if(strpos($data, $searchText) !== false || strpos($name, $searchText) !== false){
        return "results"; //Just to see if it's returning correctly

And it's giving me a 404 error in the JS method on the xhttp.send() Any ideas?

29th September, 2016

Bartude started a new conversation Laravel Live Search Box • 1 year ago

Hey guys, I'm using Laravel 5.3. This is most likely not a Laravel question but I already searched the web but found nothing that could help me. I have an array that presents data onto a blade template. My objective now is to create a live search box to filter the data. Here is an example of my data:

array(2) { 
    [0]=> object(SimpleXMLElement)#196 (6) { 
        ["id"]=> string(1) "1" 
        ["id_customer"]=> string(1) "1" 
        ["date_add"]=> string(19) "2016-09-26 16:31:18" 
        ["payment"]=> string(39) "Pagamentos por Transferência Bancária" 
        ["total_paid"]=> string(9) "56.580000" 
        ["reference"]=> string(9) "OFBDWERLL" 
    [1]=> object(SimpleXMLElement)#194 (6) { 
        ["id"]=> string(1) "2" 
        ["id_customer"]=> string(1) "1" 
        ["date_add"]=> string(19) "2016-09-26 16:37:59" 
        ["payment"]=> string(39) "Pagamentos por Transferência Bancária" 
        ["total_paid"]=> string(9) "40.590000" 
        ["reference"]=> string(9) "CAYWFSRCA" 

An example of the search box would be, if I typed in id_customer, it would show me every piece of data that include the id_customer key. Any ideas on how to achieve this?

22nd September, 2016

Bartude left a reply on Different Workspaces • 1 year ago

@SaeedPrez Yeah, good idea. When the employee logins, a middleware will check the workspace id from the employee, and then the controllers will have to dynamically show the data on the view depending on the workspace. But from I'm thinking, like, 90% of the app has to be dynamic for this to work. And then on the database, basically every table will have to have a row which is workspace_id. Am I thinking straight?

Bartude started a new conversation Different Workspaces • 1 year ago

Hey guys, I'm using Laravel 5.3. I have a company registration and then the company invites employees. The objective is that each company and its employees work on a unique "workspace".

An example would be Company Zeus has it's employees Hercules and Megara. When either Hercules or Megara login, they would go to the workspace "Olympus" where they would view different information pulled from several API's. To add to the example, a company Odin has an employee Thor. When Thor logins, he will go to the workspace "Valhalla". But all of it on the same application. Thor can never access "Olympus" and Hercules can never access "Valhalla".

I'm kind of confused on how to proceed to accomplish this. Anybody can give me some guidance?

I've easily done the registration part and inviting users. My question is, how do I structure my app so that it presents different workspaces depending on the logged in employee?

Edit Your Profile

Want to change your profile photo? We pull from