Veleous

Veleous

Member Since 4 Years Ago

Experience Points
6,610
Total
Experience

3,390 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.

Level 2
6,610 XP
Sep
28
3 weeks ago
Activity icon

Started a new Conversation Where To Locate Validation Rules And Rules Based On HTTP Verbs

Couple of questions:

What is the convention (if there is one) for locating input validation rules?

Currently I have a function on my eloquent model (which I call from where-ever) that returns an array of validation rules. This feels acceptable to me as it keeps the validation reusable in one place and that my model encapsulates its own validation rules, however, this leads into my next question.

How do people cater for rules based on the request HTTP verb?

Rules for creating a model may differ from those for updating. All fields might be required during a POST, but I might want to allow partial updates via PATCH.

I read this discussion which seems reasonable, but I am not thrilled at the prospect of leading request data into my model (i.e. having to pass the verb as a parameter to my models rules function).

Jul
19
3 months ago
Activity icon

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());
}
Jul
17
3 months ago
Activity icon

Replied to 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?

Activity icon

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?

Jun
22
4 months ago
Activity icon

Replied to 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.

Activity icon

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)?

Jun
20
4 months ago
Activity icon

Replied to 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?

Activity icon

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?

Jun
12
4 months ago
Activity icon

Replied to Declare Middleware Use In Route File Or Controller

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

Activity icon

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?

Jun
09
4 months ago
Activity icon

Replied to 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.

Activity icon

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.