gjm

gjm

Member Since 2 Years Ago

Experience Points 7,580
Experience Level 2

2,420 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 68
Lessons
Completed
Best Reply Awards 0
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.

10 Dec
7 months ago

gjm started a new conversation Laravel Mix Upgrade Best-practices

Hi.

The Laravel upgrade guide doesn't mention upgrading package.json versions as it does for some composer.json components, namely laravel-mix.

How do you guys do it when you upgrade Laravel? Do you manually keep it in sync with the default framework file?

That's what I have been doing but it feels somewhat awkward and I was wondering if there is a better way of tackling this.

Thanks in advance.

22 Sep
1 year ago

gjm left a reply on Getting Auth User Very Eatly In Bootstrap Process

@martinbean actually i've made a slight mistake in the OP. It's not on the handler it's on the processor (using $monolog->pushProcessor()). The processor adds the logged in user to the message info.

I'm sorry for the confusion but essentially the problem is the same.

gjm left a reply on Getting Auth User Very Eatly In Bootstrap Process

@36864 the getDefaultDriver() method returns web (as it should i think). I think the problem is, as you pointed out, the driver is not yet initialized.

gjm left a reply on Getting Auth User Very Eatly In Bootstrap Process

@martinbean i agree! :) I don't care what the user is at this point.

The problem is that the handler is "universal" and for normal logging task i do want the user.

But, either in development or in runtime, if something happens this early i don't want the system to break because it can't write to the log. I want the error to be logged so it can be dealt with.

As i said in the OP, my workaround is working for me. I just wanted to know if there was a more correct way of addressing the issue.

gjm left a reply on Getting Auth User Very Eatly In Bootstrap Process

@martinbean i'm using $monolog->pushHandler() in bootstrap/app.php.

The logging handler is working fine. The problem is when the error occurs very early, for example in a middleware before the session is initialized. Only in those cases the error occurs.

gjm started a new conversation Getting Auth User Very Eatly In Bootstrap Process

Hi.

I've set up a logging handler in which i want to include information about the logged in user, if applicable.

My problem is that, if some error occurs early in the bootstrap process auth()->user() will throw an InvalidArgumentException:

Auth guard driver [web] is not defined.

I know this normal because the session has not yet been initialized. What i want to know is if there is a way to check if i can call auth()->user() safely?

As a workaround i'm enclosing the call in a try catch block but i wanted to know if there is a "proper" way of doing this.

Thanks in advance.

05 Sep
1 year ago

gjm left a reply on Facade Alias Not Working Since 5.5

Got it!

It was related to auto-discovery. So laravelcollective/html automatically registers two facades, Html and Form and that was overlapping my own facades.

Disabled auto-discovery for laravelcollective/html and everything is working fine again.

gjm started a new conversation Facade Alias Not Working Since 5.5

Hi.

I have a problem after upgrading to Laravel 5.5. I have an alias to a facade in my config/app.php file. The alias is called Html and points to a facade that resolves to a class i wrote to generate some html code.

I have the laravelcollective/html package installed and it is used internally by my class.

Up until now everything was working properly but since the upgrade all references to Html::* cause an exception because the Html facade is resolved to Collective\Html\HtmlBuilder insted of my class, event though no reference to it is present in the aliases section. Even if i remove the Html alias it keeps working.

Is this related to some new feature present in L5.5 like auto-discovery ou auto-facades? Is it a bug? Does anyone have any clues on this?

Thanks in advance.

04 Sep
1 year ago

gjm left a reply on Laravel Upgrade Strategy

@bashy so what you mean is doing point release upgrades, just as i meant when saying there is only upgrade guide from 5.4.

01 Sep
1 year ago

gjm started a new conversation Laravel Upgrade Strategy

Hi folks.

Now that 5.5 LTS has been released i was wondering what your thoughts are on the best upgrade strategy for Laravel applications. Should one upgrade to each point release or stick with LTS and upgrade only to the next LTS version?

Maybe Taylor has already answered this for us by only having upgrade instructions from 5.4 to 5.5 but i wanted to ear what you guys (and gals) think about this.

Thanks in advance.

17 Mar
2 years ago

gjm started a new conversation Using Mix With An Apache Alias

Hi.

I have configured my app to be available under an alias (http://localhost/myapp). How can i configure mix to reflect this in the manifest file? I want to reference /myapp/css/app.css instead of /css/app.css.

Thanks in advance.

16 Mar
2 years ago

gjm started a new conversation Asset Management And Version Control

Hi.

I'm using Mix (this applies to Elixir as well i guess) to manage my frontend assets. I have Mix configured to version files in production but not in dev. As such, when i update assets, i get updated app.js and app.css files in dev and app.{hash}.js and app.{hash}.css files in production.

What is your advice on how to leverage this with version control?

  1. Put the files in version control? If so how do i manage the constant changes during development? Keep adding new hashed files? Do i leave app.js and app.css on the production server?

  2. .gitignore the js and css files and run npm on the production server to compile the assets locally?

  3. Some other solution?

What are your thoughts on this?

Thanks in advance.

06 Feb
2 years ago

gjm started a new conversation Middleware Dependency/order

Hi.

Hi have a middleware that i must ensure is run after the auth middleware. How can i guarantee that the auth middleware is processed before mine? Is this even possible?

Thanks in advance.

26 Jan
2 years ago

gjm started a new conversation Migrations And Branches

Hi.

I've looked around but couldn't find a definitive/satisfactory answer for my problem, although i found out that many people have the same issue.

In my development workflow i (might) have several simultaneous branches. If i create migrations on some of those branches how to maintain integrity and chronological order between them?

Moreover, it's possible to create migrations on the same tables in different branches. How to avoid conflicts between them, since the later one might operate on a table the former one has already changed?

Hope my question is not too confusing.

Thanks in advance.

15 Dec
2 years ago

gjm started a new conversation Helper Functions On Packages

Hi.

I want to develop a package and include some helper functions with it. What's the best strategy for including these helper functions? I was thinking require()ing the file in the boot() method of a service provider but that doesn't seem very elegant.

Is there a better/more elegant way of doing it?

Thanks in advance.

13 Dec
2 years ago

gjm started a new conversation Setter Dependency Injection

Hi.

I have a class in which i want to inject several dependencies, depending on context. In theory that would be a perfect fit for setter injection. How can i make it work in Laravel? If i write something like:

public function setMailer(Mailer $mailer)
{
    $this->mailer = $mailer;
}

Can i make Laravel's service container inject the dependency automatically?

Thanks in advance.

06 Dec
2 years ago

gjm started a new conversation CamelCase Model Attributes

Hi.

Is there a way to automatically access a model's attributes using camelCase instead of snake_case? For example i want to be able to write $person->firstName instead of $person->first_name.

I know i can write get mutators but it's very tedious to do it for each attribute.

I've seen there's an class variable Model::$snakeAttributes but it seems to have no effect.

Can someone help me on this, please?

Thanks in advance.

28 Nov
2 years ago

gjm left a reply on Conditional @yield

@nielskramerr that's exactly it! Thanks!

gjm started a new conversation Conditional @yield

Hi.

Is there a way i can check if a section has content? For example i want to be able to write something like:

@if (@has_content('section'))
    This is my section content: @yield('section')
@endif 

Can this be done?

Thanks in advance.

25 Nov
2 years ago

gjm started a new conversation Middleware On Routes And Controllers

Hi.

I',m having a problem understanding how middleware is applied to controllers. What's the precedence? If i apply a middleware in a route definition can i override it in a controller?

Here's an example. Say i have a set a routes. I want all of them to have the auth middleware, except for one action in one controller. I would do something like:

Route::group(['middleware' => 'auth'], function () {
    Route::get('/action_1', 'Controller1@action1');
    Route::get('/action_2', 'Controller1@action2');
    ...
    Route::get('/foo', 'Foo[email protected]');
    ...
});

Is it possible to tell in FooController that i don't want the 'auth' middleware applied to the foo() method? Something like:

public function __construct() {
    $this->middleware('auth')->except('foo');
}

or do i have to define that route outside the route group?

Thanks in advance.

23 Nov
2 years ago

gjm left a reply on Migrations, Namespaces And PSR-1

@primordial i would much rather go with the second option but what you are suggesting doesn't work. Even though my migration classes are namespaced my problem persists: the migrator can't find them!

gjm started a new conversation Migrations, Namespaces And PSR-1

Hi all.

This is my first post on Laracasts so, please, be gentle with me :)

I'm starting a Laravel app (i'm new to Laravel too) and i'm enforcing PSR-4 coding standard for PHP files using a pre-commint hook.

I've stumbled into a problem while trying to add migrations since migration classes are not namespaced and that is a PSR-1 requirement.

I was wondering what's the best solution to overcome this issue. Is there some way to make the migrator use namespaced migration classes? Do i have to add some sort of exception to allow the non-compliant migration files to be commited? Some other solution?

Thanks in advance.