bobbybouwmann

bobbybouwmann

Member Since 4 Years Ago

Apeldoorn, The Netherlands

Developer at Enrise

Experience Points 1,395,175
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 1487
Lessons
Completed
Best Reply Awards 1731
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.

18 Jul
20 hours ago

bobbybouwmann left a reply on Composer Install Laravel 5.8.17 Instead 5.8.29

The laravel/framework repository is at version 5.8.29, but the laravel/laravel repository is at version 5.8.17!

So it's still downloading 5.8.29 for you, but that is a dependency of laravel/laravel ;)

17 Jul
1 day ago

bobbybouwmann left a reply on Call To Undefined Relationship [user] On Model [App\Quote].

Your relationship is called users, but you reference user in your blade file. You should rename your method of the relationship to user, that should fix it ;)

15 Jul
3 days ago

bobbybouwmann left a reply on Laravel In GCP With Forge

@bgweb Awesome! I didn't know that!

12 Jul
6 days ago

bobbybouwmann left a reply on Laravel And Lumen Oferta::destroy(id) Is Not Working

The destroy method returns the count of the number of items that have been deleted. So in your case it makes sense it returns just 1 since that is the count.

If you want information from the model and output that in a message you should do this

public function destroy($id) 
{
    $oferta = Oferta::findOrFail($id);
    $oferta->delete();

    return redirect()->route('webofertas.index')
        ->with('success', 'Oferta borrada: '.json_encode($resultado));
}

Let me know if this works for you!

bobbybouwmann left a reply on Liskov Substitution Principle

Very nice example @sergiu17 That is exactly what I meant with my example but it was too abstract I guess!

bobbybouwmann left a reply on Trying To Execute 'vagrant Up'

It looks like you still have another vagrant box running! Make sure you shut down all boxes before you run vagrant up again. You can do that by opening the VirtualBox app and stop all running containers.

bobbybouwmann left a reply on Execute Encrypted Files

Why don't you set it up as a SaaS. This way the customer doesn't have to run anything but they can connect to your system. They can even access your application using an url so whatever you're doing should be available.

I'm curious for what kind of application your building that you need this! I've build pretty secure applications for secret companies and never encrypted a single php file!

bobbybouwmann left a reply on Does Laravel Has Validation For Names?

Yeah, you can use a regex if you want more complex validation. In general for names you just check if it's a string or not.

Documentation: https://laravel.com/docs/5.8/validation#rule-string

To be honest I never add any extra validation for name fields. Just required if needed and that's it. Laravel automatically escapes the input so you should be good to go ;)

bobbybouwmann left a reply on Can I Define Dependency Injection In Any Class?

Laravel will resolve the class automatically for you. If it can't it will throw an exception. If that is the case you need to be more specific and you can register a class in the container using service providers

Documentation: https://laravel.com/docs/5.8/container

bobbybouwmann left a reply on Gates Problem After Laravel's Upgrade From 5.2 To 5.8

In the new setup you don't need to pass in the $gate variable anymore

// 5.2
public function boot(GateContract $gate)
{        
    $this->registerPolicies($gate);
}

// 5.8
public function boot()
{        
    $this->registerPolicies();
}

You can find all of this in the upgrade guide!

Documentation: https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0

You may remove the arguments from the boot method on the EventServiceProvider, RouteServiceProvider, and AuthServiceProvider classes.

You probably didn't read the upgrade guide so you will probably have more issues after fixing this!

bobbybouwmann left a reply on Deleting Users Passport Token On Logout.

@doctolly In this case it's fine, because you're extending the functionality.

Another solution is using an event and listener to perform those actions. That is what @d9705996 suggested

protected $listen = [
    'Illuminate\Auth\Events\Logout' => [
        App\Listeners\DeleteUserAccessTokens::class,
    ],
];

bobbybouwmann left a reply on Liskov Substitution Principle

Mmh I think I have an example for you.

Let's say you have a shop where you sell books and ebooks. Now not all books are available as downloadable content and not every book is available as a hard copy right. But some books have both. So for each book the action after purchasing is different. So either ship the book or download the book

So you have a base class called book and then for each possibility you have an implementation for that.

class Book
{
    public function getTitle();
    public function getSummary();
    public function purchase();
}

class DownloadableBook extends Book
{
    public function purchase()
    {
        // Perform the download action
    }
}

class PhysicalBook extends Book
{
    public function purchase()
    {
        // Perform the shipping thing
    }
}

I believe this is a correct example ;)

bobbybouwmann left a reply on Add Certification On LinkedIn

Maybe @jeffreyway can answer that question!

bobbybouwmann left a reply on Nested Eager Eloquent Not As Expected

It's probably because you call get on it! What do you see when you do this?

foreach ($sectors as $sectorkey => $sectorvalues) {
    foreach ($sectorvalues->codelists as $codekey => $codevalues) {
        dd($codevalues);
    }
}

This should show one "codevalues" with the selected columns.

11 Jul
1 week ago

bobbybouwmann left a reply on Deleting Users Passport Token On Logout.

You can just do something like this right?

public function logout(Request $request)
{
    $user = $request->user();

    foreach ($user->tokens as $token) {
        $token->revoke();
    }

    Auth::logout();
}

bobbybouwmann left a reply on Redirect In Middleware Returns View Of Vue Route!

Well redirects are browser specific and not api specific. Vue runs in the browser and has it's own router if you use it as a single page application. If you do a request to the backend that returns a redirect your vue won't understand what to do with that. It will only see a response coming in and that's it.

So you either need to handle the request as a browser request or you need to handle the routing in your frontend.

bobbybouwmann left a reply on Specific Validations For Dates Selects

I tryed this code but it didn't work.

Sorry man but "didn't work" is a bit unclear.

Anway, glad you fixed it ;)

bobbybouwmann left a reply on Execute Encrypted Files

Nope you can't! That's not how PHP works. Even if that would work your server would be really slow because decrypting the file before performing the request and then encrypting it again is very slow.

This doesn't sound like a solid solution!

May I ask why you want to do this?

bobbybouwmann left a reply on Reset Auto Increment Id For The Tests?

@ranx99 Note that DatabaseMigrations is a bit slower because it performs all the migrations for each test class. A transaction is much faster ;)

bobbybouwmann left a reply on How To Create Null Values Columns In Laravel Database File?

Here you go ;)

$table->string('comment')->nullable();
$table->string('extra')->nullable();

bobbybouwmann left a reply on Custom Mail Log Channel Breaks MAIL_DRIVER=log

I think the level is incorrect here. Can you set it to debug to see if the emails show up in the log file then?

Also have you tried a simpler file name like storage_path('logs/mail.log'), just for testing purposes?

10 Jul
1 week ago

bobbybouwmann left a reply on Share Redis Cache And Between Different Laravel

In general it should work if they both have the same prefix key! By default the prefix is generated like this

'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache'),

So you either need to set the CACHE_PREFIX in your .env in both applications or set the same APP_NAME.

After that make sure they both connect to the same database number. You can set that with REDIS_DB. By default this is set to 0!

Let me know if that makes sense now ;)

bobbybouwmann left a reply on Test Suite "General Error: 1205 Lock Wait Timeout Exceeded"

It's probably a transaction that hasn't been closed! This should be done by Laravel itself!

You need to add the parent::tearDown() call in your tearDown method

public function tearDown()
{
    parent::tearDown();

    // Do your own tearDown here
}

bobbybouwmann left a reply on Specific Validations For Dates Selects

You can already do this with Laravel if you would keep each date as a single field. This also makes your code more readable and it's easier to validate!

So you would get something like this

$requestDatas = $request->validate([
    'startDate' => 'required|date|after_or_equal:now',
    'endDate' => 'required|date|after:startDate',

    // Other rules
]);

Let me know if that works for you ;)

bobbybouwmann left a reply on Reset Auto Increment Id For The Tests?

You can still do that right? But at this point you just generate a collection of posts and assert that same collection. You already know the order at this point in the code example you showed before.

What you normally would do is generate some posts with specific data for example a different date or different id number. The you would retrieve that from the database and see if they are in the correct order.

bobbybouwmann left a reply on Get Translation For Array Field

Well that makes sense in this case because the translation doesn't know about the index keys right? It's just a general translation for each key. So you have two options here. Either the same method for each field

// First argument is an array of rules, second argument is an array of translation messages

$request->validate(
    [
        'bedroom.*' => 'required' 
    ],
    [
        'bedroom.*.partners' => __('attributes.property.bedroom.partners'),
    ]
);

Now another solution is providing a unique message per key, but you would need to build that up as well

// Translation
return [
    'attributes' => [
        'property' => [
            'bedroom' => [
                'partners' => 'At some custom message here for index :key',
            ],
        ],
    ],
];


// Validation
$bedrooms = $request->get('bedroom');

$messages = [];
foreach ($bedrooms as $key => $bedroom) {
    $messages['bedroom.' . $key '.partners'] = __('attributes.property.bedroom.partners', ['key' => $key]);
}

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

bobbybouwmann left a reply on Getting The Array Index Inside Validator->sometimes(bedroom.*.partners,...)

I don't really see what you want to achieve with this sometimes rule in this case. Can you explain your case a bit more?

bobbybouwmann left a reply on Reset Auto Increment Id For The Tests?

RefreshDatabase migrates once at the start of the test suit and then uses a transaction for each following test. So this is correct behaviour ;)

However your test case is not of much value. As the end user you basically don't care what kind of ID is created right? You just want to make sure a Post is there.

So what exactly are you trying to test here?

bobbybouwmann left a reply on Question About Dropzone Validation

Well basically yes! It's javascript that runs in the browser, so technically they can change it.

However you should have the same validation on your production environment! So make sure there is a upload limit on the server, but also in your validation. This way you should always be good to go ;)

bobbybouwmann left a reply on Structure Of Laravel 5/vuejs 2 With Flexbox

Vue is a complete different syntax, I honestly never check complete frontend apps in that kind of validators. You don't know how the render you app and in this case it's blocking the rest of the checks because of a tag name which is valid in Vue.

I would bother;

bobbybouwmann left a reply on How To Add An Extra Method To The Auth Facade Class?

The boot method would be the right place for this!

bobbybouwmann left a reply on Laravel Echo: Count Number Of Online Users

Well you can't do that because you only know your own session right? You don't know the session of others users. In this case just checking in the array of users is the best option here. You can then let the frontend handle the count ;)

bobbybouwmann left a reply on How To Add An Extra Method To The Auth Facade Class?

You can use the extend method of class that generates the user session

SessionGuard::macro('newMethod', function() {
    return true;
});

The best place to do this is normally a ServiceProvider, for example the AppServiceProvider you already have in your code base ;)

bobbybouwmann left a reply on Rating For Users

Well that is a very good question!

Our top contributor @snapey blogged about this a while ago: http://novate.co.uk/using-fontawsome-svg-and-laravel-blade-to-output-a-star-rating/

This is exactly what you need ;)

bobbybouwmann left a reply on Laravel Echo: Count Number Of Online Users

Well you need to keep a reference to the initial number and whenever someone joins or leaves you need to update that number.

So if you're using Vue you well get something like this

listen() {
    Echo.join('onlineusers').here((users) => {
        this.users = users;
        this.usersCount = users.length;
    })
    .joining((user) => {
        this.users.push(user);
        this.usersCount = this.usersCount+1;
    })
    .leaving((user) => {
        this.users.$remove(user);
        this.usersCount = this.usersCount-1;
    });
},

This way it's updating instantly and not every 5 seconds, but I think this is fine in your case as well! Now you can just reference {{ usersCount }} in your template to show the number of active users.

bobbybouwmann left a reply on Laravel And Ant Design

I'm not sure what your question is. You can find the installation steps here: https://vue.ant.design/docs/vue/introduce/#Installation

From there Laravel offers your Laravel Mix out of the box to compile your assets. For the rest it's just javascript and one template file. There are a lot of tutorials out there for this ;)

bobbybouwmann left a reply on Sharing Cache/queue Between Laravel And Lumen Projects

Well you can easily do that because redis itself is not part of the Laravel application right? It's a separated running process. As long if you connect on the same database in redis you should be able to read and write data from both application in Redis.

Do notice that Laravel has a prefix for all the cached items that are stored in redis. You need to make sure that you either remove the prefix or that you make them the same on both application ;)

Laravel cache: https://github.com/laravel/laravel/blob/master/config/cache.php#L101

bobbybouwmann left a reply on Verify Email Address Redirect When Not Logged In

Well you can override the default route from Laravel in your own routes file and add the auth middleware.

// web.php

Route::get('email/verify/{id}', 'Auth\[email protected]')->name('verification.verify')->middleware('auth');

Another solution is adding the auth middleware to the controller itself

// VerificationController.php

public function __construct()
{
    $this->middleware('log')->only('verify');
}

Documentation: https://laravel.com/docs/5.8/controllers

09 Jul
1 week ago

bobbybouwmann left a reply on How To Show An Output Value In Browser

What is event.label? You can't just randomly assign a variable in this case.

Can you show the code you used for the console.log call?

bobbybouwmann left a reply on Homestead Stop During "homestead Up" At "SSH Auth Method: Private Key"

If you're on windows you need to make sure "virtualization" is enabled. Otherwise you get this issue! You can just Google on how to enable it.

If you're in a different OS destroying the vagrant box and starting it again works most of the time as well!

vagrant destroy
vagrant up

bobbybouwmann left a reply on Update Job Payload On Job Failure

I have an application running over 2 million jobs a day and never have performance issues. If you have a dedicated "worker" that processes the jobs it will run very fast!

A worker is basically a server that runs the same application but only processes the jobs from the queue.

I think you can make this work ;)

bobbybouwmann left a reply on Composer "suggests Installing"

It will work correctly, it just suggest other packages that work nicely with this package as well. You don't really need to do anything with this ;)

bobbybouwmann left a reply on Update Job Payload On Job Failure

Well you see that your job performs multiple actions, that sounds like bad behaviour in general. Each task should be a separated job in my opinion! In Laravel you can also use job chaining: https://laravel.com/docs/5.8/queues#job-chaining

bobbybouwmann left a reply on Save Markdown As .md

What you're looking for sounds like Statamic: https://statamic.com/

Anway, you want to keep the files on the server to keep them in sync when locally editing them? If that is the case you need an SSH or (S)FTP connection between your device and the server. There are plenty of tools for that, but I'm not sure if this is what you really want!

bobbybouwmann left a reply on User Registration Via API And The Activate Redirect URL

If you look into the sendEmailVerificationNotification method you can see that this will send a notification to the user using an email. In the email a route is specified. So what you can do is override the emailtemplate and specifiy a different route. The only think you then need to do is add that route to your application point to the verification controller.

You can find the current route and it's controller by running php artisan route:list

08 Jul
1 week ago

bobbybouwmann left a reply on Get Everything From Table With Every Related Data From Many To Many Relations

So the database was empty? :P

Anyway, did you get everything working now?