jorgejavierleon

jorgejavierleon

Member Since 3 Years Ago

Experience Points 36,010
Experience Level 8

3,990 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 347
Lessons
Completed
Best Reply Awards 3
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.

12 Apr
3 years ago

jorgejavierleon left a reply on Validator: Unique

have you tried it with conditional rules?

$validator->sometimes('product_name', 'unique:products, product_name', function($input) {
    
    $department =  Department::find($input->department_id);
    
    return $department->products()->where('product_name',  $input->product_name)->count();
});
02 Apr
3 years ago

jorgejavierleon left a reply on Interfaces In OOP

I agree, it’s not that easy to implement interfaces, and it is a bit of an art knowing when is appropriate. In the case you mention, I think you should consider some of those classes as abstracts. Interfaces are just contracts, you can have a DogInterface for your Dog class is that make sense for the project. I think Animal, for example, should be an abstract class, and you can make an AnimalInterface if you need that contract.

31 Mar
3 years ago

jorgejavierleon left a reply on Navigate Betwenn 3 Association

Don't use the parenthesis when calling the relations. That's for chaining query constraints.

Do it like this $topic->subCategory->category->isHidden()

30 Mar
3 years ago

jorgejavierleon left a reply on Having Trouble Running Php Artisan Migrate:refresh

Add the table to the on method $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')

29 Mar
3 years ago

jorgejavierleon left a reply on DRY Repositories Interfaces

Thanks for the link @davestewart , I will read the comments and see if I decide to stick with my old concretes repositories instead.

@tag has some great points in there,

DRY can be a double-edged sword as it's a form of coupling, which in itself is maintenance

jorgejavierleon started a new conversation DRY Repositories Interfaces

Hi. I have some doubts about my repositories design. I want to code to an interface all my repositories (although I don’t see myself swapping eloquent any time soon, I want to do that mostly for making my testing easier and to respect the SOLID principles ).

So, for my User model I will have a UserRepositoryInterface and then a DbUserRepository

Also, to avoid duplication, DbUserRepository it’s going to extend and abstract DbBaseRepository with common eloquent methods, all(), find(), etc.

Now, the problem I see is that, even with the abstract DbBaseRepository, I still need to duplicate mostly the same code for all my interfaces. I surely don’t want to do that.

Am I missing something here? Should I have a BaseInterface as well for all my interfaces?

Do you have any recommendations?

28 Mar
3 years ago

jorgejavierleon left a reply on Laravel 5.2 - Socialite - First And Last Name

You could check the result of the api call and see what object are you getting. Linkedin, for example, return an object with an user array, and in there, the first_name and last_name.

$linkedinUser = $this->socialite->driver('linkedin')->user());

$attributes = [
            'first_name' => $linkedinUser->user['firstName'],
            'last_name' => $linkedinUser->user['lastName'],
            'email' => $linkedinUser->email,
            'avatar' => $linkedinUser->avatar,
            'linkedin_id' => $linkedinUser->id
        ];

27 Mar
3 years ago

jorgejavierleon left a reply on Displaying Pretty Names For :attributes On Validator

In the folder for your languages, e.g. resources/lang/es, you need to create a file named 'validation.php' with a general array, and inside of it an array of attributes. Like this one

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Validation Language Lines
    |--------------------------------------------------------------------------
    |
    | The following language lines contain the default error messages used by
    | the validator class. Some of these rules have multiple versions such
    | as the size rules. Feel free to tweak each of these messages here.
    |
    */

    "accepted"             => "El campo :attribute debe ser aceptado.",
    "active_url"           => "El campo :attribute no es una URL válida.",
          

    /*
    |--------------------------------------------------------------------------
    | Custom Validation Language Lines
    |--------------------------------------------------------------------------
    |
    | Here you may specify custom validation messages for attributes using the
    | convention "attribute.rule" to name the lines. This makes it quick to
    | specify a specific custom language line for a given attribute rule.
    |
    */

    'custom' => [
        'attribute-name' => [
            'rule-name' => 'custom-message',
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Custom Validation Attributes
    |--------------------------------------------------------------------------
    |
    | The following language lines are used to swap attribute place-holders
    | with something more reader friendly such as E-Mail Address instead
    | of "email". This simply helps us make messages a little cleaner.
    |
    */

    'attributes' => [
        'email' => 'E-mail',
        'password' => 'clave'       
   ],

];
26 Mar
3 years ago

jorgejavierleon left a reply on Laravel 5.2 Roles

the very next step could be creating an admin middleware that chek if the auth user has the role admin, to protect the admin routes. Have a look at https://laracasts.com/series/laravel-5-from-scratch/episodes/14

jorgejavierleon left a reply on Not Displaying The Desired Output

ohffs is right. Laravel is lookin for the user_id field in your orders table. If you want to keep naming the field "customer_id", you need to override the convention in the custorder() relation, like this return $this->hasMany('App\Order, 'customer_id'); Here is the documentation https://laravel.com/docs/5.2/eloquent-relationships#one-to-many

25 Mar
3 years ago

jorgejavierleon left a reply on Logging Jobs

How about implementing the decorator pattern. In the video decorating-repositories Jeffrey explain how to stack functionality, like logging or caching, by applying that pattern .

jorgejavierleon left a reply on Validating On Update

I manage to get the ids for the rules method passing it as a route argument, and then calling it like this $this->get('id')

The controller method is like this

public function update(UpdateUserRequest $request, $id)
    {
       ...

    }

And in the rules method of the FormRequest

public function rules()
    {
        return ['email' => 'required|email|unique:users,email,'.$this->get('Id')];
    }