ahuggins

Hire Me

Experience

261,450

37 Best Reply Awards

  • Member Since 4 Years Ago
  • 1329 Lessons Completed
  • 1 Favorite

22nd May, 2018

ahuggins left a reply on Pass Options To Dusk Via Artisan Command • 3 months ago

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

        $this->call('dusk',  ['group' => $this->argument('group')]);

15th April, 2018

ahuggins started a new conversation Auto-open `artisan Make:` In Editor Package • 5 months ago

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.

4th March, 2018

ahuggins left a reply on Daily Statistics • 6 months ago

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 • 6 months ago

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 • 6 months ago

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 • 6 months ago

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 • 6 months ago

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.

16th February, 2018

ahuggins left a reply on Save Via Relationship Is Not Saving ID • 7 months ago

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 • 7 months ago

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.

12th February, 2018

ahuggins left a reply on Save Via Relationship Is Not Saving ID • 7 months ago

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.

10th February, 2018

ahuggins left a reply on TSL 1.2 On Guzzle Requests • 7 months ago

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 • 7 months ago

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? • 7 months ago

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 • 7 months ago

what are the permissions on the output directory?

8th February, 2018

ahuggins left a reply on Spark 6.0 Need Extra Charge? • 7 months ago

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.

1st February, 2018

ahuggins left a reply on Laravel Socialite Avatar (twitter) Not Updating • 7 months ago

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 • 7 months ago

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? • 7 months ago

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

18th January, 2018

ahuggins left a reply on Require Selecting A Plan When Creating A New Team • 8 months ago

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 • 8 months ago

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.

21st December, 2017

ahuggins left a reply on Password Reset - Email Never Reaches The Recipient. • 8 months ago

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.

25th November, 2017

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

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

ahuggins left a reply on Queue: Delay Dispatching Throws Error • 9 months ago

What version of Laravel are you on?

ahuggins left a reply on Queue: Delay Dispatching Throws Error • 9 months ago

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

ahuggins left a reply on Queue: Delay Dispatching Throws Error • 9 months ago

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.

17th October, 2017

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

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.

16th October, 2017

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

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.

24th July, 2017

ahuggins left a reply on Testing Custom Artisan Command • 1 year ago

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/

28th June, 2017

ahuggins left a reply on Nothing Showing, No Login, No Page, No Errors. • 1 year ago

@Cronix You can make PR to the Spark docs?

22nd June, 2017

ahuggins started a new conversation Nothing Showing, No Login, No Page, No Errors. • 1 year ago

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.

12th June, 2017

ahuggins left a reply on Can't Find My Mailable Class In Controller • 1 year ago

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

29th May, 2017

ahuggins left a reply on How To Insert Multiple Rows With Multiple Fields • 1 year ago

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.

25th May, 2017

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

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" • 1 year ago

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 • 1 year ago

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 • 1 year ago

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.

27th April, 2017

ahuggins left a reply on Creating A Custom Facade / Service Provider - Please Help • 1 year ago

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 • 1 year ago

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.

20th April, 2017

ahuggins left a reply on Scheduler Problem • 1 year ago

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?

28th January, 2017

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

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 • 1 year ago

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 • 1 year ago

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?

14th December, 2016

ahuggins left a reply on WYSIWYG Editor For Page Content • 1 year ago

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.

12th December, 2016

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

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? • 1 year ago

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 • 1 year ago

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 • 1 year ago

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.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.