Member Since 2 Years Ago

Experience Points 7,860
Experience Level 2

2,140 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 62
Best Reply Awards 0
Best Reply
  • 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.


    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.


    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.

11 Mar
4 months ago

Bartude started a new conversation Concat Many To Many Polymorphic Into One Column

I have a many-to-many polymorphic relationship of Tags, and they are connected to Devices and Users. When querying Devices, I also want to query the associated tags. Right now I can GROUP_CONCAT the associated tags into a single column, but two things are happening which I don't want:

  1. When applying count at the end, instead of counting the number of devices, it's counting the number of tags which are a match for the query
  2. It's only retrieving the tags which are a match for the query.

Here is the query:

$devices->leftJoin('taggables as t', 't.t_taggable_id', '=', 'd_id')
            ->leftJoin('tags', 'tags.t_id', '=', 't_tagId')
            ->where('t.t_taggable_type', 'App\Device')
            ->addSelect(\DB::raw('GROUP_CONCAT(t_name) as t_name'))
            ->groupBy($columns, 'devices.created_at')
            ->where(function ($devices) use ($columns, $params) {
                array_push($columns, 't_name');
                foreach ($columns as $column) {
                    $devices->orWhere($column, 'like', '%'.$params->query.'%');

$devices is the list of devices I want to query. If I query London, and a device has two tags which contain London, when applying count() at the end of this query, it's going to return 2, and the t_name attribute will have both those tags only (but it has like 10 more unrelated to London)

Any idea on what I can do to fix this?

05 Dec
7 months ago

Bartude left a reply on Recommended Place For A Shared Function

@LOSTDREAMER_NL - Yeah, I chose a trait since it's related to the controllers, but not actually a "parent" to those controllers.

04 Dec
7 months ago

Bartude started a new conversation Recommended Place For A Shared Function

Hey guys,

So I have a function that will be shared with at least two controllers, and to adhere by DRY, I would like to put it in one location only. i was thinking in a helpers class, but this function will access the DB multiple times so I'm not sure that is best practice. What would you say is the recommended place for something like this?

12 Nov
8 months ago

Bartude left a reply on Factory Not Retrieving DB Records Properly

@SHEZ1983 - I'm calling the factory like this in DatabaseSeeder:

factory(App\Cluster::class, 10)->create();

09 Nov
8 months ago

Bartude started a new conversation Factory Not Retrieving DB Records Properly

So I have a migration with four fields like this:

Schema::create('clusters', function (Blueprint $table) {
            $table->unique(['c_virtualMachineOneId', 'c_virtualMachineTwoId']);

I'm trying to populate this table with a factory like this:

$factory->define(App\Cluster::class, function (Faker $faker) {
    $virtualMachines = App\VirtualMachine::all()->pluck('vm_id')->toArray();
    $length = count($virtualMachines) / 2;
    $vmOnes = array_slice($virtualMachines, 0, $length);
    $vmTwos = array_slice($virtualMachines, $length);
    do {
        $id1 = $faker->randomElement($vmOnes);
        $id2 = $faker->randomElement($vmTwos);
    } while(DB::table('clusters')->where('c_virtualMachineOneId', $id1)->where('c_virtualMachineTwoId', $id2)->exists());

    return [
        'c_virtualMachineOneId' => $id1,
        'c_virtualMachineTwoId' => $id2,
        'c_quorum_device'       => $faker->macAddress,

Every once in a while when I run my factory, I'm getting constraint violations. Supposedly the do while should prevent this, but it's not working. I've also tried to dump DB::table('clusters')->count()right before the return to see if it's incrementing, but it always dumps 0. Any idea why this is happening and how to fix this?

Bartude left a reply on Accessing JSON In TEXT Columns

@staudenmeir This is how the json appears in the accessor being passed in $value

""{\n \"si_id\": 66,\n \"si_accountId\": 9,\n \"si_host_name\": \"Katarina\",\n \"si_number_portal_clients\": 3,\n \"si_number_signage_clients\": 8,\n \"si_storage\": 88103,\n \"si_monitoring\": 0,\n \"si_contract_expiry\": \"2028-08-22\",\n \"operator_id\": 18,\n \"customer_id\": 19\n}" ??

To store the json, I'm uploading a JSON file, and then doing this:

'b_bom_json' => file_get_contents($request->bom),

08 Nov
8 months ago

Bartude started a new conversation Accessing JSON In TEXT Columns

I have a TEXT field in the database that has JSON. I'm having two problems.

The first is that when I try to access that field, even with casting that field in the model, it's not returning as proper JSON.

protected $casts = [
    'b_bom_json' => 'array',

To fix this I had to set an accessor, but even then it's weird cause the value field comes weirdly formatted that I had to decode it twice to return a proper json.

public function getBBomJsonAttribute($value){
        return json_decode(json_decode($value));

The second is that I've seen in quite some places, that with Eloquent I can access the json values directly in the where conditions, but it's throwing an error because it's not identifying the arrow.

public function boms() {
        return \App\BOM::where('b_bom_json->operator_id', $this->u_id)->get();

Is the second problem even feasible?

25 Oct
8 months ago

Bartude left a reply on Laravel Echo Listen On Host Subfoler

Nevermind, I got it working by just removing the echo from the host. In my laravel-echo-server configuration, the authHost already has the /echo in front of the IP so I assume that's all that's needed.

The configuration is now like this:

import Echo from 'laravel-echo'; = require('');
window.Echo = new Echo({
    broadcaster: '',
    host: ''

Bartude started a new conversation Laravel Echo Listen On Host Subfoler

My Laravel application is located at Here is my config:

import Echo from 'laravel-echo'; = require('');
window.Echo = new Echo({
    broadcaster: '',
    host: ''

When I debug, this is what I get: polling got data 27:44/echo/,"Invalid namespace" socket receive: type "message", data "4/echo/,"Invalid namespace"" decoded 4/echo/,"Invalid namespace" as {"type":4,"nsp":"/echo/","data":"Invalid namespace"}

It isn't able to decode the /echo part of the url, thus it tries to listen only on

Any idea how I can fix this?

24 Oct
8 months ago

Bartude started a new conversation Notifications Factory For Users

Is there any way to create a notifications factory for my notifications table in the database? I found a file called Factory in Illuminate\Contracts\Notifications, but without an example I'm not really sure how to proceed or even if this file has anything to do with what I want.

23 Oct
8 months ago

Bartude left a reply on Validation Different Rule Triggering When Field Is Null

@Vilfago bail only stops running validation rules on an attribute it's on. Even if required fails, it will still pass onto the new_password rules

Bartude started a new conversation Validation Different Rule Triggering When Field Is Null

Laravel Version: 5.5 PHP: 7.2.9

I'm trying to reset a user password and first I want to do some validation, like this:

$this->validate($request, [
    'old_password' => 'required',
    'new_password' => 'required|different:old_password|confirmed',

However, in my form, if I don't fill the old_password, but fill in the other two fields new_password and new_password_confirmation, I'm getting both an error of The old password field is required. and also The new password and old password must be different..

I checked the request object and old_password is being passed as null, and new_password has a string, so they should be different and the rule shouldn't be triggering.

Is this the expected behavior? If so, how can I make it so this error doesn't show up, or make it so only the first error shows in case it fails? (I could create two validations like above, one for each attribute, but that seems like a shortcut, which I would like to avoid)

11 Jul
1 year ago

Bartude started a new conversation Laravel Or Lumen? What To Use?


I'm developing an API, so I decided to use Lumen. However, as I'm progressing, I'm adding a couple of stuff that isn't originally in Lumen but is in Laravel, like Notifications, Mailables, Filesystem. I've also enabled the Facades and Eloquent because I'm extremely used to it by now. I'm also doing a lot more routes than I initially planned, right now I have around 60 but most likely the final version will have close to 100. And I have around 15 migrations, but should end up with about 20.

My question is, should I continue to use Lumen or at this point is it better to just use Laravel? What should be the deciding factor between choosing which one to use?

17 Jan
1 year ago

Bartude started a new conversation About SQL Injection


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.

28 Dec
1 year ago

Bartude started a new conversation Laravel Multiple DB On Server Mixed Connections

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.

28 Nov
1 year ago

Bartude left a reply on Multiple Call To Actions On Notifications

@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?

27 Nov
1 year ago

Bartude left a reply on Multiple Call To Actions On Notifications

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

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?

14 Nov
1 year ago

Bartude started a new conversation Redis Queue Always Processing The Same Job


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.

25 Jul
1 year ago

Bartude started a new conversation Best And Safest Way To Pass Data To Event Handlers

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?

19 Jul
2 years ago

Bartude started a new conversation Include Files Depending On User Input With Variables From Controller

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?

14 Jul
2 years ago

Bartude started a new conversation Notifications "Message Rejected By Local Rules"

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?

12 Jul
2 years ago

Bartude started a new conversation Find Unused Methods/Routes/Views

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?

27 Jun
2 years ago

Bartude left a reply on Multiple Languages

@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

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.

20 Jun
2 years ago

Bartude started a new conversation Laravel Queue Takes Up Too Much Physical Memory And Processes

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();

14 Jun
2 years ago

Bartude left a reply on Queue Jobs And Mail Notifications

@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

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?

13 Jun
2 years ago

Bartude left a reply on Queue Worker Not Doing Anything L5.4

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

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?

07 Jun
2 years ago

Bartude left a reply on Contacts Page Send To Pre-defined Email


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

@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

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?

06 Jun
2 years ago

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

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

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

31 May
2 years ago

Bartude started a new conversation [Socialite] Login/Register With Facebook

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.

26 May
2 years ago

Bartude started a new conversation MVC Where Does The DB Logic Go?

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...)

25 May
2 years ago

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

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

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          |

24 May
2 years ago

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

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?

23 May
2 years ago

Bartude started a new conversation Multiple Notifications VS One Dynamic Notification

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.

12 Apr
2 years ago

Bartude left a reply on Same Database Maintain Login Across Multiple Apps

@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

@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

@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

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?

10 Oct
2 years ago

Bartude started a new conversation Laravel & AngularJS Authentication

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?

30 Sep
2 years ago

Bartude left a reply on Laravel Live Search Box

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?

29 Sep
2 years ago

Bartude started a new conversation Laravel Live Search Box

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?

22 Sep
2 years ago

Bartude left a reply on Different Workspaces

@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

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?