bobbybouwmann

bobbybouwmann

Developer at Enrise

Member Since 5 Years Ago

Apeldoorn, The Netherlands

Experience Points
1,526,735
Total
Experience

0 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
1557
Lessons
Completed
Best Reply Awards
1942
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 50
1,526,735 XP
Oct
22
5 hours ago
Activity icon

Awarded Best Reply on V-model 2 Data Properties...

You can probably do something like this in your VueJS component:

<template>

    <div>
        <select name="customer" @change="onChange($event, $event.target.selectedIndex)">
            <option value="customer.id" v-for="(customer, index) in customers">
        </select>
    <div>

</template>

<script>

methods: {
    onChange(event, selectedIndex) {
        let customer = customers[selectedIndex];

        this.form.customer = customer.name;
        this.form.color = customer.color;
    }
}

</script>

Something like this should push you in the right direction ;)

Activity icon

Awarded Best Reply on Reducing Search Operations Using Laravel Scout And Algolia

Yeah, you can use an aggregator to combine results in the query. If you then search you get a mix of all the given models. You can find more about that here: https://www.algolia.com/doc/framework-integration/laravel/advanced-use-cases/multiple-models-in-one-index/?language=php

Caching is always a good idea if you have huge data sets and queries are getting slower. In your cache caching would speed up a lot, since you won't have to do the queries anymore. So in your case, you can do something like this

$result = Cache::remember('model-a', 900, function () {
    return ModelA::search('foo');
});

This will cache the results for 15 minutes because the number is in seconds. After 15 minutes the query will be performed again.

You can switch to another driver, but I think Algolia already offers all the features you need ;)

Activity icon

Replied to Send Mail To Real Email

@sirpoot I sometimes do, but then I get nightmares! Laracasts is the only thing that calms me down...

Activity icon

Replied to Reducing Search Operations Using Laravel Scout And Algolia

Yeah, you can use an aggregator to combine results in the query. If you then search you get a mix of all the given models. You can find more about that here: https://www.algolia.com/doc/framework-integration/laravel/advanced-use-cases/multiple-models-in-one-index/?language=php

Caching is always a good idea if you have huge data sets and queries are getting slower. In your cache caching would speed up a lot, since you won't have to do the queries anymore. So in your case, you can do something like this

$result = Cache::remember('model-a', 900, function () {
    return ModelA::search('foo');
});

This will cache the results for 15 minutes because the number is in seconds. After 15 minutes the query will be performed again.

You can switch to another driver, but I think Algolia already offers all the features you need ;)

Activity icon

Awarded Best Reply on Send Mail To Real Email

If you have an email created from cPanel you can use the SMTP settings for sending emails. By default, all these variables can be found in your .env file.

You can find all the other options in config/mail.php

Activity icon

Replied to Send Mail To Real Email

If you have an email created from cPanel you can use the SMTP settings for sending emails. By default, all these variables can be found in your .env file.

You can find all the other options in config/mail.php

Oct
21
1 day ago
Activity icon

Awarded Best Reply on Application Performance Monitoring

During development I mostly use the debugbar. This shows a lot of statistics about your app. For example the number of queries and which queries, the load time per page, which events are triggered and so on.

Laravel Debugbar: https://github.com/barryvdh/laravel-debugbar

For production I use NewRelic most of the time. This is a very powerful tool, but pretty expensive if you don't use it often. You can find more information about it here: https://newrelic.com/php/laravel

There are a lot of tools that I can recommend, but what kind of monitoring are you looking for? Maybe a combination of some free packages are already good enough for you ;)

Activity icon

Replied to Delete Duplicates Records From Large Laravel Collection

Aah sorry, that is the wrong table name! I updated by reply!

Activity icon

Replied to Loading Count Of An Extended Relationship

What do you mean by "not working as expected"?

I believe you can't do loadCount on an intermediate relationship. An alternative is adding likes through the replies to the posts model. We call that a hasManyThrough relationship. That should be possible.

Documentation: https://laravel.com/docs/5.8/eloquent-relationships#has-many-through

Activity icon

Replied to V-model 2 Data Properties...

You can probably do something like this in your VueJS component:

<template>

    <div>
        <select name="customer" @change="onChange($event, $event.target.selectedIndex)">
            <option value="customer.id" v-for="(customer, index) in customers">
        </select>
    <div>

</template>

<script>

methods: {
    onChange(event, selectedIndex) {
        let customer = customers[selectedIndex];

        this.form.customer = customer.name;
        this.form.color = customer.color;
    }
}

</script>

Something like this should push you in the right direction ;)

Activity icon

Replied to Using Another Method Of Same Controller Inside One Method Causing Error

Well, your code is really unreadable. Also doing 3 foreach loops in one method is really a bad practice. This makes your code really slow and unreadable as well.

What exactly is your use case? What are you trying to achieve?

Activity icon

Replied to Application Performance Monitoring

During development I mostly use the debugbar. This shows a lot of statistics about your app. For example the number of queries and which queries, the load time per page, which events are triggered and so on.

Laravel Debugbar: https://github.com/barryvdh/laravel-debugbar

For production I use NewRelic most of the time. This is a very powerful tool, but pretty expensive if you don't use it often. You can find more information about it here: https://newrelic.com/php/laravel

There are a lot of tools that I can recommend, but what kind of monitoring are you looking for? Maybe a combination of some free packages are already good enough for you ;)

Activity icon

Replied to Delete Duplicates Records From Large Laravel Collection

I think you can do it with just one raw query here

DELETE FROM table_name t1 
INNER JOIN table_name t2 
WHERE t1.id > t2.id 
    AND t1.relation_id = t2.relation_id
    AND t1.foo = t2.foo
    AND t1.bar = t2.bar;

I think this is a lot faster than loading everything into memory when using collections.

Another option is using the lazy load collections that have been added to Laravel 6.2.

Documentation: https://laravel.com/docs/6.x/collections#lazy-collections

Activity icon

Replied to Scout Get All Posts In Category

You can probably just fetch the category first and then use scout to fetch the posts based on the category id

$category = Category::find($id);

$posts = App\post::search('something')->where('category_id', $category->id)->get();
Oct
20
2 days ago
Activity icon

Awarded Best Reply on Validate Array Indexes

In general, you don't want to use the syntax for syncing models in your frontend and validate against that. I would strongly advise against using this syntax in your frontend.

However, you could do it with a custom rule that validates the whole array.

Oct
19
3 days ago
Activity icon

Replied to Validate Array Indexes

In general, you don't want to use the syntax for syncing models in your frontend and validate against that. I would strongly advise against using this syntax in your frontend.

However, you could do it with a custom rule that validates the whole array.

Activity icon

Replied to Better Solution For SQL Query

Well, the queries look pretty solid to me and they should be really fast. You can, for example, install the laravel-debugbar and see the performance per query. I assure you that the query is fast.

It will be slow if you have a lot of results and start looping over them. How many results do you get back?

Activity icon

Replied to How To Remove A Query String From An Url?

@nakov except returns an array of items that are added to the query of the URL. In this case that won't work because we generate the URL again.

Activity icon

Replied to How To Remove A Query String From An Url?

Yeah, it automatically merges with the previously selected query that was added to the URL. Another option is doing it yourself

return resource()->fullUrl() . '?' . Arr::query(['status' => 'published']);

This is still pretty clean ;)

Oct
18
4 days ago
Activity icon

Replied to Sync Does Not Copy All

Well, that is because the sync method requires you to be specific about the extra pivot field per item that you sync. Sync only takes the ID and that's id. The documentation should make this more clear with the given examples

Documentation: https://laravel.com/docs/6.x/eloquent-relationships#updating-many-to-many-relationships

Instead, you need to look over each value and attach the correct value including the.

$program->users->each(function ($user) {
    $new->users()->attach($user->id, ['type' => $user->pivot->type]);
});
Oct
17
5 days ago
Activity icon

Replied to Disable Unused Variable Error

I'm not an expert in this, but this should be the correct setup for this AFAIK.

Activity icon

Replied to Extending Package.json Within Laravel Package

In general, when you have a package that includes javasript you don't do anything with the javascript yourself as the end-user. The creator package builds the JS and minimizes it and that file is included in the package and loaded.

So I'm wondering what your use case is here with the Vue stuff that you need to add?

Activity icon

Replied to Disable Unused Variable Error

Your syntax is correct, but I think you use the wrong rule here. Shouldn't it be just no-unused-vars, without the vue part.

rules: 
    'no-unused-vars': 'off'
},
Oct
16
6 days ago
Activity icon

Replied to Trouble Using External Filesystem W/ Laravel (AWS-compatible One)

I think Laravel can't handle the wasabi driver here. Instead, it's better to use a package that supports the wasabi driver for Laravel: https://packagist.org/packages/probablyrational/wasabi-storage

Let me know if that works for you!

Activity icon

Replied to Laravel Queue Job Manually Run Without Php Artisan Queue:work Command To Send Email

Normally you have a tool like supervisor that keeps running your php artisan queue:work command. This way you don't have to call it yourself. For local development this isn't a good solution, you normally only do this on your server.

For local development I recommend you to set the driver to sync so the job is fired right away.

You can find more in the docs about this. It also mentions supervisor

Documentation:https://laravel.com/docs/6.x/queues#running-the-queue-worker

Activity icon

Replied to Passport

What do you think the tables are for?

Anyway, I recommend you to read the full passport documentation and then most tables will already make sense

Documentation: https://laravel.com/docs/6.x/passport

If you're still not sure how things work I would recommend you to read the documentation of the underlying league/oauth2-server package

Package: https://oauth2.thephpleague.com/

Activity icon

Replied to Validation In Laravel

I think your regex need to look like this

[-\d+*\/]

You can test it here: https://regex101.com/r/0jIYwc/1

Activity icon

Replied to Looking For A Admin Theme For An ERP Project.

@muhammadjaved I think all of these themes look pretty good. You just need to look into what they offer extra and what component you think you need ;)

Oct
15
1 week ago
Activity icon

Replied to Should Money Be Paid For Laravel?

Laravel is an open source framework. Which basically means it's completely free to use ;)

You might need to pay for the tooling around Laravel. For example, services like Laravel Forge or Laravel Nova. The framework and the usage of the framework itself is completely free.

Activity icon

Replied to What's Wrong With My Middleware?

No problem ;) It's awesome to help other people :D

Mmh your middleware should at least be called after the middleware that creates the session.

So how do you apply this specific middleware to your routes? In a group or only on a specific route?

Activity icon

Replied to Get Children On Custom Component

If you give your children a reference you should be able to get information from them. Here is an example: https://stackoverflow.com/questions/42814406/accessing-nested-child-components-in-vuejs

Activity icon

Replied to Messaging Like Facebook

Probably one channel is already good enough for all the notifications for a specific user. You could consider adding an extra channel for each chat as well so you can show results in there as well. However, one channel should be good enough.

Activity icon

Replied to How To Create Fake Blog Content With Html Code And Not Real Text In Faker

If htmlLorem is not doing what you want, then they're not much alternatives.

An option is to remove all tags from the generated htmlLorem text and use that.

Personally I would generate some HTML files and use file_get_contents to randomly pick one of those files and pass them to your model in the factory. This way you get your custom HTML and it can still be randomlyish.

Activity icon

Replied to Scaling Laravel Scout

Well, you can't share it without moving it to its own server. It's really hard to keep all servers in sync based on the given data. Keeping your servers in sync with all the data in a completely different challenge if you ask me!

So your best option is to store it on a separated server using a certain storage driver. I believe you can configure a storage driver, so that should actually work.

Activity icon

Replied to Add Value

Your component doesn't know the user object, so this.user is never going to work. Instead, you can set the global object in the window and then you should be able to access it.

window.user = [YOUR OBJECT HERE]

// Selec the customer_id
windows.user.customer_id

Note that this is not a good practice. If you want to share data between component you either need to pass the data to those components or use something like vuex to share a certain state!

Activity icon

Replied to What's Wrong With My Middleware?

I don't see much strange things here. However, I did notice that you use Cache::get('currencies') everywhere. What happens if that doesn't return anything. At this point it will never set any value.

I would expect something like this

$currencies = Cache::remember('currencies', 60 * 60 * 24, function () {
    Currency::updateExchangeRates();

    return Currency::where('is_active', '1')->get();
});

if (!$request->session()->has('preferred_currency')) {
    $currency = $currencies->where('is_active', '1')->where('code', $geoCurrencyCode)->first();

    if (!$currency instanceof Currency) {
        $currency = $currencies->where('code', 'USD')->first();
    }

    if ($currency instanceof Currency) {
        session(['preferred_currency' => $currency]);
    }
}

return $next($request);

Well you get the idea ;) Let me know if this makes sense to you.

Activity icon

Replied to Storage

@davy_yg Well no, normally this is an incoming string from a form or the contents of an image. For example

Storage::put('file.jpg', Storage::get('file2.jpg'));

This is basically copying an image. Bu Storage::get returns the string representation of that image. You can try that out yourself :)

Activity icon

Replied to Storage

You won't enter your own text in there and convert it to an image. That doesn't make any sense.

However, HTTP can only send text over the line and not actual images. So that's why there is a conversion from image to text and then from text to image.

Activity icon

Replied to AssertContains() Url: Testing Best Practice

Yeah, of course, that should have been double quotes :see_no_evil:

Activity icon

Replied to Scaling Laravel Scout

Well, that is very challenging. When scaling your application you need to keep a few things in mind. Your data need to be accessible from different servers or locations. For example, your database can't run on one server anymore, it's better if it runs on its own server so you easily access it. The same goes for the storage of your indexes. You need a setup that works like Algolia or ElasticSearch where you store your indexes on a different server and you can access it there from all the other servers.

So in this case you need to centralize the data of your indexes to make it work in a scalable setup.

Activity icon

Replied to Composer Command

The command regenerates the list of all classes that need to be included in the project (autoload_classmap.php).

In Laravel the autoload_classmap.php also includes the providers in config/app.php. So when run this command your providers are being registered again.

Activity icon

Replied to New Laravel

It's probably because of your current PHP version. I bet you're still running on PHP 7.1 locally. However, Laravel 5,8 and 6.x require you to use PHP 7.2 or higher. If you update your PHP version it should update the latest version of the framework for you ;)

Activity icon

Replied to Data Format Issue In Mysql

Well, before you insert it in the database you need to convert it so it's in the correct format. You can do the conversion yourself in either the frontend using momentjs or using Carbon in your PHP backend.

Using Carbon it will be handled automatically for you:

$date = Carbon::createFromFormat('dd/mm/yyyy', $date);
Activity icon

Replied to Storage

Well, an image is actually text. If you would open an image in an editor you would only see text characters and special characters. This is based on the type of image you have of course.

Whenever you upload a file it's being sent as text as well over the line.

Take a look at these examples: https://www.php.net/manual/en/function.imagecreatefromstring.php

Oct
14
1 week ago
Activity icon

Replied to How To XML Data Convert To Php Object

Well, look at the error... Your data is an array and not a string. Also looking at your data it looks more like XML in JSON...

Can you show your code for this?

Activity icon

Replied to How To XML Data Convert To Php Object

You can use the simplexml_load_string method for that

Documentation: https://www.php.net/manual/en/function.simplexml-load-string.php

Activity icon

Replied to Laravel Fixed Next Version?

This depends on the MySQL database version you're using. Also from the same article:

This only affects new applications and as long as you are running MySQL v5.7.7 and higher you do not need to do anything.

Sadly, if you're running MariaDB you need to keep fixing this.