ahuggins

ahuggins

Hire Me

Member Since 4 Years Ago

Experience Points 262,050
Experience
Level
Lessons Completed 1331
Lessons
Completed
Best Reply Awards 37
Best Answer
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.

22 May
5 months ago

ahuggins left a reply on Pass Options To Dusk Via Artisan Command

I know this is ~1 year old, but I think this should be like this:

        $this->call('dusk',  ['group' => $this->argument('group')]);
15 Apr
7 months ago

ahuggins started a new conversation Auto-open `artisan Make:` In Editor Package

You know how you often use the artisan make: commands to generate files, then you switch to your editor, maybe you look in the file tree to open the file...or you use the fuzzy search to open it? Isn't that pretty tedious?

Wouldn't it be just a little convenient if the artisan make: command just opened the file in your editor?

Well, pull in this new package I made and that can easily be done.

https://packagist.org/packages/ahuggins/open-on-make

Let me know if you like this, if it is useful, or if it's not really that big a deal.

04 Mar
8 months ago

ahuggins left a reply on Daily Statistics

Another benefit here, is if you ever have to login to the server, you can run the command from the terminal very easily. That's why I usually setup the Artisan command, I don't want to have a lot of steps, I want it to be simple to execute.

ahuggins left a reply on Daily Statistics

Well I usually make an Artisan command, and then you can use the Scheduler in the app/commands/kernel.php (I think) to set the timing:

https://laravel.com/docs/5.6/scheduling#schedule-frequency-options

Then you can at least test the command by running the Artisan command. Now if you want a cron on your local env...not sure on that one. Haven't used windows in a while, but you aren't really worried about the Cron...that is going to be a function of the server software. Where as the command that is executed is what you should be focusing on.

ahuggins left a reply on Setting Up A Subscription Service With Free Sub-users

If you use Spark, you can setup a subscription, but do not put a limit on the amount of people on the team, this would allow X number of people to be on the account/team.

Read over this for more information: https://spark.laravel.com/docs/6.0/billing#charging-users-per-team

ahuggins left a reply on Access Route Parameters From Global Middleware

Post your middleware class, how is the $request variable being set? Are you instantiating the Request object, either by constructor injection or method injection?

Are you getting any error, or are the above options returning null?

ahuggins left a reply on Daily Statistics

So if you want like "Yesterdays Sales" I would create a cron job, that looks at the sales (orders) table, for all sales and sums up the total.

You could store this in a new table, order_statistics or something like that, and then you can just grab a stored value. The idea being that once the clock passes into the new day...no more sales will happen on yesterday's date. And this way you are not dealing with calculating that data on the fly each page request.

Then I would probably look at cacheing that view file, for 12 hours or something, so that you really aren't even hitting the db every time, because again, that order_statistics table should not change except when the cron job adds a new row.

This would also provide you historical data that you could put in a graph, and then maybe you could have "current day sales" that you calculate on the fly, maybe once an hour. This gives you (or your client) a sort of "live" look at the sales coming in and can easily compare to last 30 days....but would not create a lot of load on the server.

Then later you could get really fancy and use websockets to update the dashboard live anytime a sale came in. But I tend to think every hour or half hour of updating when the page loads is probably acceptable in most situations.

16 Feb
8 months ago

ahuggins left a reply on Save Via Relationship Is Not Saving ID

I wonder if you can use attach() with polymorphic relations and if that would populate the user_id...might be worth trying

ahuggins left a reply on Save Via Relationship Is Not Saving ID

The polymorphic relationships only populate the usable_id and usable_type, or at least that's what I understand. Basically whatever the -able field is.

Where the other types of relationships are looking for a specific field like user_id based on the model name.

12 Feb
9 months ago

ahuggins left a reply on Save Via Relationship Is Not Saving ID

I guess you could use a mutator on the Profile model. Something like:

public function setUserIdAttribute($value)
    {
        if ($this->usable_type == 'App\User') {
                $this->attributes['user_id'] = $this->usable_id;
        }
    }

The condition is to only set the user_id if the model that the profile is being saved with is a User model. You may have to adjust the namespace if it is not App\User.

This should set the user_id field on save. If that doesn't work you could do the same thing but maybe move it to an Eloquent event, saved so that the data would have already been saved.

10 Feb
9 months ago

ahuggins left a reply on TSL 1.2 On Guzzle Requests

If you need your requests to come from an https url, you could always do valet secure in the root directory of your project. This means that Valet will serve your app via https. You might have to update your APP_URL in your .env file as well.

As far as Guzzle, this might help: https://stackoverflow.com/questions/33134274/how-do-we-specify-tls-ssl-options-in-guzzle

ahuggins left a reply on Save Via Relationship Is Not Saving ID

Why are you using a Polymorphic relationship? A profile seems like a pretty straightforward HasOne/BelongsTo relationship.

Also, I think your problem might be how you are trying to save this data. Shouldn't $profile->user()->save($user); be more like $user->profile->save($cleanedData); Assuming you have the user at this point.

Or I guess, the way I am suggesting, is based on a HasOne/BelongsTo relationship.

ahuggins left a reply on Spark With Another Template, How Hard?

I think it will be tricky, or would be rather time consuming. But it is possible. The one thing is that you can do whatever you want with your Spark app. The "dashboard" is pretty easy to customize, but if you want to control the "settings" pages, that is where the tricky-ness will be.

But since you are using a Bootstrap theme, it might be easier than I initially think. Most Bootstrap themes use quite a bit of the base styles, and provide a "theme" css file for its custom styles. It might take a little work to get things playing nicely, but the "settings" area uses Bootstrap.

ahuggins left a reply on Laravel-snappy: File Was Not Created

what are the permissions on the output directory?

08 Feb
9 months ago

ahuggins left a reply on Spark 6.0 Need Extra Charge?

At Laracon online yesterday, I think Taylor said there was quite a bit of changes coming in Spark 6.0. Enough to warrant a new major release. He also said that any Spark licenses for 5.0, would be given a 50% discount to upgrade to 6.0.

That would be $49.50 for single site, and $149.50 for multi-site licenses.

To me that's not too bad to pay for about 12-24 months of of updates...especially considering that Spark should be being used on a SaaS that should be generating income. Not to mention, you do not have to upgrade. You can continue to use the 5.0 version as long as you want. Not sure I understand the problem.

01 Feb
9 months ago

ahuggins left a reply on Laravel Socialite Avatar (twitter) Not Updating

You should do something like:

$user = User::updateOrCreate(['email' => $socialiteUser->email], [
    'name' => $socialiteUser->name,
    'email' => $socialiteUser->email,
    'contributor_code' => str_random(8),
    'username' => $socialiteUser->nickname,
    'twitter_avatar' => str_replace('http://','https://',$socialiteUser->avatar_original),
    'verified' => 1,
]);
 
         
   // Leave this for you to figure out
//            $userRole = Role::whereName('basic')->first();
  //          $user->assignRole($userRole);
    //    }

ahuggins left a reply on Laravel Socialite Avatar (twitter) Not Updating

So this handleProviderCallback is used when your user tries to authenticate using Twitter...but you are not updating the user...only creating a new User this means that the second time they are authenticating with Twitter, this will not update their user.

ahuggins left a reply on What To Do?

Do you have the resources/assets/sass/app.scss file in your repo? If that doesn't exist, then there is nothing for Webpack to compile

18 Jan
9 months ago

ahuggins left a reply on Require Selecting A Plan When Creating A New Team

So the individual user is on a plan of his own...then creates a team with a separate plan?

Is that basically a feature that allows him to have collaborators and that's what the team plan covers?

ahuggins left a reply on Require Selecting A Plan When Creating A New Team

I am assuming you are using the No card up front option?

I would guess you could make a middleware, that checks if the created team has a plan...if not redirect the user to a page that requires sign up for a plan. Then just make sure the middleware is applied on the appropriate routes.

That would be my initial take based on info provided, but hard to know if that is suitable for your situation.

21 Dec
10 months ago

ahuggins left a reply on Password Reset - Email Never Reaches The Recipient.

when you say "configured the env file" what do you mean? How are you setting up your mail? Using SMTP, mailgun, sparkpost, php mail function?

I did this the other day, and it was tricky to actually get an email to send. I ended up using SMTP, so had the username and password in the env file, but also had to setup the MAIL_HOST, the DRIVER, PORT, and ENCRYPTION.

25 Nov
11 months ago

ahuggins left a reply on Examples Of Problems That Can Be Solved The Object Oriented Way?

I would say a Cart/Product is a pretty simple OOP example.

ahuggins left a reply on Queue: Delay Dispatching Throws Error

What version of Laravel are you on?

ahuggins left a reply on Queue: Delay Dispatching Throws Error

actually, it should be ok, not sure why it is not working for you

ahuggins left a reply on Queue: Delay Dispatching Throws Error

I think this is a limitation of the dispatch() helper function. That function, returns a new PendingDispatch object, but the constructor of the PendingDispatch class does not return the object, so I don't think you will be able to chain method calls on it.

You might be able to do ProcessOrder::dispatch($orderData)->delay(10) instead, or something along those lines.

17 Oct
1 year ago

ahuggins left a reply on Adding Username To Database(migration) Using Auth::user

You could do something like this:

\\PostController.php

 public function store(Request $request)
    {
        request()->validate([
            'post' => 'required',
            'location' => 'required',
        ]);

        Auth::user()->post()->create($request->all());

        return redirect()->route('post.index')
                        ->with('success','Post created successfully');
    }

And you would have to add a relationship on your User model for post(). Something like:

\\ App\User.php

public function post()
{
    return $this->hasMany(Post::class, 'username', 'username');
}


This assumes that you have a username column on both your User and Post models.

16 Oct
1 year ago

ahuggins left a reply on Call To Undefined Method Laravel\Lumen\Application::booted()

The Lumen Application class doesn't have the booted() method, which the Propaganistas package is looking for. You could extend the Application class that comes with Lumen and add a booted method that takes a call back and ties the passed callback to the Container...Might want to look at the Laravel Application class to see how it works:

https://github.com/laravel/framework/blob/5.5/src/Illuminate/Foundation/Application.php#L802-L809

But you would also have to use the isBooted() method, and maybe some other things.

24 Jul
1 year ago

ahuggins left a reply on Testing Custom Artisan Command

use the Artisan Command to generate a test like php artisan make:test NameOfYourTest Or actually @themsaid probably explains it better here: https://themsaid.com/building-testing-interactive-console-20160409/

28 Jun
1 year ago

ahuggins left a reply on Nothing Showing, No Login, No Page, No Errors.

@Cronix You can make PR to the Spark docs?

22 Jun
1 year ago

ahuggins started a new conversation Nothing Showing, No Login, No Page, No Errors.

Posting this in case anyone else experiences this.

I think I had an older version of Spark, and tried to upgrade, but then the app wouldn't show anything. No pages, and very curiously, no errors in the console.

Eventually I tracked it down to something involving the v-cloak directive. No link was turning up anything that was explaining what was happening. So I did a fresh install of Spark and everything was working. So I began trying to find what was causing the problem.

Looks like Spark was built before Vue 2.0, and was using inline-templates, and maybe there was another change that the v-cloak directive needs to be on the actual Vue instance div.

In older versions of Spark, the v-cloak directive was on the body tag, and moving it to the the spark-app div, then the site begins appearing again.

Unfortunately, this does not seem to be mentioned in the upgrade guide.

12 Jun
1 year ago

ahuggins left a reply on Can't Find My Mailable Class In Controller

you try a composer dump-autoload?

Figure you have, but also didn't say it, so worth asking. It looks right, so I would try the dump autoload and see if that helps

29 May
1 year ago

ahuggins left a reply on How To Insert Multiple Rows With Multiple Fields

What about just this:


foreach ($inputs as $input)
            {

                StudentMark::create(array(
                    'course_id'=>Input::get('course'),
                    'semi_written_test'=>$input['written'],
                    'semi_reading_test'=>$input['read'],
                    'semi_class_activity'=>$input['activity'],
                    'semi_homework'=>$input['homework'],
                    'semi_total'=>$input['total'],
                    'student_id'=>$input['studentId'],
                ));
            }
StudentMark::create($marks);


It's not the best, since you are making a full roundtrip request for each $input....but it should at least create it in the db. Then you can work toward a better solution, that doesn't make as many requests.

25 May
1 year ago

ahuggins left a reply on I Am Getting "This Page Isn’t Working. Localhost Is Currently Unable To Handle This Request. HTTP ERROR 500"

Is this the only site on the server? Can you visit the other ones?

This looks like your local server is not running.

ahuggins left a reply on I Am Getting "This Page Isn’t Working. Localhost Is Currently Unable To Handle This Request. HTTP ERROR 500"

What local server are you using?

php artisan serve

Homestead

Valet

Wamp, Mamp, Xampp, Ampps?

ahuggins left a reply on 2 Variable In 1 Foreach

Are you using Eloquent Models? It looks like you are only using the Query builder. If you were using Eloquent Models, I would suggest using relationships then you can return the products and reference the relationship of the other tables you are trying to get the data of.

ahuggins left a reply on 2 Variable In 1 Foreach

You have a problem in your product function. You are setting $k = within a foreach. This overwrites the $k value every time, so when in the view...there should only be one value in $k.

27 Apr
1 year ago

ahuggins left a reply on Creating A Custom Facade / Service Provider - Please Help

Because someone could do this...if you remove a , it can not be from the last entry in the providers array. It needs to be one that would cause an error.

ahuggins left a reply on Creating A Custom Facade / Service Provider - Please Help

Ran across this, because I experienced similar issue in 5.4. Posting it in case anyone else comes across this post.

For me, I added the package service provider in the config/app.php, like we all know to do. Kept getting that the class was not found. At some point I ran all these commands in the terminal:

composer dump-autoload
php artisan config:clear
php artisan cache:clear
php artisan clear-compiled

I think it was the config:clear, but I am not 100% sure on that.

One thing you can do is go to your config/app.php file, go to the providers array, and remove a , from the end of a line. If you refresh your browser/app, and do not get a parse error. You know that you have a cache issue.

Be sure to add the , back when you are done though.

20 Apr
1 year ago

ahuggins left a reply on Scheduler Problem

crontab is mostly a Unix thing, so since you are using CMD/Windows...probably isn't going to work out for you too well.

Do you know the server software you are using? IIS, Apache, Nginx?

Are you using Wamp, Mamp, Ammps, or some other local server package?

28 Jan
1 year ago

ahuggins left a reply on Npm Install Sweetalert Missing .min.js File In Dist Folder

HA, turns out, I excluded *.min.js files from being searched in Sublime, and it also doesn't show them in the file tree.

So that is why it was not showing up.

ahuggins left a reply on Npm Install Sweetalert Missing .min.js File In Dist Folder

I've deleted and installed the sweetalert module a few times

ahuggins started a new conversation Npm Install Sweetalert Missing .min.js File In Dist Folder

I am working on a Spark application, I run npm install and it looks like things install. But when I run gulp, the Elixir/Mix file tries to publish this .copy('node_modules/sweetalert/dist/sweetalert.min.js', 'public/js/sweetalert.min.js') but when I look in the public/js folder, there is no sweetalert.min.js file, and so I go look in the node_modules/sweetalert/dist/ folder the sweetalert.min.js file is missing too.

I go look on Github for the Sweetalert repo and it has the sweetalert.min.js file listed...so does anyone know why I am not getting the min.js file in the dist folder?

14 Dec
1 year ago

ahuggins left a reply on WYSIWYG Editor For Page Content

So you are asking, how do you get your page content into a WYSIWYG editor?

Usually, you have that as a property on your Page model, where you store the html, then in the edit/create page you have your WYSIWYG editor connect to a textarea field, you store that in your db, then when you edit, you set the property as the value of the textarea and have the WYSIWYG connect to the text area again.

I've done this many times.

Also, there is not a WYSIWYG that is going to automatically handle file uploads into your Laravel app. If there is, I am unaware. Most likely there might be one that has the majority of this built in the front end side, but you will most likely have to handle the upload yourself.

12 Dec
1 year ago

ahuggins left a reply on How To Get Base Url Form Json In Laravel 5.3?

Friendly reminder, you don't want your .env file in your Git repository

ahuggins left a reply on How To Get Base Url Form Json In Laravel 5.3?

in the .env file, there is a key APP_URL. For your local development, you can set this to APP_URL=http://localhost where on production you would set this to the actual domain.

In your case you might want to set it to: APP_URL=http://localhost/mysystem/public but I can't say 100% that will work.

ahuggins left a reply on Laravel Socialite Throws A Fatal Error When I Cancel The Authorization Process With Facebook

when Fb redirects you, it usually has a code in the url...I'm guessing when the user clicks "not now" it does not have this code in the url?

ahuggins left a reply on WhereBetween In Laravel 5

You need to make the $start and $end variables instances of Carbon...or make sure that the format matches what you have in the DB.