gn0rt0n

Experience

72,960

0 Best Reply Awards

  • Member Since 3 Years Ago
  • 1173 Lessons Completed
  • 0 Favorites

11th September, 2017

gn0rt0n left a reply on Is There A Time Limit/max-length Of An Artisan Command? • 2 months ago

These are processes that I currently handle in Perl. Design isn't the issue. Sometimes work takes that long. Not everything can be handled during a browser session. I am trying to determine if I can unify the codebase under PHP, rather than passing things off to Perl and Python.

Php/Laravel may not be the best fit for these processes though. That is what I am trying to discover.

Thanks for your feedback though.

gn0rt0n started a new conversation Is There A Time Limit/max-length Of An Artisan Command? • 2 months ago

How long (time) of a process could I pass off to an Artisan command? Would it be possible to have a Laravel controller spawn an Artisan command that took 15 minutes to run? 30 minutes? What is the top-end for these processes?

19th April, 2016

gn0rt0n left a reply on Lesson Request: Testing Vue • 1 year ago

+1

11th March, 2016

gn0rt0n left a reply on Creating A <select> Without Form Builder • 1 year ago

@willvincent Yeah, I had thought about the loop, but then I also need to take into account issues for an item that is currently selected. I guess I could just put the code in a snippet, but wanted to see if others had something they had been doing.

I'm trying to reduce my dependencies on external mods, and since they removed form builder from core, I am wanted to see my options before including it again. I may just go back to using form builder, since I would have similar logic for checkbox lists as well. Form builder did make management of those easier as well.

gn0rt0n started a new conversation Creating A <select> Without Form Builder • 1 year ago

I am looking for an example of creating a form using a list from Laravel without using the Form Builder. My searches both here and on google have come up empty. Does anyone have an example?

2nd March, 2016

gn0rt0n left a reply on Laravel 5.2 - Are Behat/Codeception Out Of Favor? • 1 year ago

@greenleaf I had actually considered that the other day (extraction/separate package) and based what I have seen over the last couple of days, that might be the way to go. I have not looked at the facebook webdriver yet, so thank you for the link. It definitely seems to be more current and maintained.

gn0rt0n left a reply on Laravel 5.2 - Are Behat/Codeception Out Of Favor? • 1 year ago

I have tried adding the behat driver. There is currently a bug with the versioning of mink-browser-kit driver (https://github.com/laracasts/Behat-Laravel-Extension/issues/41). I have tried the solution listed by one of the posters in that thread, but was not successful. I spent a few hours with it, but wasn't able to get it resolved and have not revisited it since then.

It was actually that that lead me to this post. It just didn't seem that there was much activity related to behat anymore.

I'll continue to work with it in the next few days, but I just wanted to find out what the current Selenium solution was for people.

gn0rt0n left a reply on Laravel 5.2 - Are Behat/Codeception Out Of Favor? • 1 year ago

I'm not sure I understand your comment. Laravel is wonderful, however, as of right now, there doesn't seem to be a Selenium solution, whereas 1 year ago there was.

29th February, 2016

gn0rt0n left a reply on Laravel 5.2 - Are Behat/Codeception Out Of Favor? • 1 year ago

Yeah, that's what I was afraid of. I've been using the laravel stuff which is fine for integration testing. However now that I need selenium support, I'm not really seeing a clear-cut winner. I was hoping that there were some other solutions out there that are a little more current than the ones I've listed.

gn0rt0n started a new conversation Laravel 5.2 - Are Behat/Codeception Out Of Favor? • 1 year ago

It seems that there hasn't been much activity on the Behat-laravel driver lately and it's currently out of data on some of it's dependencies. I don't see much talk about codeception anymore either.

Have Behat and Codeception kind of been pushed to the side since the inclusion of portions of the Laravel Integrated package?

I want to start testing with some Selenium support, and that hasn't been included as part of Laravel yet. The integrated package also hasn't had many updates.

I guess I am just trying to figure out what people are using for their Acceptance level testing right now when Javascript support is needed.

20th February, 2016

gn0rt0n left a reply on Polymorphic Relationships With Non-integer Key • 1 year ago

I guess I'm a little confused by your reply. The SKU is the primary key in this case. There are many instances where a numerical ID is not the primary key of a table other cases would consist of guid-based Id's.

Let me know if I have misunderstood what you were trying to convey. I appreciate your reply.

gn0rt0n started a new conversation Polymorphic Relationships With Non-integer Key • 1 year ago

I am trying to implement model versioning in my system and I have a few tables that do not have integers as their primary key such as:

products.sku
```

How could I work with polymorphic relations in this case? The examples I have seen typically define something like this :

```
 $table->integer('versionable_id');
```

This would work fine where tables have PK's that are int's, but in my system I have a couple of table sthat I don't have liberty to change the PK to ints from text(varchar()).

Is this possible?

9th February, 2016

gn0rt0n started a new conversation Sorting With Nested Eager Loading • 1 year ago

I have the following tables:

makes -> hasMany vehicle_models (Has field name I want to sort on)

vechicle_models -> belongsTo makes (Has fields Name, Year I want to sort on)
vechicle_models -> hasMany products

products -> hasMany vehicle_models

I am pulling products with the following query:

$this->product
            ->with(
                [
                    'vehicles_models' => function ($query) {
                        $query->with([
                                'make' => function ($query) {
                                    $query->orderBy('name');
                                }
                            ]
                        )
                            ->orderBy('models.year')
                            ->orderBy('models.name');
                    }
                ],
                'brand'
            )
            ->findOrFail($id, $columns);

I can get the data to return to blade just fine. The problem is when I want to sort:

                @foreach($product->vehicle_models as $vehicle_model)
                    <li>
                        {{ $vehicle_model->year }}
                        {{ $vehicle_model->name }}
                        {{ $vehicle_model->make->name }}
                    </li>
                @endforeach

This give me sorting based on the values of the vehicle_models table. However, I would like to be able to display products sorted like this:

Make Name, Model Name, Year

So in essence I want:

Chevy Silverado 1500 - 2015
Chevy Silverado 1500 - 2014
Ford F150 - 2015
Ford F250 - 2015
etc.

as my display.

I'm not sure if I can do this with eager loading. However, if I switch to raw SQL and generate the query sorting that I want I lose the ability to have nested objects return to me as it flattens the data out. That is assuming I am generating my queries properly.

Is what I want to do possible with eager loading? If not, how would I go about getting these results.

The display page is on a 'Show' page for a CRUD object. I want to list a given product and display all related vehicles for the product sorted by: make.name model.name model.year

27th January, 2016

gn0rt0n left a reply on Db:seed Issue With Postgres • 1 year ago

On a side note, you can also tell Postgres to set a default timestamp on those columns using the DB::RAW syntax.

$table->timestamp('created_at')->default(DB::RAW('CURRENT_TIMESTAMP'));
$table->timestamp('updated_at')->default(DB::RAW('CURRENT_TIMESTAMP'));

Note, the following syntax will not work as it doesn't support the chaining of ->default. You have to all the fields separately, rather than with the combined timestamps call.

$table->timestamps()->default(DB::RAW('CURRENT_TIMESTAMP'));

26th January, 2016

gn0rt0n left a reply on Problems With Integration Testing And Repositories • 1 year ago

I know it can be difficult to give reasons why not to use packages when speaking about projects of other people since you may want to avoid offending people. However, if you could give me some reasons why, I would really appreciate it. It seems to have some very nice features, although there are some I won't use. So I'm looking for guidance on what about the package would make you not want to use it.

I guess I would really like some advice, or even an actual Laracasts that describes what to look for and what to avoid when using public packages. There are so many to choose from, it can be difficult to know when not to reinvent the wheel, and when to roll your own.

25th January, 2016

gn0rt0n left a reply on Problems With Integration Testing And Repositories • 1 year ago

Thanks Tyler!

That is a much cleaner solution. I don't like to new things up unless I have to.

gn0rt0n left a reply on Problems With Integration Testing And Repositories • 1 year ago

I got it working with this code:

<?php

use App\Domain\Vehicles\Make\Make;
use App\Domain\Vehicles\Make\MakeRepositoryEloquent;
use Illuminate\Container\Container as Application;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;


class MakeTest extends TestCase
{
    use DatabaseMigrations;
    use DatabaseTransactions;

    protected $repository;

    public function setUp()
    {
        parent::setUp();

        $this->repository = new MakeRepositoryEloquent( new Application );
    }

    /** @test */
    public function it_fetches_a_make()
    {
        // Given I have a make
        $make = factory( Make::class )->create();

        // When I fetch the first make
        $foundMake = $this->repository->find( 1 );

        // Then I should see they match
        $this->assertEquals( 'foo', $make->name );
    }
}

Thanks for pointing me in the right way Jeffery!

gn0rt0n left a reply on Problems With Integration Testing And Repositories • 1 year ago

Well, I guess it's making progress since I got a new error. I am using: https://github.com/andersao/l5-repository (the github namespace is different than the namespace in the error, but they are the same).

It seems that there needs to be some kind of injection with this module, but perhaps that is beyond the capabilities of the PHPUnit tests.

If that is the case, is there any way you can think of that I can do integration testing using real data? I suppose one way might be to actually have the test hit a web page and then look/see in the page, but it is less convenient than just testing against the DB results themselves.

There was 1 error:

1) MakeTest::it_fetches_a_make
TypeError: Argument 1 passed to Prettus\Repository\Eloquent\BaseRepository::__construct() must be an instance of Illuminate\Container\Container, none given, called in /home/vagrant/te-admin/tests/integration/vehicles/MakeTest.php on line 21

/home/vagrant/te-admin/vendor/prettus/l5-repository/src/Prettus/Repository/Eloquent/BaseRepository.php:87
/home/vagrant/te-admin/tests/integration/vehicles/MakeTest.php:21

use App\Domain\Vehicles\Make\Make;
use App\Domain\Vehicles\Make\MakeRepositoryEloquent;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;


class MakeTest extends TestCase
{
    use DatabaseMigrations;
    use DatabaseTransactions;

    protected $repository;

    public function setUp()
    {
        parent::setUp();

        $this->repository=  new MakeRepositoryEloquent;
    }

    /** @test */
    public function it_fetches_a_make()
    {
        // Given I have a make
        $make = factory(Make::class)->create();

        // When I fetch the first make
        $foundMake = $repository->find(1);

        // Then I should see they match
        $this->assertEquals($foundMake->name, $make->name);
    }
}

gn0rt0n left a reply on Problems With Integration Testing And Repositories • 1 year ago

Here is the test for reference:

<?php

use App\Domain\Vehicles\Make\Make;
use App\Domain\Vehicles\Make\MakeRepositoryEloquent;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;


class MakeTest extends TestCase
{
    use DatabaseMigrations;
    use DatabaseTransactions;

    protected $repository;

    public function __construct(MakeRepositoryEloquent $repository)
    {
        $this->repository =  $repository;
        parent::__construct();
    }

    /** @test */
    public function it_fetches_a_make()
    {
        // Given I have a make
        $make = factory(Make::class)->create();

        // When I fetch the first make
        $foundMake = $repository->find(1);

        // Then I should see they match
        $this->assertEquals($foundMake->name, $make->name);
    }
}

gn0rt0n started a new conversation Problems With Integration Testing And Repositories • 1 year ago

I am trying to setup integration testing and want to use my repositories.

I have tried setting the repository up using both the __construct() and setUp() method (PHPUnit using Laravel TestCase). I have tried passing in both the interface, as well as the concrete implementation.

However, I can't seem to get it to work. I want to test actual data, not Mocks.

Errors I have received include:

Argument 1 passed ... must be an instance of ....

Any advice?

23rd January, 2016

gn0rt0n left a reply on Foreign Key Nullable • 1 year ago

Yes, foreign keys can be nullable. However in your code: 'trainee_id' => $trainee_id,

You are trying to assign $trainee_id, but you have it commented out above. So in this case you are not assigning a NULL value, but rather an undefined variable.

Perhaps you want: 'trainee_id' => null,

21st January, 2016

gn0rt0n left a reply on Factory Requires Model To Have An `id` Column? • 1 year ago

Awesome. Thank you for your quick reply. I had assumed there was a way to do it, but my search-fu failed me.

gn0rt0n started a new conversation Factory Requires Model To Have An `id` Column? • 1 year ago

I have a country table that has a primary key based on country code (2 letters). When creating a test record with factory, I am give this error:

SQLSTATE[42703]: Undefined column: 7 ERROR: column "id" does not exist

It seems that it is related to the 'returning "id"' statement that factory is issuing. I can probably fix this by adding an id column, to the table. However, I don't think I should have to, as I already have a primary key.

I can't find anywhere that discusses this. Does anyone know if I can override this behavior? FWIW, I am using pgsql as the DB type.

6th November, 2015

gn0rt0n left a reply on API Authentication: Browser Vs Mobile App • 2 years ago

@jlrdw Laravel will be used to create the API and a webclient to consume the API. The mobile apps will not be able to use Laravel. They would be built using Cordova and consume be consume an AngularJS SPA.

@uxweb I have looked at the JWT package, but from what I can see it is only for managing they way credentials are tokenized, and not related to the authentication itself. As such, it would not be able to allow you to login using your Google/Facebook/Github credentials. I believe that JWT could be used in conjunction with oAuth2 to accomplish though, but that takes me back to my original question about my need for an oAuth2 server, or just an oAuth2 client component.

gn0rt0n left a reply on API Authentication: Browser Vs Mobile App • 2 years ago

That would work if I was just making the site mobile-friendly. We will actually be using mobile applications for the IOS/Android. Specifically I am looking at API Authentication. If the site were just going to be mobile friendly, I would ignore the API approach all together.

gn0rt0n started a new conversation API Authentication: Browser Vs Mobile App • 2 years ago

I want to create an API using Laravel (or Lumen) that will service both web and mobile clients.

I am trying to figure out what type of authentication is best to use. Would you recommend setting up my own Oauth2 server, or using the services provided by Google/GitHub etc? Basically, If I don't have my own OAuth2 server, will I be able to coordinate accounts information for users across mobile apps and the website (assuming I use the same client_id and client_secret for both platforms)?

I am still trying to get my arms around what will work best for the API, and authentication has me really confused.

17th June, 2015

gn0rt0n started a new conversation Switching Between Multiple .env Files (Laravel 5.1) • 2 years ago

I have my normal .env file configured with variables for normal development. However, I also have a .env.behat file which is called and referenced during execution of behat suite.

I am having a problem with one of my behat tests and would like to use PHP tinker to work with the objects against the behat database configured in .env.behat

I have tried running php tinker --env=behat and I see that that environment is reference properly within tinker. However, it doesn't appear to be using the database or other variables set in .env.behat.

How can I switch between multiple .env files? Since behat is doing it, it appears to be possible, but I am not seeing an elegant way to accomplish this.

Edit Your Profile
Update

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