MickBee

MickBee

Member Since 4 Months Ago

Experience Points 5,120
Experience
Level
Lessons Completed 42
Lessons
Completed
Best Reply Awards 0
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.

10 Oct
2 months ago

MickBee started a new conversation PHP-VCR

Hi,

We have just been discussing mocking calls to external APIs.

One way of doing this, is using php-vcr (https://laracasts.com/lessons/testing-http-requests).

This video looks a little old (2014).

Is this still the recommended way?

Cheers,

Mick

02 Oct
2 months ago

MickBee started a new conversation Include External CSS And JS In Single Page Component.

How should I be doing this?

I only want these files to be loaded, when the component is loaded.

19 Sep
2 months ago

MickBee left a reply on When To Break REST.

Nice one, that is an interesting way of doing things. I'm not sure that I want to go that far, I like just having a controller for each model. I think this makes it easier to find code if you are not familiar with the application.

Having said that, I do like his first rule: Nested resource = new controller.

Mick

MickBee started a new conversation When To Break REST.

Hi,

I am trying to use REST as much as possible. When is it acceptable to create your own route names?

I generally feel that for standard CRUD actions REST can used but for additional actions you need to create your own route names?

What does everyone else do?

Mick

10 Sep
3 months ago

MickBee left a reply on Testing That A Guzzle Call Is Made In An Event Listener.

I'm thinking about this a bit differently now. I am doing it in two ways:

1, test that the event listener is fired. 2, test the Guzzle post response separately.

Mick

MickBee started a new conversation Testing That A Guzzle Call Is Made In An Event Listener.

Hi,

I have an event listener that fires when a new model is created.

In this listener, a Guzzle POST is made (internal API which returns JSON).

How can I confirm in a test, that this call is being made and getting the correct response?

Thanks,

Mick

06 Sep
3 months ago

MickBee left a reply on Ajax Table Editing

The Editor component does the editing:

https://editor.datatables.net/

I agree, it is difficult because there are many ways to do it, I think it is easier to do the editing on a separate page (or modal).

Mick

MickBee left a reply on Connection Second DB

I can't really see what the problem is but this is how I have achieved this:

In database.php, make sure your have the database connection defined:

 'mysqlProductsDB' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST_PRODUCTS', 'localhost'),
            'database'  => env('DB_DATABASE_PRODUCTS', 'forge'),
            'username'  => env('DB_USERNAME_PRODUCTS', 'forge'),
            'password'  => env('DB_PASSWORD_PRODUCTS', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],


Then in your model. you just need:

protected $connection = 'mysqlProductsDB';

Does that not work?

Mick

MickBee left a reply on Ajax Table Editing

Can I suggest cheating instead: https://datatables.net/

15 Aug
4 months ago

MickBee left a reply on Lumen API Token Authentication

Thanks @salmon

"Can the existing API handle authentication for you and then make all API calls to the new Lumen API?"

The existing application is not an API, it is a full Laravel application, so yes it can handle the auth.

"If you don't need the users to interact with the new Lumen API, you can get away with configuring the new Lumen API so that it only accepts calls from your current api"

Users do not interact with the API, only the application does.

So, yes, configuring the Lumen API, to only accept calls from authenticated users sounds perfect. Where do I start with that?

MickBee left a reply on Lumen API Token Authentication

Yes @salmon we have an existing Laravel web application which users log into.

We are now developing a Lumen api, the same set of users will use the api.

Thanks,

Mick

MickBee started a new conversation Lumen API Token Authentication

Hi,

I am just looking at securing me new API, it is internal, so we are just using a token in the headers.

I was reading this: http://www.php-dev-zone.com/2018/02/lumen-rest-api-authentication.html

This suggests that the API has access to a users table, is that correct? Should it have its own users table? Or connect to the one belonging to the application?

Cheers,

Mick

14 Aug
4 months ago

MickBee left a reply on API Resources In Lumen

It looks like they are working, Lumen just doesn't have the make commands.

Mick

MickBee started a new conversation API Resources In Lumen

Hi,

I just noticed that API Resources (https://laravel.com/docs/5.6/eloquent-resources) are not in Lumen. I would have thought that this is the place where they would have been needed most (instead of using Fractal)?

How is everyone else transforming the data, in their Lumen APIs?

Thanks,

Mick

MickBee left a reply on How To Use Sqlite When Testing Lumen.

Yes, that has sorted it. If anyone else gets this, you need to set the default configuration file on the PHP->Test Frameworks page.

MickBee left a reply on How To Use Sqlite When Testing Lumen.

@tykus you are a genius, yes phpUnit.xml is used when I run from the command line.

I think that this means that my configuration is wrong in PHPStorm (this is where I am executing the tests from).

MickBee left a reply on How To Use Sqlite When Testing Lumen.

Still the same :-(.

MickBee left a reply on How To Use Sqlite When Testing Lumen.

@tykus do you have a database.php file or a config directory?

MickBee left a reply on How To Use Sqlite When Testing Lumen.

Once again @crnkovic thanks for your helpful contribution. If it is that easy, why not post one of these links here?

@tykus thanks for looking, this is exactly the same as mine and it still resets my mySQL database, I wonder if something is wrong somewhere else.

13 Aug
4 months ago

MickBee left a reply on How To Use Sqlite When Testing Lumen.

Thanks @tykus, I appreciate your help.

MickBee left a reply on How To Use Sqlite When Testing Lumen.

Still doing the same, I now have this:

 <php>
        <env name="APP_ENV" value="testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
        <env name="DB_CONNECTION" value="testing" />
   </php>

MickBee left a reply on How To Use Sqlite When Testing Lumen.

@tykus I tried that first and it isn't working (my MySQL database gets reset, so I assume that it is connecting to that)

@crnkovic thankyou for your valuable input.

MickBee started a new conversation How To Use Sqlite When Testing Lumen.

Hi,

I am wondering how do to this with Lumen because there is no database.php?

    <env name="APP_ENV" value="testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
        <env name="DB_CONNECTION" value="database.sqlite" />
        <env name="DB_DATABASE" value=":memory:" />

Thanks,

Mick

MickBee started a new conversation Should I Be Using Models In Lumen?

Hi,

Does the fact that with->Eloquent() is commented out suggest that I shouldn't be using models in my API?

Thanks,

Mick

06 Aug
4 months ago

MickBee left a reply on Private Method Injection In A Trait

Yes that is correct. But in my trait I want the Optimus object to be automatically resolved and injected.

Maybe it's not possible and I need to do this:

$optimus = app()->make('Optimus');