flyingL123

flyingL123

Member Since 1 Year Ago

Experience Points 12,880
Experience Level 3

2,120 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 124
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.

25 Jan
3 months ago

flyingL123 started a new conversation How To Use Mysql_config_editor To Connect Laravel To Mysql

It seems like the most secure way of specifying login credentials to a mysql database is through the mysql_config_editor method, explained here: https://dev.mysql.com/doc/refman/5.6/en/mysql-config-editor.html

Is it possible to instruct Laravel to use this method? Rather than storing my mysql credentials in the .env file, I would prefer to store them in this encrypted .mylogin.cnf file. Then, in the .env file, I could specify which 'login path' should be used to connect.

Is there a built in way to do this in Laravel?

24 Jan
3 months ago

flyingL123 left a reply on Changing Forge Root Password Not Working

@BOBBYBOUWMANN - Thanks. I'm aware you can change the password from the control panel in Forge. That's the issue though. Even the change password functionality doesn't work. They must use the existing password to login and set the new one, but they don't know the correct current password, so it's not working.

flyingL123 started a new conversation Changing Forge Root Password Not Working

I had an issue earlier today that required me to reset my root mysql password manually by SSH'ing into the server. I followed these instructions and successfully reset the password: https://www.digitalocean.com/community/tutorials/how-to-reset-your-mysql-or-mariadb-root-password-on-ubuntu-18-04

However, now I am receiving a permission denied error when I try to do anything database-related from the Forge control panel. For example, if I try to add another user, or change the password, the output of the command is ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).

Did changing the password manually cause this? Does Forge store their own copy of the password somewhere, and since it has changed, the access denied error occurs? How can I resynchronize these passwords so that the control panel functions as intended?

flyingL123 left a reply on Please Help - No Mysql Access All Of A Sudden

@AURAWINDSURFING - Somehow my 'forge' database user got deleted from mysql. This must have somehow happened during the automatic updates that occur on the server. I can see following entries in /var/log/apt/history.log:

Start-Date: 2019-01-24  06:36:21
Commandline: /usr/bin/unattended-upgrade
Upgrade: mysql-client-5.7:amd64 (5.7.24-0ubuntu0.18.04.1, 5.7.25-0ubuntu0.18.04.2)
End-Date: 2019-01-24  06:36:22

Start-Date: 2019-01-24  06:36:25
Commandline: /usr/bin/unattended-upgrade
Upgrade: mysql-client-core-5.7:amd64 (5.7.24-0ubuntu0.18.04.1, 5.7.25-0ubuntu0.18.04.2)
End-Date: 2019-01-24  06:36:26

Start-Date: 2019-01-24  06:36:29
Commandline: /usr/bin/unattended-upgrade
Upgrade: mysql-server:amd64 (5.7.24-0ubuntu0.18.04.1, 5.7.25-0ubuntu0.18.04.2)
End-Date: 2019-01-24  06:36:29

Start-Date: 2019-01-24  06:36:38
Commandline: /usr/bin/unattended-upgrade
Upgrade: mysql-server-5.7:amd64 (5.7.24-0ubuntu0.18.04.1, 5.7.25-0ubuntu0.18.04.2), mysql-server-core-5.7:amd64 (5.7.24-0ubuntu0.18.04.1, 5.7.25-0ubuntu0.18.04.2)
End-Date: 2019-01-24  06:36:54

These update ran one minute before I first saw the mysql access denied error happening all over my application. I can only assume that these updates somehow deleted my 'forge' user. I followed the steps here to reset my root password:

https://www.digitalocean.com/community/tutorials/how-to-reset-your-mysql-or-mariadb-root-password-on-ubuntu-18-04

This allowed me to access the database, and when I did, I found that there was no 'forge' user at all. This makes no sense since I have been logging in with this user for months. My application also uses this user. So something changed during those updates. It seems like the user got deleted, but I have no idea why.

Is that possible?

flyingL123 left a reply on Please Help - No Mysql Access All Of A Sudden

@AURAWINDSURFING - Sorry, I'm not sure what you mean. I've been using this user for the last 2 months and it's worked without issue. Also, as I said in my question, I did try creating a new user called 'forge2', but when I try to connection to the database with that user from the command line I also get the same error.

flyingL123 started a new conversation Please Help - No Mysql Access All Of A Sudden

Please help. All of a sudden around 2019-01-24 06:37:10 UTC I started receiving errors on my server that:

SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: YES)

I'm unable to access mysql. I did not change anything on my end, so I don't know what happened. When I look through the system logs, I do see some mysql activity around that time:

Jan 24 06:36:07 whispering-hurricane systemd[1]: Starting Daily apt upgrade and clean activities...
Jan 24 06:36:24 whispering-hurricane kernel: [1767450.357697] [UFW BLOCK] IN=eth0 OUT= MAC=32:f4:a6:e9:03:29:f0:4b:3a:4e:50:30:08:00 SRC=85.10.193.56 DST=206.189.227.234 LEN=60 TOS=0x00 PREC=0x00 TTL=56 ID=37186 DF PROTO=TCP SPT=57178 DPT=22123 WINDOW=29200 RES=0x00 SYN URGP=0
Jan 24 06:36:32 whispering-hurricane systemd[1]: Reloading.
Jan 24 06:36:33 whispering-hurricane systemd[1]: Reloading.
Jan 24 06:36:33 whispering-hurricane systemd[1]: Stopped Daily apt upgrade and clean activities.
Jan 24 06:36:33 whispering-hurricane systemd[1]: Stopping Daily apt upgrade and clean activities.
Jan 24 06:36:33 whispering-hurricane systemd[1]: Started Daily apt upgrade and clean activities.
Jan 24 06:36:33 whispering-hurricane systemd[1]: Stopped Daily apt download activities.
Jan 24 06:36:33 whispering-hurricane systemd[1]: Stopping Daily apt download activities.
Jan 24 06:36:33 whispering-hurricane systemd[1]: Started Daily apt download activities.
Jan 24 06:36:38 whispering-hurricane systemd[1]: Reloading.
Jan 24 06:36:38 whispering-hurricane systemd[1]: Stopping MySQL Community Server...
Jan 24 06:36:42 whispering-hurricane systemd[1]: Stopped MySQL Community Server.
Jan 24 06:36:42 whispering-hurricane systemd[1]: Reloading.
Jan 24 06:36:46 whispering-hurricane kernel: [1767472.035497] audit: type=1400 audit(1548311806.292:39): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="/usr/sbin/mysqld" pid=27468 comm="apparmor_parser"
Jan 24 06:36:46 whispering-hurricane kernel: [1767472.069261] audit: type=1400 audit(1548311806.324:40): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=27486 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Jan 24 06:36:46 whispering-hurricane kernel: [1767472.132572] audit: type=1400 audit(1548311806.388:41): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=27501 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Jan 24 06:36:50 whispering-hurricane kernel: [1767476.078756] audit: type=1400 audit(1548311810.336:42): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=27552 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Jan 24 06:36:53 whispering-hurricane kernel: [1767478.885369] audit: type=1400 audit(1548311813.140:43): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="/usr/sbin/mysqld" pid=27601 comm="apparmor_parser"
Jan 24 06:36:53 whispering-hurricane systemd[1]: message repeated 5 times: [ Reloading.]
Jan 24 06:36:53 whispering-hurricane systemd[1]: Starting MySQL Community Server...
Jan 24 06:36:53 whispering-hurricane kernel: [1767479.454427] audit: type=1400 audit(1548311813.708:44): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=27677 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Jan 24 06:36:53 whispering-hurricane kernel: [1767479.499368] audit: type=1400 audit(1548311813.756:45): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=27682 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=113 ouid=0
Jan 24 06:36:54 whispering-hurricane systemd[1]: Started MySQL Community Server.

Can someone help me understand if something in that system log is what caused the problem? How can I fix it? This is our production server and I can not access the database. Neither can our application. Not good.

22 Jan
3 months ago

flyingL123 left a reply on Transaction And Model Events

@challet I highly recommend this package. It fixed my problem without changing a single line of code. Just installed it and the problem was fixed:

https://github.com/fntneves/laravel-transactional-events

flyingL123 left a reply on Transaction And Model Events

Hi @challet I have run into this same problem. I've been reading this thread related thread on Github. There seems to be some disagreement on this.

https://github.com/laravel/framework/issues/8627

Did you ever find a solution that works for you?

07 Jan
4 months ago

flyingL123 left a reply on Bucket Name Not Appearing In S3 Url

@REALRANDYALLEN - Interesting, that works. However, I'm using laravel-paperclip and removing that results in an error:

RuntimeException with message 'Could not determine base URL for storage disk 'paperclip'

It looks like even though Laravel doesn't require it, paperclip does.

06 Jan
4 months ago

flyingL123 started a new conversation Bucket Name Not Appearing In S3 Url

I'm confused. I'm using Laravel 5.6, and I entered my s3 config details like so:

AWS_ACCESS_KEY_ID=MY_KEY
AWS_SECRET_ACCESS_KEY=MY_SECRET
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=mybucket
AWS_URL=https://s3.amazonaws.com

I'm able to upload files correctly. They go to the right bucket. However, when I get a URL for a file on the s3 disk, it doesn't include the bucket in the URL.

echo Storage::disk('s3')->url('path/to/a/file.jpg');

// https://s3.amazonaws.com/path/to/a/file.jpg

Instead, I find that I need to include the bucket in the AWS_URL variable, like this:

AWS_URL=https://s3.amazonaws.com/mybucket

This results in the correct URLs, but is that expected? Do I need to include the bucket in that URL? I thought it was supposed to be included automatically by the framework when generating the URL.

Am I filling these variables out correctly?

I appreciate the help!

31 Dec
4 months ago

flyingL123 left a reply on Is There A Shorthand To Schedule Commands To Be Queued?

@SNAPEY - Ok, that makes sense, but I am still confused about one thing. If the command queues the job, is there any way for me to run the logic in the Job without hitting the queue. If I want to go to the command line and manually run the command with artisan, how can I set it up so the command doesn't always hit the queue, but instead just runs the code in the current process?

Should I add a 'queue' option to the command, and maybe have the default set to 'sync', so it runs immediately if no queue is specified?

flyingL123 left a reply on Is There A Shorthand To Schedule Commands To Be Queued?

@OHFFS - I could, but then I still have a command and a job doing the exact same thing. I was under the impression the command could just be queued, which is why the Artisan::queue() method and the Illuminate\Foundation\Console\QueuedCommand class exist.

flyingL123 left a reply on Is There A Shorthand To Schedule Commands To Be Queued?

@SNAPEY - In my case, I have written a command to export some data to an FTP service. Something like php artisan data:export. I want it to be a command so that I can call it manually from the command line when needed (in the same process, not in the background). However, it will mostly be called on a schedule, and sometimes there are errors with the connection. So I wanted to queue the command so it will be retried if there are errors.

What's the best way to do this? I didn't want to create a Job class whose purpose was to trigger the command with Artisan::call(). Maybe I am not thinking about this correctly.

flyingL123 left a reply on Is There A Shorthand To Schedule Commands To Be Queued?

@_STEFANZWEIFEL - Hmmm, I don't think that's the case. I think it may just be confusing documentation. Because when I run Artisan::queue('command:name');, I see an instance of Illuminate\Foundation\Console\QueuedCommand pushed onto the queue.

Also, as you can see in the docs the the onQueue and onConnection methods can be chained to the call to Artisan::queue():

Artisan::queue('email:send', [
    'user' => 1, '--queue' => 'default'
])->onConnection('redis')->onQueue('commands');

flyingL123 started a new conversation Is There A Shorthand To Schedule Commands To Be Queued?

I can schedule artisan commands like this:

$schedule->command('emails:send --force')->daily();

I can schedule a queue job like this:

$schedule->job(new Heartbeat)->everyFiveMinutes();

I can queue and artisan command like this:

Artisan::queue('email:send', [
    'user' => 1, '--queue' => 'default'
]);

But, from what I can tell, there is no way to nicely schedule a queued artisan command. In other words, I can accomplish what I need like this:

$schedule->call(function () {
    Artisan::queue('command:name');
})->everyMinute();

But it seems like there should be a better way. Is there any way to use the $schedule->job() method, but pass it a command name?

12 Jun
11 months ago

flyingL123 left a reply on Creating And Dropping A Table During Test Breaks RefreshDatabase Trait

Making the stubs table temporary did the trick. Creating a table causes an implicit commit in mysql. Creating a temporary table does not. It also means I don't need to drop the table either, since it happens automatically:

Schema::create('stubs', function ($table) {
    $table->temporary()
    $table->increments('id');
    $table->string('name');
    $table->timestamps();
});

Seems to be working perfectly so far.

flyingL123 started a new conversation Creating And Dropping A Table During Test Breaks RefreshDatabase Trait

I've created a trait using in my Laravel 5.6 app. The trait is called Projectable. This trait is meant to be used by Eloquent models. In order to test the trait, I wanted to create a ProjectableStub model to use in the tests. However, since this is an Eloquent model, it requires a table.

I wanted to simply create and drop a table just for testing. However, when I do this, it seems like something breaks regarding the RefreshDatabase functionality. To demonstrate, I am simply running two tests, both of which try to create a Product model with id = 1. Since the RefreshDatabase trait is being used, this should work fine. And, in the example below, it does:

    <?php
    
    namespace Tests\Feature;
    
    use App\Product;
    use Tests\TestCase;
    use App\Concerns\Projectable;
    use Illuminate\Support\Facades\Schema;
    use Illuminate\Foundation\Testing\WithFaker;
    use Illuminate\Foundation\Testing\RefreshDatabase;
    use Illuminate\Database\Eloquent\Model as Eloquent;
    
    class ProjectableTest extends TestCase
    {
        use RefreshDatabase;
    
        public function setUp()
        {
            parent::setUp();
    
            //$this->createStubTable();
        }
    
        /**
         * @test
         */
        public function example_first_test()
        {
            factory(Product::class)->create(['id' => 1]);
        }
    
        /**
         * @test
         */
        public function example_second_test()
        {
            factory(Product::class)->create(['id' => 1]);
        }
    
        public function tearDown()
        {
            //$this->dropStubTable();
    
            parent::tearDown();
        }
    
        private function createStubTable()
        {
            Schema::create('stubs', function ($table) {
                $table->increments('id');
                $table->string('name');
                $table->timestamps();
            });
        }
    
        private function dropStubTable()
        {
            Schema::dropIfExists('stubs');
        }
    }

    class ProjectableStub extends Eloquent
    {
        use Projectable;
    
        protected $table = 'stubs';
    
        protected $guarded = [];
    }

However, as soon as I uncomment the two lines so that the stubs table is created and dropped, I get a SQL error that a duplicate ID is being used:

    <?php
    
    namespace Tests\Feature;
    
    use App\Product;
    use Tests\TestCase;
    use App\Concerns\Projectable;
    use Illuminate\Support\Facades\Schema;
    use Illuminate\Foundation\Testing\WithFaker;
    use Illuminate\Foundation\Testing\RefreshDatabase;
    use Illuminate\Database\Eloquent\Model as Eloquent;
    
    class ProjectableTest extends TestCase
    {
        use RefreshDatabase;
    
        public function setUp()
        {
            parent::setUp();
    
            $this->createStubTable();
        }
    
        /**
         * @test
         */
        public function example_first_test()
        {
            factory(Product::class)->create(['id' => 1]);
        }
    
        /**
         * @test
         */
        public function example_second_test()
        {
            factory(Product::class)->create(['id' => 1]);
        }
    
        public function tearDown()
        {
            $this->dropStubTable();
    
            parent::tearDown();
        }
    
        private function createStubTable()
        {
            Schema::create('stubs', function ($table) {
                $table->increments('id');
                $table->string('name');
                $table->timestamps();
            });
        }
    
        private function dropStubTable()
        {
            Schema::dropIfExists('stubs');
        }
    }

    class ProjectableStub extends Eloquent
    {
        use Projectable;
    
        protected $table = 'stubs';
    
        protected $guarded = [];
    }
  1. Tests\Feature\ProjectableTest::example_second_test Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY'

Does anyone know why creating and dropping a table within the test is causing this issue? Is there a better way to go about this? Maybe some way to add a migration at runtime for this new table?

12 Mar
1 year ago

flyingL123 left a reply on Best Practice For Developing A Site That Uses 3rd Party APIs

@shez1983 I guess what I'm trying to say is that there isn't actually any real data to fetch because I'm seeding the database with fake information. In production, objects in my database would correspond to real objects in BigCommerce, so the API calls will make sense and work, however, during development, making these API calls doesn't make sense because the corresponding objects don't exist in BigCommerce.

One option that makes sense to me would be to create a 'fake' BigCommerce class that just uses sub function to return fake data. I understand how to do this during tests, by creating mocks and binding to the container during the test or even in a setUp method.

But how would I do this same thing during development?

flyingL123 started a new conversation Best Practice For Developing A Site That Uses 3rd Party APIs

What is the best way to handle developing an app that accesses 3rd-party apis? For example, I have an app that relies on data from the BigCommerce API. Every time a certain route is loaded, a call is made to using a 3rd party BigCommerce library to hit their API. For example,

public function view(Store $store)
{
    $bcStore = Bigcommerce::getStore($store->id);

    // Do some stuff with the data before returning the view

    return view('stores.view');
}

As I am developing this app I am obviously loading this route many times in a browser, which means I'm making an continuously hitting the BigCommerce servers. Additionally, the data I seed my database with for developing is not for real BigCommerce stores, so these continuous calls to the BigCommerce server are all going to fail.

What is the best practice for this sort of situation? During testing I know I can create mocks and use the Service Container to bind the mocks rather than the real classes. Am I supposed to do the same thing for development? If so, where and how do I do this?

Just trying to understand what my options are. This seems like a pretty common thing but I'm struggling to figure out the "right" way to handle it.