bobbybouwmann

bobbybouwmann

Member Since 4 Years Ago

Apeldoorn, The Netherlands

Developer at Enrise

Experience Points 1,253,025
Experience Level 50

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 1434
Lessons
Completed
Best Reply Awards 1519
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

20 Feb
15 hours ago

bobbybouwmann left a reply on What Are The Contracts For User Model For?

For example the CanResetPasswordContract makes sure some methods needs to be there right? So an interface makes sure you need to have a set of methods in that class. The traits below that, for example CanResetPassword has the methods that the CanResetPasswordContract wants to have.

Also the interfaces are used to check if the user can perform a certain action. If we continue with the password reset, if the user model does not have the CanResetPasswordContract interface it can't reset the password because the correct methods are not available.

Does this make it clearer for you?

bobbybouwmann left a reply on Security And Pentesting

I have a huge list of security things, but let me list a few things down here for you!

Of course you need to use the CSRF functionality that comes by default in Laravel, so never ever disable that middleware for the web requests.

Your api requests should always be behind some security. Either a token or authorization header.

Make sure that you only have up-to-date assets in your public directory. Sometimes an old javascript library has some exploit and if that is still in the public directory everyone can still use that. So it's important to keep the public directory clean with only the useful data. This may lead to Cross Site Scripting.

By default the session cookie of Laravel is prefixed with laravel, so people already know you use Laravel and if there is a known exploit they can use that against you

// config/session.php

'cookie' => env(
    'SESSION_COOKIE',
    Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
),

You can also enable session encryption in that same file, which should be saver ;)

// config/session.php

'encrypt' => false,

Always show a success message when resetting a password or requesting a password reset. Sometimes you get messages like "We don't have this username in our database". But if there is always a success message you never know if the username exists in the system or not.

Since I've been using Laravel, I never had any troubles application wise. However server security is a whole other thing. It happens sometimes that you get a DDOS and that kind of stuff, but that is never on application level.

You should never publish a vulnerability unless the party involved isn't doing anything about it. You should always directory contact the owner of the application to let them know about the flaw to fix it. Providing as much context as possible is helping most of the time.

Let me know if this helps you in anyway ;)

19 Feb
1 day ago

bobbybouwmann left a reply on A Suitable Project For Object-oriented PHP

An ATM application is cool to build, but indeed you can't really put that into real life

Start with a blog, that is the easiest way to get started. You will need to learn the fundamentals of the MVC pattern. Also you can build an admin panel to manage the content of your site.

If you get the hang of the blog you can for example create a small shop where you can order items. You don't even have to build in the payment stuff. When building a webshop you have to think about relations between objects and so on.

Another option would be to automate something in your life. For example a todo list or a schedule for your local sport club and so on.

bobbybouwmann left a reply on Edit() And Destroy() Functions Not Working On Shared Hosting

Do you use the same database? The same database engine? You should probably looking into that direction!

bobbybouwmann left a reply on Edit() And Destroy() Functions Not Working On Shared Hosting

@arthvrian @mvpop Both Auth::user()->id and $post->user_id should by default return an integer so the !== shouldn't be a problem as well!

This is really weird behaviour...

bobbybouwmann left a reply on Add Meta Tag Dynamically For Each Product

You need to add this depending on the data that is showing on that page. So your code is working perfectly, except you don't have to loop over all images. You already have this data available!

bobbybouwmann left a reply on How Can I Print This Pdf Using Dompdf

filename is not an extra key in the array. It belongs to the Content-Disposition key. If you look carefully to my example you can see that there as well!

return new Response($output, 200, [
    'Content-Type' => 'application/pdf',
    'Content-Disposition' =>  'inline; filename="'invoice.pdf"',
]);

bobbybouwmann left a reply on Testing Connected Methods

Well what are you actually testing here? If you use the preg_match in both your code and in the test you're not testing anything. If you you made a mistake in the regular expression you still end up with the wrong.

What you really want to test is something like this

public function a_user_can_create_a_video()
{
    $this->withoutExceptionHandling();
    $this->actingAs(factory('App\User')->create());

    $attributes = [
        'url' => 'https://www.youtube.com/watch?v=wlsdMpnDBn8'
    ];
    
    $this->post('/videos', $attributes);

        $this->assertDatabaseHas('videos', ['url' => 'wlsdMpnDBn8']);
}

Now you're actually testing two methods here. First of all you test the post action to see if you can store the data. FInally you also test the regular expression.

Let me know if this works for you!

bobbybouwmann left a reply on Error Migrations: Cannot Declare Class X, Because The Name Is Already In Use

composer dump-autoload
php artisan optimize:clear
php artisan clear-compiled

bobbybouwmann left a reply on How To Access Files And Image Stored Outside Public Folder

You can't indeed access them from there. So you should either use an endpoint for that to get to those images. Just like my previous reply you can use that same url to access that file in your views or components.

Let me know if you need an example!

bobbybouwmann left a reply on Error Migrations: Cannot Declare Class X, Because The Name Is Already In Use

Did you try composer dump-autoload -o?

Also this error only happens whenever you create a new class with the same name, this shouldn't happen if you don't create another class with the same name.

Also clearing all caches might help ;)

bobbybouwmann left a reply on Edit() And Destroy() Functions Not Working On Shared Hosting

Well this happens because of your redirect

if (auth()->user()->id !== $post->user_id) {
    return redirect('/articles')->with('error', 'Unauthorized Page');
}

It seems that the edit page is redirecting you to /articles in my browser. I can also see that in the developers console

Request URL: http://mvpop.co.uk/articles/41/edit
Request Method: GET
Status Code: 302 Found
Location: http://mvpop.co.uk/articles

So I think the user is not the created of that post. Maybe something goes wrong there?

Also it seems that you do send a session value in the form of error to the view, but you never display anything!

Let me know if this helps you out!

bobbybouwmann left a reply on Error Migrations: Cannot Declare Class X, Because The Name Is Already In Use

You already have a migration with that same class name. So if your search in your project for CreateRolesTableyou should find multiple classes, you can only have one of them ;)

The reason that you get this error is because the migration classes don't have a namespace and there need to be unique!

bobbybouwmann left a reply on File Folder Permissions On Remote Server

The folder should already have the correct permissions when downloading a file. You can't change that during a request ;) That would make the internet really unsafe!

bobbybouwmann left a reply on Laravel Routes

@bestmomo You don't have to use route:list, but maybe the same format to see what kind of routes you have created ;)

18 Feb
2 days ago

bobbybouwmann left a reply on How To Do This Better

Well it depends on your style of programming. In general I find sprintf more readable then doing everything in one string. It's up to you ;)

bobbybouwmann left a reply on How To Do This Better

You can use sprintf to clean this up a little bit ;)

public function imageUrl($region, $bucket, $directory, $file) 
{ 
    return sprintf(
        'https://s3.%s.amazonaws.com/%s/%s/%s',
        $region,
        $bucket,
        $directory,
        $file
    );
}

Does this help you?

bobbybouwmann left a reply on Laravel Routes

Looking fancy! I think it still needs some love on UX, but the idea is pretty cool!

Some thoughts I have while using it:

  • Would be cool if it would generate the Controllers as well with the methods (if they are configured)
  • It now generates the laravel output, but maybe the php artisan route:list output would give a good overview as well
  • Maybe some extra templates or helpers would be nice. Maybe some common examples that you can view or reuse

Anyway! Keep up the good work :D

bobbybouwmann left a reply on Validation Question

You can use an array instead as well

return [
    'email' => ['required', 'email', Rule::exists('email')],
]

Let me know if that works for you ;)

bobbybouwmann left a reply on Add Meta Tag Dynamically For Each Product

So this doesn't really work that way. A page can only have one og:image object. So if you want an image on the homepage of your app you either need to pick a product or use the logo of your site.

On the single product page you can use the og:image for a specific product. That's the only way that works.

Let me know if that helps you!

bobbybouwmann left a reply on How To Show Images In Vue Component?

Mmh, not sure if this path works because it's a path to some other directory. Normally you would bind the full url to the image to the component. The component can be run on any page and right now you have a fixed path which will not work if you have more items in your url like example.com/users/ etc.

Als if you find it like this you need to set a property and not a data attribute, but I guess you already know that.

This might help as well: https://stackoverflow.com/questions/45880956/how-to-use-img-src-in-vue-js

bobbybouwmann left a reply on Route Error

Well the problem here is that $username can be nullable, but the callback doesn't know that! So instead you need to do this

Route::get('/username/{username?}', function ($username = null) {
    return 'Hello ' . $username;
});

That should fix it ;)

bobbybouwmann left a reply on Help Im Stuck

Hi,

Well this normally happens when you run php artisan down. It basically means you put your application in maintenance mode. The app\Http\Middleware\CheckForMaintenanceMode.php class is taking care of this for you.

You can fix this by simply running php artisan up.

Let me know if that fixes it for you ;)

bobbybouwmann left a reply on Laravel Artisan Inspire

Well Laravel actually uses a facade to get to the local behind it. So in your routes/conosle.php you have this

Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->describe('Display an inspiring quote');

Which is effectively calling this class in Laravel: https://github.com/laravel/framework/blob/5.7/src/Illuminate/Foundation/Inspiring.php

So just a random item is returned from this collection, that's it ;)

bobbybouwmann left a reply on Page Expiration - Laravel Dusk

Are you sure both have exact the same content? Normally you get this exception when you wait for an element which never appears. So either a button click is not doing anything or some popup is not showing when you expect one to show up!

bobbybouwmann left a reply on How To Structure Media Folder Similar To Dropbox

This is what you're after: https://laraveldaily.com/laravel-upload-file-and-hide-real-url-for-secure-download-under-uuid/

This tutorial is focused on downloading files, but instead of downloading the file you can also just return the file in the browser using a different response.

This way the url doesn't say anything about the path and your files are save!

Also remember that whenever you use the symlink folder for public you should know that everyone can access those files by guessing the url. So ideally you don't want to use that directory for files that shouldn't be public!

17 Feb
3 days ago

bobbybouwmann left a reply on NPM Install Laravel-Mix Gives Error: “Maximum Call Stack Size Exceeded”

Did you try one of the following work arounds?

npm cache clean --force

npm rebuild -g 

rm -rf node_modules &&  npm install

bobbybouwmann left a reply on Passing Data To Verification Email On Notification Email Laravel 5.7

The MustVerifyEmail trait is sending the email for you in the User model. You can override the sendEmailVerificationNotification method. By default the $user object will be passed to this notification class.

// This is the default behaviour
public function sendEmailVerificationNotification()
{
    this->notify(new Notifications\VerifyEmail);
}

You can either create your own notification class or send a normal email. That is up to you ;)

bobbybouwmann left a reply on Npm Install Maximum Call Stack Size Exceeded ??

I have no clue of what it could be. Installing a new project from scratch works fine for me!

16 Feb
4 days ago

bobbybouwmann left a reply on Npm Install Maximum Call Stack Size Exceeded ??

Try below commands

// Clean your cache
npm cache clean --force

// Rebuild npm
npm rebuild

// Reinstall node_modules
rm -rf node_modules
npm install

bobbybouwmann left a reply on Npm Install Maximum Call Stack Size Exceeded ??

Here is a full list of things you can try: https://stackoverflow.com/questions/40566348/maximum-call-stack-size-exceeded-on-npm-install

Normally just cleaning up the cache works! Also deleting your node_modules directory and running npm install again helps most of time.

bobbybouwmann left a reply on Validation With Lumen.

So basically this is important information for you from that documentation page at the bottom

Lumen does not support sessions out of the box, so the $errors view variable that is available in every view in Laravel is not available in Lumen. Should validation fail, the $this->validate helper will throw Illuminate\Validation\ValidationException with embedded JSON response that includes all relevant error messages. If you are not building a stateless API that solely sends JSON responses, you should use the full Laravel framework.

bobbybouwmann left a reply on Laravel Job Doesn't Get Scheduled With Delay()

@arximughal So during development you should never cache your config because this might give you problems with changing .env values and not seeing any changes ;)

bobbybouwmann left a reply on Determine Date Of Birth From Dates/ages

This is not just a simple date method anymore :P

To make it easier I would probably start collecting some information first. You can for example determine first the average age of the given dates. Based on that you can already termine the correct year right.

To get the average date (day + month) I would probably first set the same year for all dates. Then I would start determining the difference between the days of these dates. Based on this you can also determine an average date just like the years.

I don't have any code right now, but I can help you brainstorm this idea ;)

15 Feb
5 days ago

bobbybouwmann left a reply on Laravel Job Doesn't Get Scheduled With Delay()

Are you sure your config wasn't cached? Forcing it to go to the database connection is not a best practise when something doesn't work as expected!

bobbybouwmann left a reply on How Do We Turn Event Handling Back On For Test After ->withoutEvents?

well it's basically replacing the implementation in the container to do that. So you can either replace it back with the correct implementation which should work just fine

Code: https://github.com/laravel/framework/blob/892b2cef309ea86cc110f7c153e81474eb1b2a35/src/Illuminate/Foundation/Testing/Concerns/MocksApplicationServices.php#L92

An another alternative would be to use a seperate test class that doesn't have this in the setUp method or moving the withoutEvents to the tests that actually need it!

bobbybouwmann left a reply on Please Change Or Remove The "Memoize" Video

@tkrajacic Don't make this a huge point man. You're spamming Jeffrey on this, while he is doing his best as he can. If you can do better write a tutorial or make a video and publish it ;)

I'm not into this terminology and you might be right, I simply don't know at this point. But public shaming like this doesn't help anyone! Think before you post these kind of messages!

bobbybouwmann left a reply on Dompdf In Laravel

You need to use loadView here instead of `loadHtml

$pdf = \PDF::loadView('orders.show', $order);

Source: https://github.com/barryvdh/laravel-dompdf#using

bobbybouwmann left a reply on Laravel Job Doesn't Get Scheduled With Delay()

What driver are you using? The delay only works with the redis, database, beanstalkd and sqs driver. When you have it set to sync it won't queue the job for you and fire it off right away!

bobbybouwmann left a reply on Condition Inside Query Builder

I don't really undestand your question, but you can do this

Job::where('disabled_hub', '=', '0')->with([
    'positions' => function ($queryPositions) {
        $queryPositions->where('queryPositions', '=', '10') );
    }, 
    'locations' => function ($queryLocations) {
        queryLocations->where(''region', 'US');
    }
])->get();

Or in your case a whereHas makes more sense

Job::where('disabled_hub', '=', '0')->with(['positions' => function ($queryPositions) {
    $queryPositions->where('queryPositions', '=', '10') );
}])->whereHas('locations', function ($queryLocations) {
    queryLocations->where(''region', 'US');
})->get();

bobbybouwmann left a reply on Syncronous Queue Not Running Failed() Method, Or Adding To Failed_jobs

Oow yeah, that makes perfectly sense! Glad you fixed it :D

14 Feb
6 days ago

bobbybouwmann left a reply on Condition Inside Query Builder

The query below should give you all the jobs that have disabled_job set to 0 and also where the options column of positions is set to 10

 $jobs = Job::where('disabled_job', '=', '0')->whereHas(['positions' => function ($query) {
    return $query->where('option', '=', '10');
});

bobbybouwmann left a reply on DevDependencies Vs Dependencies

With webpack basically all your dependencies can be in the devDependencies. The reason for this is that you use webpack to compile everything done to a single file (js/app.js). So your browser only needs that js/app.js file and the rest is not needed. However you do need it to compile everything done to a single file. So just devDependencies should be good enough ;)

bobbybouwmann left a reply on Syncronous Queue Not Running Failed() Method, Or Adding To Failed_jobs

MMh that sounds odd. As far as I know it should work out of the box!

To be sure I would try to use a different driver. For example the database driver. You can easy set that up by running the following commands

php artisan queue:table
php artisan queue:failed-table
php artisan migrate

After you've updated the driver to database you should be able to see the jobs in the jobs table. You then need to run php artisan queue:work and all jobs in the jobs should be executed.

Let me know if that works for you! If not there might be a different problem.