Veleous

Veleous

Member Since 4 Years Ago

Experience Points 6,560
Experience Level 2

3,440 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 73
Lessons
Completed
Best Reply Awards 0
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.

19 Jul
1 month ago

Veleous started a new conversation Unit Testing Laravel Validation Rules

Given the validation rules below:

'field' => 'required|string|max:100|unique:table,column'

I have written feature tests that check each validation rule fails/passes and the response messages for the responses.

Example:

function it_should_fail_validation_if_field_not_provided()
{
  // Arrange

  // Act

  // Assert
}

Is there any reason to write unit tests to confirm each of the valuation rules work in isolation, or am I basically writing tests to confirm something that has already been tested as part of the Laravel framework?

Example:

test it_should_be_invalid_if_field_not_provided()
{
  $model = factory(Model::class)->raw(['field' => '']);

  $v = Validator::make($model, $rules);

  $this->assertTrue($v->fails());
}
17 Jul
1 month ago

Veleous left a reply on Duplicate Assertions Using AssertJson And AssertJsonStructure

Yeah I get the distinction between the two assertions and that there may be times one is more appropriate than the other, however, is there any benefit other than clarity (arguably) for doing the following:

->assertJsonStructure([
  'field',
  'another_field' => [
    'nested_field',
    'another_nested_field'
  ]
])
->assertJson([
  'field' => 'value',
  'another_field' => $array
])

In such scenarios, is the assertJsonStructure superfluous?

Veleous started a new conversation Duplicate Assertions Using AssertJson And AssertJsonStructure

If using assertJson which if I understand correctly checks JSON structure and data, is there any point in also using assertJsonStructure in the same test?

22 Jun
2 months ago

Veleous left a reply on Using Doctrine With Third Party Packages

@BOBBYBOUWMANN - That was my assumption.

Not looking to switch as such. Mostly used the data mapper pattern in the past (not PHP projects) and so I was just considering doctrine rather than eloquent for a project, researching the pros and cons.

A big con being it seems, locking myself out of some very neat packages that are readily available.

Veleous started a new conversation Using Doctrine With Third Party Packages

Without looking to incite a riot over the pros and cons of the two patterns, if I chose to make use of Doctrine in my project rather than Eloquent, would I be limiting myself on the third party packages I could make use of in my project?

Do the vast majority of packages for Laravel make the assumption you're using Eloquent in your project(s)?

20 Jun
2 months ago

Veleous left a reply on Package Dependencies During Development

@MANELGAVALDA - Thanks @manelgavalda , that's a pretty smart package. Simple to install and configure, and worked a treat.

Out of curiosity, and for anyone that reads this with a similar issues and doesn't want to use Studio for some reason, would adding include __DIR__.'/../vendor/autoload.php; to the ServiceProvider boot method during testing and then removing it before pushing to a repo be correct?

Veleous started a new conversation Package Dependencies During Development

When creating packages that have dependencies, how do you include them for local testing but not in the published package?

So that I can test locally, I have been adding:

include __DIR__.'/../vendor/autoload.php';

Then when about to push to my repo, I remove that line. This seems a little hacky though, is there a 'correct' method for this?

12 Jun
2 months ago

Veleous left a reply on Declare Middleware Use In Route File Or Controller

Thanks @manelgavalda, I should really have checked the docs before posting.

Veleous started a new conversation Declare Middleware Use In Route File Or Controller

Is there a convention for where the middleware used should be declared, whether it be on the route or in a controller constructor?

09 Jun
2 months ago

Veleous left a reply on Parameterized Envinronment Variables

The parameter keys will remain the same, only the values of some of the keys (1 or 2) will change and not frequently (really only if the app is working in development or production).

I had initially thought of a single varible for simplicity but some of the key values are 40+ characters making the entire variable quite long and a little difficult to read which is why I was considering option 2.

Veleous started a new conversation Parameterized Envinronment Variables

I have an enviromnent variable which is a URI and contains some query parameters that can change based on the enviroment and other factors.

Would it be recommended to keep everything in one environment variable, or have the changable values as separate environtment variables which can then be used to compose the final URI?

Option 1

URI="https://dev.domain.com?key1=fuhsf7w78gww08hb&key2=eofubw97b847fs8f0..."

Option 2

URI="https://%s.domain.com?key1=%s&key2=%s..."
KEY_1="fuhsf7w78gww08hb"
KEY_2="eofubw97b847fs8f0"

Then combine the above somewhere.

13 Jun
1 year ago

Veleous left a reply on How To Properly Use Cross Database Relationships?

@bertholf I'm not sure the answer is in protected $connection as you put it, as the whereHas method that @Riotsmurf is using is not supported across databases.

https://github.com/laravel/framework/issues/4649#issuecomment-49469168

There is a composer package available which provides support for this feature should it be required though.

https://github.com/hoyvoy/laravel-cross-database-subqueries

25 Jul
2 years ago

Veleous started a new conversation BindingResolutionException When Resolving A ServiceProvider

I'm attempting to create a service provider which will inject a dependency into a controller, however, I encounter a BindingResolutionException when attempting to access the controller.

The exact exception message I receive is:

(1/1) BindingResolutionException Target [Stockholm\Address\Domain\Handler\HandlerInterface] is not instantiable while building [App\Http\Controllers\CityController].

I define my ServiceProvider as such.

    <?php

    // app/Providers/AddressServiceProvider.php

    namespace App\Providers;

    use App\Http\Controllers\CityController;
    use Illuminate\Support\ServiceProvider;
    use Stockholm\Address\Domain\Handler\CityHandler;
    use Stockholm\Address\Domain\Handler\HandlerInterface;

    class AddressServiceProvider extends ServiceProvider
    {
        protected $defer = true;

        public function register()
        {
            $this->app->when(CityController::class)
                ->needs(HandlerInterface::class)
                ->give(function() {
                    return new CityHandler();
                });
        }

        public function provides()
        {
            return [
                CityHandler::class
            ];
        }
    }

Register the ServiceProvider in the Providers array.

    <?php
    
    // config/app.php
    
    return [
      'providers' => [
        // clipped
        App\Providers\AddressServiceProvider::class,
      ]
    ]

Define my HandlerInterface.

    <?php
    
    // stockholm/Address/Domain/Handler/HandlerInterface.php
    
    namespace Stockholm\Address\Domain\Handler;
    
    interface HandlerInterface
    {
        // clipped
    }

Define my implementation of the HandlerInterface.

    <?php
    
    // stockholm\Address\Domain\Handler\CityHandler.php
    
    namespace Stockholm\Address\Domain\Handler;
    
    class CityHandler implements HandlerInterface
    {
        // clipped
    }

Add the HandlerInterface as a Constructor argument to my CityController.

   <?php
    
    // app/Http/Controllers/CityController.php
    
    namespace App\Http\Controllers;
    
    use Illuminate\Http\Request;
    use Stockholm\Address\Domain\Handler\HandlerInterface;
    
    class CityController extends Controller
    {
        private $handler;

        public function __construct(HandlerInterface $handler)
        {
            $this->handler = $handler;
        }
    }

My PSR-4 autoload configuration in my composer.json file looks as below.

    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\": "app/",
            "Stockholm\": "stockholm/"
        }
    },