bramcou

bramcou

Member Since 2 Years Ago

Experience Points 4,220
Experience Level 1

780 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 37
Lessons
Completed
Best Reply Awards 0
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.

14 Dec
2 months ago

bramcou left a reply on From Shared Hosting And Filezilla/Putty To Git.. I'm Lost

Oh lol. How underestimating to thank there wouldn't be a whole laracasts category on this. Thanks.. I'll probably figure it out from there.

Perhaps just one question on the front: can you work with just Git, your local homestead dev area, your remote (production) server and GitLab or GitHub and no other services/party's involved?

bramcou started a new conversation From Shared Hosting And Filezilla/Putty To Git.. I'm Lost

Dear readers,

I'm not that old but learned programming and web development in what seems to be an previous era (-:

Learned PHP in the times of PHP4, eventually got into CodeIgniter and when I picked up web development again two years ago I transitioned to Laravel which was the best thing ever (obviously).

Currently managing a Laravel project for a local society. The project utilizes some queue's, is hooked up to G Suite to manage email groups, uses Sentry for bug tracking. The website is hosted @ A2Hosting, shared hosting but with all the PHP/SSH goodies that I required so far. For about 10 euro a month.

All the time the project's been deployed really old school using Filezilla and Putty. Now that another developer is joining in I want to switch to use Git to manage the versioning. However, I'm getting totally lost and confused in the thousands of available tutorials. Is there anyone recognizing this situation who's been through that phase and can explain which is the best course to go or the best tutorial(s) to read?

Basically what I want is very simple: be able to work independently of each other with a co-developer on the website, preferably beeing able to work on multiple new features in parallel which could be deployed to the server separately once a feature is good 2 go. Would be nice to have a graphical overview of which features are being developed (I understand that to be branches)

I understand either Github or Gitlab would be neccesary for this, however, when reading the Gitlab & Laravel tutorial @ Gitlab I get totally sucked up into something I can't grasp and which seems to be over my head (https://docs.gitlab.com/ee/ci/examples/laravel_with_gitlab_and_envoy/index.html#initialize-our-laravel-app-on-gitlab)

I've ended up reading and tutorialing from DigitalOcean and AWS to Forge, to then understanding that Forge comes on top of either DO/AWS or another host. And a ton of other different hosting companies. I am however quit happy with A2Hosting and wouldn't mind staying there if we can simple get the co-working part using Git working there.

Help through this 'jungle' would be sincerely appreciated.

Thanks!

25 May
8 months ago

bramcou left a reply on For Those Who Find Homestead/Vagrant/Virtualbox Slow On Windows

@mistermat solution works aswell and is really quick and easy. Do mind that you add:

  type: "nfs"
  mount_opts: ['nolock,vers=3,udp,noatime,actimeo=1']

For each folder mapping and without the stripes in front of type and mount_opts.

Thx!

19 May
1 year ago

bramcou started a new conversation Strange Bug: Illuminate\Database\Eloquent\ModelNotFoundException "favicon.ico"

Hi all,

I have a rather strange bug which I just can't figur out, despite quite some efforts. Googled it and can't find any other cases. The bug turns up every few days and the website's used by 50-100 unique users a day. We use Sentry as bugtracker so we have access to a lot of supplementary information if needed.

I'll describe one particular case which happened a few times: Users click a link which directs them to:

http://xxx.yyy.zzz/ddwv/afmelden-vliegdag/7

Where 7 is the ID of a Model. That controller's code is:

    //get DDWV
        $ddwv_day = Ddwv::with('users')->findOrFail($ddwv_id);

        //authorize
        $this->authorize('leave', $ddwv_day);

        //user is actually already signed up
        if (! $ddwv_day->users->contains($this->user)) {

            //add usernotification
            UserNotification::store('danger', 'U kunt zich niet afmelden voor deze vliegdag want u bent niet aangemeld voor deze vliegdag.');

            //redirect
            return redirect('/ddwv/vliegdag/' . $ddwv_id);
        }

        //remove user from DDWV day
        $ddwv_day->users()->detach($this->user);

        //notifcation
        UserNotification::store('success', 'U bent succesvol afgemeld voor de vliegdag van: ' . $ddwv_day->flyday_date->formatLocalized('%A %e %B %Y'));

        //redirect
        return redirect('/ddwv');
            

Then, somehow they end up getting redirected to the following URL: http://xxx.yyy.zzz/ddwv/afmelden-vliegdag/favicon.ico

Some data from Sentry:

  • The above URL is the "referer" header.
  • It happens on any type of device, OS, browser etc.
  • Stacktrace, top part:
Illuminate\Database\Eloquent\ModelNotFoundException: No query results for model [App\Models\Ddwv] favicon.ico
#51 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(302): findOrFail
#50 app/Http/Controllers/Flightops/DdwvController.php(226): leave
#49 [Anonymous function](0): call_user_func_array
#48 vendor/laravel/framework/src/Illuminate/Routing/Controller.php(55): callAction

Any thoughts? If more (specific) info is required, please just ask.

Thanks!

Bram

18 May
1 year ago
16 May
1 year ago

bramcou started a new conversation Architectural Question Regarding Laravel And Mailgun Mailing Lists

Hi all,

I have a architectural question regarding Laravel and Mailgun mailing lists. The Laravel website supports an association in which groups of users can be dynamically created and removed. Now I'm implementing mailing lists with Mailgun.

The administrator can turn on/off a mailing list for his or her group using the Mailgun API. Each time an administrator opens the configuration screen for a group it will display the mailing list settings.

Now I'm doubting between two options (there might be more I haven't thought of):

  1. Just storing the address of the mailing list (in a separate table that has a relationship to the group) in the database. Each time the user opens the config screen, the API will be called to retrieve the settings which will then be displayed.

  2. Storing all the mailing list settings in the mailing lists table. Each time the user opens the configuration screen those settings are displayed. If the user changes one of those settings the API is called to adjust those settings in Mailgun. If that returns 200, the settings are also stored in the database.

I can think of a few advantages and disadvantages.

My main concern with the second option is, what if for any reason, a setting is changed through the Mailgun control panel. Then the database and Mailgun aren't concurring anymore but the users won't notice until something stops working (for instance if the access level of the mailing list is changed). I could build in some sort of daily integrity check but that still doesn't cover it any given time of day..

On the other hand, when each time that the configuration is opened, a API call has to be performed and that puts load on the application. And when Mailgun stops talking back (forgot to pay, troubles, whatever) that will have implications. Of course, those can be catched, but still.

Would really appreciate somebody's input on this.

Thanks!

Bram

25 Apr
1 year ago

bramcou started a new conversation 404 Shows Despite Environment = Local

Hi all,

I just installed a custom 404 view. I already have several other custom error views. Those only show when running in production. However, the 404 always shows (when there is cause for then of course), also in the local environment.

Checked the Exception handler (app/exceptions/handler.php) but it doesn't even appear to get that far.. tried looking for some form of middleware that might handle this but it doesn't appear to work that way either.

Please help!

Thanks,

Bram

23 Mar
1 year ago

bramcou left a reply on Complex Relationship That Takes (too) Long

Hey guys,

Yeah I had tried it, broke my head on it a few times but now.. just after I got to the point of posting the question here I figured it out. With eager loading indeed.

Thanks!

bramcou started a new conversation Complex Relationship That Takes (too) Long

Hi all,

My question is basically: how can I do the following better, as in quicker:

I have 3 tables with a manyToMany relationship: users, memberships and membership_user (this one's the pivot). A user can have multiple memberships (and vv) and the memberships aren't parallel but sequenced.

A simple example: Tom joined the association and became a "new member" on 01-01-2016. Now after one year he becomes a "regular member", on 01-01-2017. After many years he will become a "senior member", say on 01-01-2030.

Our administrators can put in memberships both in the future and in the past, so they can pre-program Tom to become a senior member, 5 years from now.

To determine the user's current membership the application does the following:


/**
     * Gets the current membership from the user
     *
     * Furthermore, we must account for the possibility of having an user with all memberships in the future
     *
     * @return object membership object
     */
    public function getCurrentMembership()
    {
        $membership = $this->memberships->where('effective_date', '<=', date('Y-m-d'))->limit(1);

        //if no records are found this user holds only future memberships, make a new query
        if (! $membership->exists()) {
            $membership = $this->memberships()->limit(1);
        }

        return $membership->first();
    }

This works fine.

Now the problem is that we have about 600~ users and when I want to retrieve, say all senior members I actually have to retrieve all members and then check, member by member, whether they currently hold this particular membership. That's when the application has to do 600 + 1 query's which puts about a second on top of the regular loading time.

I've tried eager loading the pivot table but I can't get that to work and I don't think it's actually meant to be a solution for this challenge.

Now when I started programming some 10 years ago I did actually learn a bit of SQL but I can't figur out how to join this together. Actually I'm not even sure it's possible to join this.

Simplified DB structure:

Users

id name

Memberships

id name

Membership_USer

id membership_id user_id effective_date

Any idea's on either: how to do fix this DB-wise or perhaps a (totally) different way to implement the desired functionality?

Cheers!

Bram

28 Feb
1 year ago

bramcou left a reply on Can't Access Model Attributes In Constructor

Oh lol, it never occured to me that an accessor could be uses for a non existing attribute.

Thanks!

bramcou left a reply on Can't Access Model Attributes In Constructor

Well, I'd like to be able to pass the $user model straight to the mailable. Therefore it needs to have a $name property which it doesn't natively have (there is no DB column).

How else could I accomplish that?

I'd be glad to learn (-:

bramcou started a new conversation Can't Access Model Attributes In Constructor

Hi all,

I'm having trouble accessing attributes in the constructor of my Auth User model despite running the parent constructor.

Might have to do with the fact that it's the Authentication user model.

public function __construct(array $attributes = array())
    {
        parent::__construct($attributes);

        dd($this->getFullName());
    }

This will not work, I can try to DD any property or method but result is NULL. I checked the parents: first is the Auth User model and then Eloquent model.

In the Eloquent model constructor $this->fill($attributes) is called, when I DD there I see that that method is indeed run, with properties but the array is empty here aswell.

So I suppose the Auth class does some non-standard Eloquent setting.

Anybody any idea?

My goal is to set the $name property of the Model in the constructor so I can use it for Mailables.

(I have a temp workaround in the base controller but that's not a pretty one)

Cheers!

Bram

17 Feb
1 year ago

bramcou left a reply on Set A Default Date Format For Carbon In Laravel

Thanks for the addition. I had considered it and that's also what the other thread suggests (in a slightly more abstract manner) but it would've been way nicer if Carbon supported some sort of config file where you could set this stuff. It just doesn't appear to have any such thing :p

bramcou left a reply on Set A Default Date Format For Carbon In Laravel

Thanks! Didn't look good enough.

bramcou started a new conversation Set A Default Date Format For Carbon In Laravel

Hi all,

The title pretty much sums up the question: how to define a default date format that carbon uses in Laravel?

Default is now Y-m-d, but I'd like to have it in euro style: d-m-Y and it would be nice if I wouldn't have to force that at each carbon instance.

Thanks!

13 Feb
2 years ago

bramcou left a reply on Should I Use A Service Provider?

Or do put it in a seperate class but have it extend the User model..?

bramcou left a reply on Should I Use A Service Provider?

Thanks!

@SaeedPrez , now I'm thinking.. why not put the methods of getting, adding and deleting the profile photo on the User model.

I suppose that is somewhat inappropriate as it will be putting some form of logic in the model, from the other hand, it are methods that edit the state (and db values) of the User.

bramcou left a reply on Should I Use A Service Provider?

Hi guys,

Thanks for all the input Since I'll be "depending" on Intervention I eventually decided to put it in a service container anyway.

Tough I'm still doubting whether I should downgrade to a helper class..

@SaeedPrez thoughts on that (considering Intervention)?

Cheers!

bramcou started a new conversation Should I Use A Service Provider?

Hi all,

I'm very new to Laravel (coming from CI) and still finding my ways around. Mose of the time I find a problem, different solutions and wonder which solution I should choose.

I'm building an application in which both users and administrators can upload a new profile photo for theirselves/other users.

This means the logic for uploading and resizing a profile photo is gonna end up in two different controllers so I want to put this logic somewhere else and reference it.

Now I wonder, should I put this into a serviceprovider or somewhere else?

I've already made one service provider to store and display notifications to users. That was a rather clear case as I need that functionality on a lot of controllers and I use a viewcomposer to inject the notifications into a specific part of my layout.

However, now I only need this piece of code on (for now) two controllers.. But on the other hand, I wouldn't know a viable solution other than using a service provider. It just sounds like so much effort for such a simple task.

Please help!

Regards,

Bram