bobbybouwmann

bobbybouwmann

Developer at Enrise

Member Since 5 Years Ago

Apeldoorn, The Netherlands

Experience Points
1,789,395
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
1661
Lessons
Completed
Best Reply Awards
2348
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 50
1,789,395 XP
May
27
1 day ago
Activity icon

Replied to Scheduling Multiple Notifications Per User Per Event

I don't really think there is a pattern available for this in Laravel itself.

The basic idea is that you indeed "schedule" a notification using the delay method. Whenever the notification was fired you simply schedule it again for the other two weeks.

Another solution is running a cronjob that checks every minute if a certain notification should be fired. So let's say you have a concert in your database that is happening on the 1st of June. Now someone subscribes to this event and wants a notification 3 days beforehand. You can create a notify table in your database that holds a link to the event and user and the number of minutes before it should fire the event. With the cronjob you can then determine which notification should be sent.

In the end, you need to make a custom solution for this.

May
26
2 days ago
Activity icon

Replied to Dublicate Query When Use SESSION_DRIVER=database

What Laravel version are you using?

Anyway, you're not the only one with this issue. It seems to happen in the StartSession middleware and I don't think you can do anything about it

Source: https://stackoverflow.com/questions/56368161/why-laravel-5-8-makes-repeated-queries-to-the-database-when-working-with-the-ses

Activity icon

Replied to Series Request: Comprehensive Series Covering Uploaded Files

I guess you're right, but in the defense of the Laravel community there are a lot of tutorials out there. Also the Laravel documentation itself has some solid examples on how to handle it. Most of the question you ask right now is not much different than submitting a text input to your controller, except that you need to store the file itself and the file path.

Activity icon

Replied to Nginx: [emerg] BIO_new_file("/etc/letsencrypt/live/test.site2.net/fullchain.pem") Failed (SSL: Error

I don't see anything strange. Is this path correct? root /var/www/html/site1test;

May
25
3 days ago
Activity icon

Replied to Nginx: [emerg] BIO_new_file("/etc/letsencrypt/live/test.site2.net/fullchain.pem") Failed (SSL: Error

Did you set the correct directory path that is connected to the correct host insite2.conf?

Activity icon

Replied to How To Copy The Content Of My Project Folder To Another Folder In Ubuntu

You can use this cp /var/www/html/site1 /var/www/html/site2

Activity icon

Replied to Replacing Parts Of Strings Via Checkboxes In Blade File

A check box is only sent when it's checked, so instead, you check if the key is submitted in the form or not

if (has 'pid' && $request->has('license_civ_driver') === true) {
    // Do something here
} else if (has 'pid' && $request->has('license_civ_driver') === false) { 
    // Do something here
}
Activity icon

Replied to Laravel Echo - .listen() Callback Not Firing When Using Basic Socket.js

That's very odd indeed. It should probably be a server configuration. Maybe it was running on a different port?

Activity icon

Replied to Flash Data Not Being Written To Session

Can you show your controller and view? How you set the session and display it?

Activity icon

Replied to Hey Error In Laravel Livewire Script Url Link In Wrong

I have no clue what you're talking about. Can you give some more context?

Activity icon

Replied to When Generating Auth Scaffolding, Is There A Way To Not Have Any VUE Code?

Yeah, it always generates the JS. You need to manually remove it indeed.

Activity icon

Replied to Laravel Echo - .listen() Callback Not Firing When Using Basic Socket.js

Your code looks correct to me. Are you sure you compiled your javascript before you loaded it in the browser?

Activity icon

Replied to Extend Str Helper

@honzahana This works

use Illuminate\Support\Stringable;

Stringable::macro('removeSpaces', function () {
    return new Stringable(preg_replace('/[\s]+/u', '', $this->value));
});

(string) Str::of(' test ')->removeSpaces();
Activity icon

Awarded Best Reply on Using Custom PasswordRequest Rule In PasswordReset

You need to override the rules method in the ConfirmPasswordController. (At least that is what the controller is called now with the new UI package for Laravel). This class uses a trait that adds this functionality. In your controller that returns the reset page, you need to specify the rules method with your own rules and you're good to go ;)

You can find the original content here: https://github.com/laravel/ui/blob/2.x/auth-backend/ConfirmsPasswords.php

Activity icon

Awarded Best Reply on How To Reuse The Same Function In Multiple Policy Files

You have three options here.

  1. You can create a base class and let every Policy class extend that base class. Then you can decide if you want to call this method or not
  2. You can create a helper file with a global method that performs this check. Check this out for that: https://laravel-news.com/creating-helpers
  3. You can create a trait that holds this method. You can then include the trait in each of your policies where you need it.
Activity icon

Replied to Audit Trail

I personally like Laravel Activity Log very much, but it might miss functionalities you need that some other package can offer you.

Depending on your use case you need to decide which package you want to use. Double-check the requirements you need and based on that use the package that fits the best

Activity icon

Replied to How To Reuse The Same Function In Multiple Policy Files

You have three options here.

  1. You can create a base class and let every Policy class extend that base class. Then you can decide if you want to call this method or not
  2. You can create a helper file with a global method that performs this check. Check this out for that: https://laravel-news.com/creating-helpers
  3. You can create a trait that holds this method. You can then include the trait in each of your policies where you need it.
May
24
4 days ago
Activity icon

Replied to Dropzone Upload Paths And Name Attributes.

You can create the path in your PHP code, just like you do now. You just need to make sure the path is unique for each file.

I'm not sure what the current problem is you're trying to tackle.

Activity icon

Replied to Dropzone Upload Paths And Name Attributes.

The best way to solve this is either storing the path in the database or storing a model in the database and connect that to the model.

May
23
5 days ago
Activity icon

Awarded Best Reply on After Upgrade Laravel 6 To 7 Why Psr4 Composer Warning

This is not an error, but a warning.

The problem here is probably that the file path doesn't match the namespace. This is what PSR-4 is about.

Your UserManagementController class is in the Authenticated namespace, but the file is in the Dashboard path. You either need to update the namespace, or move the file to the correct directory.

Activity icon

Awarded Best Reply on Xdebug N+1 71 Duplicate Queries - Lazy Eager Loading

The problem lies in this part $this->orders(). Because you use () it will always perform a new query. Instead, you can load all the orders on the current model and use the collections methods to get the correct data.

// Some model class
class MyModel extends Model
{
    public function orders()
    {
        return $this->hasMany(Order::class);
    }
}

// Your Order model class
class Order extends Model
{
    public function getIsTrialAttribute()
    {
        // $this->orders is now a collection
        return $this->orders->where('status', 'paid')->isEmpty();
    }

    public function getLastExpiresPlanAttribute()
    {
        return $this->orders->where('status', 'paid')
            ->where('end_at', '<', now())
            ->sortByDesc('end_at')
            ->first();
    }
}

// In your controller
$myModels = MyModel::with('orders')->get();

foreach ($myModels as $myModel) {
    $myModel->lastExpiresPlan;
    $myModel->isTrial;
}

You will see that now only 2 queries will be performed ;)

There is another solution here, which is creating a different relationship for your specific get attribute methods. I think above solution is good enough for now.

Let me know if anything is unclear ;)

Activity icon

Awarded Best Reply on Need Help With Table Relationships.

There are different ways of solving this, but it also depends on how you want to display it.

You can retrieve all the data starting from messages instead of the user. Something like this

Message::with('customer.store.user')
    ->whereHas('customer.store.user' => function ($query)  {
        return $query->where('users.id', auth()->user()->id;
    })->latest()->get();

Let me know if that is an option for you.

Activity icon

Replied to Using Custom PasswordRequest Rule In PasswordReset

You need to override the rules method in the ConfirmPasswordController. (At least that is what the controller is called now with the new UI package for Laravel). This class uses a trait that adds this functionality. In your controller that returns the reset page, you need to specify the rules method with your own rules and you're good to go ;)

You can find the original content here: https://github.com/laravel/ui/blob/2.x/auth-backend/ConfirmsPasswords.php

Activity icon

Replied to After Upgrade Laravel 6 To 7 Why Psr4 Composer Warning

This is not an error, but a warning.

The problem here is probably that the file path doesn't match the namespace. This is what PSR-4 is about.

Your UserManagementController class is in the Authenticated namespace, but the file is in the Dashboard path. You either need to update the namespace, or move the file to the correct directory.

Activity icon

Replied to Dropzone Upload Paths And Name Attributes.

This is the code you've written, right? I get the feeling you're changing something in an existing application.

I'm also not sure what your followup question is at this point. What is not working for you?

Activity icon

Replied to Difference Between Command And Jobs

Yeah both solutions work.

I personally like to create separate service classes for this kind of functionality. They also live in the App\Services namespace. These classes can perform simple or complex actions, but remove the complexity in your controllers and other parts of the application. You can for example use a service inside your job class to calculate something. Makes perfect sense ;)

Activity icon

Replied to Dropzone Upload Paths And Name Attributes.

Oin your case you need to store the image connected to each post. In that case, you need access to the post as well. You probably want a path like app/public/images/posts/1/avatar.png. So your image controller also needs this information. You can send it along in the URL using route model binding or you can send it as extra information in the dropzone config.

From there it's generating the correct path and you're good to go ;)

Activity icon

Replied to Generate Multiple Excel Files By Using Laravel Excel Package

It is possible to export it to a CSV, but the zip part is not possible. You need another library for that

CSV: https://docs.laravel-excel.com/3.1/exports/export-formats.html#csv

ZIP: https://github.com/Ne-Lexa/php-zip

Activity icon

Replied to Git Push Heroku Master Not Working

Well, what is the error that composer gives you?

Activity icon

Replied to How To Insert Multiple Row Images Using Js?

The problem is that you're trying to get the file twice from the request. Try this instead

$files = $request->file('receipt_upload');
$uploads = [];

foreach($files as $file)
{
    $name = time() . $file->getClientOriginalName();

    $file->move(public_path('uploads/receipt'), $name);  

    $uploads[] = "public/uploads/receipt/{$name}";
}

$uploads; // You can now do something with this data. For example, store it in the database.
Activity icon

Awarded Best Reply on Prevent Other Listeners During Tests

Right now it's not possible to not call the other listeners. They are part of the event. You can check if they have been fired as well right?

What are the other listeners doing that you don't want to test them?

Activity icon

Replied to Laravel Forge - Why Is It So Expensive?

Most SaaS up their prices after some time. This is because they added more features and the demand is high.

I think the $19 dollar is a fair price for what you get. However, it depends on how you use it. If you only have 3 servers it might be a bit expensive. If you have 20 servers it's less than a dollar per server.

Also, the value of a service like this is expressed in the time you don't have to stuff yourself. Can you set up a new server and maintain it as fast as Forge can? If so, feel free to do it yourself.

Activity icon

Replied to Git Push Heroku Master Not Working

It looks like you didn't run composer install or something is going wrong with that command.

Activity icon

Replied to What Are The Best Practices For Api Authentication For B2B?

I believe Passport doesn't offer that by default, but you can change the value of the expiration date in the database.

DB::table('oauth_access_tokens')
    ->where('id',$token->token->id)
    ->update(['expires_at'=>Carbon::now()->addDays(1)]);

Something like that should work in most cases ;)

Activity icon

Replied to Need Help With Table Relationships.

There are different ways of solving this, but it also depends on how you want to display it.

You can retrieve all the data starting from messages instead of the user. Something like this

Message::with('customer.store.user')
    ->whereHas('customer.store.user' => function ($query)  {
        return $query->where('users.id', auth()->user()->id;
    })->latest()->get();

Let me know if that is an option for you.

Activity icon

Replied to What Are The Best Practices For Api Authentication For B2B?

Laravel Passport offers different ways to authenticate. For B2B I would probably use the Password Grant Client approach

So the party that integrates get's the client_id and client_secret. They can use that to retrieve an access_token and refresh_token. They can use it until the token is expired and then they need to request a new token.

Documentation: https://laravel.com/docs/7.x/passport#password-grant-tokens

Activity icon

Replied to Jquery In Laravel

jQuery is javascript. You need to add it to the HTML. With Laravel this means you need to add it to your blade views or include a separate javascript file. In theory you can do it in your controller, but it's not recommended.

Activity icon

Awarded Best Reply on Mysql Qurey To Laravel Qurey Like %% Problem

THat's because of the quotes. Replace the quotes around your query with "

DB::select(DB::raw("SELECT tmsid, RIGHT(tmsid,6) as max_number FROM tms_tables WHERE tmsid=(SELECT MAX(tmsid) FROM tms_tables where tmsid LIKE '%1001%' )"));
Activity icon

Replied to Getting Warning When Composer Update Or Composer Install

As the warning says, the package is abandoned. Probably one of your dependencies is still relying on this package. You can see which package that is by running composer why jakub-onderka/php-console-highlighter.

In most cases, upgrading everything to the latest version should fix this. This is not something you can fix on your side, because it's a sub dependency.

Activity icon

Replied to Mysql Qurey To Laravel Qurey Like %% Problem

THat's because of the quotes. Replace the quotes around your query with "

DB::select(DB::raw("SELECT tmsid, RIGHT(tmsid,6) as max_number FROM tms_tables WHERE tmsid=(SELECT MAX(tmsid) FROM tms_tables where tmsid LIKE '%1001%' )"));
May
22
6 days ago
Activity icon

Replied to Laravel Component Not Recognising My Variable.

You don't assign the array to the flash key. Try this instead

->with('flash' => [
    'color' => 'green',
    'title' => $sucess_title,
    'body' => $sucess_body,
]);
Activity icon

Replied to Variables And Bulma-Extension

You need to import the variables firs before you can do that. Check this out: https://versions.bulma.io/0.7.0/documentation/overview/customize/

Activity icon

Replied to Cannot Add New Package To Laravel Project

Did you read my previous message? There is an incompatible dependency between some packages in your composer.json right now. Because of that, it can't install anything.

You need to revert back your changes and start from what you had before and make one change at the time and see if you can still run composer install. It works best if you run composer update per package like composer update laravel/framework.

Activity icon

Replied to Difference Between Command And Jobs

Cool! Well, you know where to find us if you have more questions ;)

Activity icon

Replied to Laravel - My NGINX Suddenly Becomes Inactive In Ubuntu

Check /var/log/nginx/error.log

Activity icon

Replied to Cannot Add New Package To Laravel Project

If you get this message Your requirements could not be resolved to an installable set of packages you have an incompatible version conflict between packages.

You first need to fix the first issue which is the composer.lock file. If nothing works you can always delete this file and simply run composer install and see what happens. Make sure you don't make any changes in your composer.json. If the composer.lock file is good again you can update each package separately.

Activity icon

Awarded Best Reply on Difference Between Command And Jobs

So let's say you have a job that calculates the number of experience points of a user and sets that in the database. This is a reusable action inside your code. A job is perfect for this. Let's call this class CalculateExperience

Whenever the user signs up you fire an event that says UserWasRegistered. No you can add a listener called UpdateExperience. This listener itself doesn't have to update the points. It can simply fire the CalculateExperience job in that listener instead of redefining the logic.

Whenever someone likes a certain page, the experience should be updated as well. You can decide to use an event and listener again, but you can also decide to fire off the job in the controller. It depends on the context in this case.

Using jobs vs events really depends on your use case. In some cases, you can use both of them but in smaller application it mostly makes sense to pick one of them and stick to do.

Do you have a use case of your code where you can't decide between a job or an event/listener?

Activity icon

Replied to Laravel - My NGINX Suddenly Becomes Inactive In Ubuntu

Did you check the Nginx logs? Maybe there is an issue. Could be something running on the same port