aacook

aacook

Member Since 3 Years Ago

Experience Points 1,030
Experience Level 1

3,970 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 0
Lessons
Completed
Best Reply Awards 1
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 Mar
6 months ago

aacook left a reply on Having Trouble Upgrading Sentry With Laravel 5.8

I ran into this issue in both Laravel 5.7 and 5.8. If you remove user_context from config/sentry.php it should work (via https://github.com/getsentry/sentry-laravel/issues/203)

26 Sep
11 months ago

aacook left a reply on 502 Bad Gateway

This happened to me just now. Rebooting nginx didn't work. Rebooting the entire server did work.

04 Sep
1 year ago

aacook started a new conversation Automatically Restart Queue When Code Is Changed (for Local Development)

When I develop locally I run php artisan queue:work as several of the tasks for my app happen in a queue. The issue with it, though, is if I make any changes to the code I have to jump into the terminal and restart the queue, otherwise the code is loaded into memory and the most recent change isn't reflected.

Is there some way to automatically restart the queue when any file within the project is updated? Maybe Supervisor can do this, although I poked around and don't see anything obvious.

02 Sep
1 year ago

aacook left a reply on Php Artisan And Kernel.php Running Different PHP Versions On Mac OSX

I have it scheduled in /app/console/Kernel.php in Laravel. I'm using MAMP for my mysql server on this machine, running Laravel in parallel. I set my Mac to use MAMP's php 7.1.1 via https://gist.github.com/irazasyed/5987693 but it looks like Laravel still uses php 7.1.4 when it runs anything in Kernel.php.

In my Kernel I have:

protected function schedule(Schedule $schedule)
{
        $schedule->call(function () 
        {

    // my code here which fails to load the correct php version and its extensions

    })->everyMinute();
}
01 Sep
1 year ago

aacook left a reply on Php Artisan And Kernel.php Running Different PHP Versions On Mac OSX

Thank you!

When I run $ php -i |grep php.ini, it's showing /usr/local/php5/lib/php.ini but the cron is still showing 7.1.14. Very weird.

aacook started a new conversation Php Artisan And Kernel.php Running Different PHP Versions On Mac OSX

I'm facing a strange issue on my Mac local development. When I run $ php artisan serve and go to phpinfo, it shows PHP 5.6 with the imap version enabled.

When I run phpversion() in my browser I get 5.6.31 and imap works.

However, when I run the same code in Kernel.php it shows 7.1.14 as the PHP version with imap not being enabled.

I'm using homebrew but I uninstalled php 7.

Anyone know of a way to get the kernel to run the same version of PHP that's being used in artisan?

23 Jan
1 year ago

aacook left a reply on Registration / Login Issues

Thank you so much. Awesome. Had no idea. Going to give this a whirl.

22 Jan
1 year ago

aacook started a new conversation Registration / Login Issues

I'm facing a strange bug in Laravel 5.4.36 that I can't seem to reproduce locally. For some reason, some of my users who try registering are not being redirected. Instead, they're being redirected back to the registration screen with an error stating the email they just used is already taken. But they just signed up using that email which is super confusing. The user entry is in the database and the user is able to go to the login screen and login. But I'd like to figure out the root of the issue since some number of users bounce in confusion/frustration to never return again.

In web.php I have these two entries: Route::auth(); Auth::routes();

I have a basic validator in place in my RegisterController.

protected function validator(array $data) {

return Validator::make($data, [ 'name' => 'required|string|max:191', 'mobile' => 'required|unique:users|mobile_valid', 'email' => 'required|string|email|max:191|unique:users', 'password' => 'required|string|min:6|confirmed', ]);

}

I thought maybe this error was being caused by the user's browsers submitting twice so I added this jquery a while back, but today I witnessed yet another user experience the issue.

$( document ).ready(function() {

        $('form').submit(function(){
          $(this).find(':submit').attr('disabled','disabled');
        });

    });

Again, the tough part is I'm not able to reproduce it locally.

Has anyone experienced a similar issue?

27 Oct
1 year ago

aacook left a reply on Runaway Server Via Beanstalkd

Ok I think I solved the issue. Just in case someone else has this problem in the future:

$ cd /etc/supervisor/conf.d $ ls

I copied the 1 configuration file I had in here just in case. $ cp worker-147506.conf ~

then deleted it: $ sudo rm worker-147506.conf

then reboot Supervisor: $ service supervisor restart

After that I was able to create a new worker in the Forge UI.

aacook started a new conversation Runaway Server Via Beanstalkd

I made the stupid move to use a setting of 100 processes on a beanstalkd configuration. At first mysql died and I couldn't even $ ls. Then I upsized to 4GB. I tried deleting the worker in Forge, but, even though I have zero beanstalkd workers listed, it seems like the setting is stuck on the server-side. Via $ htop: https://www.dropbox.com/s/7yqj3db4lkxfxaf/Screenshot%202017-10-27%2012.42.23.png?dl=0

Is there a way to edit the queue settings on the server side rather than through the Forge UI? I contacted support, but, in the past I've had to wait a few hours or haven't heard back from support at all so I'm hoping someone from the forum might be able to help.

24 Apr
2 years ago

aacook left a reply on Running Beanstalkd Process Ruby Script (shell Issue)

Turns out I needed to load the full path to ruby.

$ which ruby

Then to queue the job

new Process( "/home/forge/.rbenv/shims/ruby myfile.rb arg1 arg2" );

23 Apr
2 years ago

aacook started a new conversation Running Beanstalkd Process Ruby Script (shell Issue)

I'm working on a project that requires a ruby script on the backend. Everything works just fine with a database queue, both locally and on production (with Laravel Forge).

But, when I move over to beanstalkd queues ruby fails to load. I get this error:

sh: 1: ruby: not found

It seems like beanstalkd is loading the sh shell profile, but should be loading bash.

Does anyone know how to configure beanstalkd to run as the forge user, using the default shell (and load ruby/rbenv)?

26 Jul
3 years ago

aacook left a reply on How To "from Table Where (x And Y) AND Z = S" In Laravel

Great success - for those who end up stumbling on this thread. Take advantage of advanced wheres: https://laravel.com/docs/4.2/queries#advanced-wheres

  $db_results = DB::table('bills')
                
                ->where('company_id', '=', $company->id)
                ->where('is_paid', '=', 0)
                ->where(function ($query) use ($search, $tag_total, $tag_billnum) {
                    $query->where('payee', 'LIKE', "%$search%")
                    ->orWhere('total', '=', "$search")
                    ->orWhere('billnum', 'LIKE', "%$search%");
                })
                ->orderBy($actual_sort, 'ASC')
                ->get();

Wasn't able to get my tags to work in this case but that's okay.

aacook left a reply on How To "from Table Where (x And Y) AND Z = S" In Laravel

So it turns out adjusting the search does give me a result when it didn't before, however, I still can't figure out how to join where statements together. It looks like if I use the orWhere option, Laravel interprets it differently than I'd hope.

Here's what I've got:

 $tag_total = DB::table('bills')
            ->orWhere('total', '=', "$search");

 $tag_billnum = DB::table('bills')
            ->orWhere('billnum', 'LIKE', "%$search%");

 $db_results = DB::table('bills')
                ->where('company_id', '=', $company->id)
                ->where('is_paid', '=', 0)
                ->where('payee', 'LIKE', "%$search%")
                ->union($tag_total)
                ->union($tag_billnum)
                ->orderBy($actual_sort, 'ASC')
                ->get();

Behind the scenes Laravel seems to be doing something like:

select * from bills where company_id = %d and is_paid = %d and payee like '%search%' or total = search or billnum like '%search%';

When I want it to do something like:

select * from bills where (company_id = %d and is_paid = %d) and payee like '%search%' or total = search or billnum like '%search%';
22 Jul
3 years ago

aacook left a reply on How To "from Table Where (x And Y) AND Z = S" In Laravel

Oh man, rookie mistake. Thanks a bunch. This is a pretty sweet community.

aacook started a new conversation How To "from Table Where (x And Y) AND Z = S" In Laravel

I've got a table, bills. I want to let the user search by payee (e.g. "Coca Cola"), by total (e.g. 55.35) or bill number (billnum).

Schema::create('bills', function (Blueprint $table) {
            $table->increments('id');

            $table->integer('company_id')->unsigned()->index(); 
            $table->string('billnum')->index();
            $table->string('payee')->index();
            $table->dateTime('date_issued');
            $table->dateTime('date_due');
            $table->decimal('total', 20, 2)->index();
            $table->decimal('balance', 20, 2)->index();
            $table->text('memo');
            $table->text('scan_url');
            $table->boolean('is_bill_payment');
            $table->boolean('is_paid');

            $table->boolean('pay_overnight');
            $table->boolean('pay_return_to_client');
            $table->decimal('pay_amount', 20, 2);
            $table->timestamps();
        });

Here's my query for searching just the payee. It's a start, but I want to add billnum and total too.

$db_results = DB::table('bills')
                ->where('company_id', '=', $company->id)
                ->where('is_paid', '=', 0)
                ->where('payee', 'LIKE', "%$search%")
                ->orderBy($actual_sort, 'ASC')
                ->get();

What I'd normally do in straight sql:

select * from bills where (company_id = %d and is_paid = %d) and payee like '%search%';

I tried the following but it's not returning valid results:

  $tag_billnum = DB::table('bills')
            ->orWhere('billnum', 'LIKE', '%$search%');

           $db_results = DB::table('bills')
                ->where('company_id', '=', $company->id)
                ->where('is_paid', '=', 0)
                ->where('payee', 'LIKE', "%$search%")
                ->union($tag_total)
                ->orderBy($actual_sort, 'ASC')
                ->get();

The answer is probably something silly. Anyone know how to approach this?

21 Jul
3 years ago

aacook left a reply on Reset Password Manually Without Email

Doh! Well, it turns out I wasn't properly inserting into the passwords_reset table - wasn't defining created_at:

  DB::table('password_resets')->insert( ['email' => $this->email, 'token' => $token] );

and should've been doing:

 DB::table('password_resets')->insert( ['email' => $this->email, 'token' => $token, 'created_at' => Carbon::now()] );

While investigating, I noticed Laravel encrypts the token. Unsure if this is necessary, but I updated my token to match what's in DatabaseTokenRepository->createNewToken()

$token = hash_hmac('sha256', Str::random(40), $this->hashKey);

aacook left a reply on Reset Password Manually Without Email

Should I really start a new thread? Seems fitting to comment here on the sample code itself. Happy to start one if necessary. I'm new here so don't really know the protocol.

So it seems like the bug comes down to Laravel / Carbon saying the tokens are expired when they're not. It looks like Carbon is using a different timezone than mysql. All of the tokens are coming back expired. In my case, Carbon::now() is giving a timestamp 3 hours ahead of the token expiration.

Curious, why doesn't Laravel just tell the user the token expired, rather than give a generic error for both invalid and expired tokens? Is this for security reasons?

20 Jul
3 years ago

aacook left a reply on Reset Password Manually Without Email

@bashy - I'm trying a similar approach but Laravel doesn't seem to like the tokens I'm generating. In the sample auth views, on /password/reset/, I get this error: This password reset token is invalid.

For example, I have the URL: http://localhost:8000/password/reset/edcjmoygpi8rhbucn1v7azgxkcsvc7avipxyft5gmkz3nsobkl7r6g2zhavynk08?email=(my email)

The token edcjmoygpi8rhbucn1v7azgxkcsvc7avipxyft5gmkz3nsobkl7r6g2zhavynk08 is exactly what I see in the passwords_reset table.

Is this approach still working for you?